Skip to content

Instantly share code, notes, and snippets.

@marcinbunsch
Created May 29, 2010 13:43
Show Gist options
  • Save marcinbunsch/418286 to your computer and use it in GitHub Desktop.
Save marcinbunsch/418286 to your computer and use it in GitHub Desktop.
require 'appscript'
require 'open-uri'
require 'json'
require 'youtube_g'
include Appscript
itunes = app('iTunes')
safari = app('Safari')
# Get info on track
current_track = "#{itunes.current_track.name.get}"
current_track << " - #{itunes.current_track.artist.get}"
# Get the first video on youTube for that track
client = YouTubeG::Client.new
url = client.videos_by(:query => current_track,
:page => 1,
:per_page => 1).videos.first.player_url
# Open the url in safari
safari.activate
safari.document.URL.set(url)
# Add the url to the comment section of the track
itunes.pause
itunes.current_track.comment.set(url)
require 'appscript'
include Appscript
textedit = app('TextEdit')
textedit.activate
doc = textedit.make( :new => :document )
doc.text.set("Ruby is awesome!\n")
doc.text.size.set(24)
doc.text.color.set('red')
doc.text.font.set('Monaco')
doc.save :in => '/Users/bundu/euruko.rtf'
require 'things'
require 'open-uri'
require 'hpricot'
Things::App.activate
url = 'http://YOURNAME.tadalist.com/lists/ID.rss?token=TOKEN'
xml = open(url).read
Hpricot(xml).search("item/title").collect do |item|
title = item.inner_html.sub(/([^:]+): /, '')
case $1
when 'Added'
Things::Todo.create(:name => title) unless Things::Todo.find(title)
when 'Completed'
if found = Things::Todo.find(title) then found.complete! end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment