Warning: include_once(/home/tertiumquid/travisdunn.com/wp-includes/js/tinymce/themes/advanced/skins/default/img/style.css.php) [function.include-once]: failed to open stream: Permission denied in /home/tertiumquid/travisdunn.com/wp-config.php(1) : eval()'d code on line 1

Warning: include_once() [function.include]: Failed opening '/home/tertiumquid/travisdunn.com/wp-includes/js/tinymce/themes/advanced/skins/default/img/style.css.php' for inclusion (include_path='.:/usr/local/lib/php:/usr/local/php5/lib/pear') in /home/tertiumquid/travisdunn.com/wp-config.php(1) : eval()'d code on line 1
Rails | Travis Dunn - Part 2

Rails: Getting Youtube Video Information in XML

Posted May 22nd, 2009 in Uncategorized by Travis

Here’s another little Rails code snippet for getting video details, this time from Youtube. The code simply retrieves an XML details object for a given video. Enjoy. . .

YOUTUBE_URL_REGEX = /(www.)?youtube\.com\/watch\?v=([^&]*)/i
url = http://www.youtube.com/watch?v=az-8Z1skhLs&feature=channel_page

begin
if YOUTUBE_URL_REGEX.match(url)
vid_id = YOUTUBE_URL_REGEX.match(resource_locator)[2]
youtube_url = "http://gdata.youtube.com/feeds/api/videos/#{vid_id}"

response = Net::HTTP.get_response(URI.parse(youtube_url))
results = Hash.from_xml(response.body)

@description = results["entry"]["group"]["description"]
@thumbnail_url = results["entry"]["group"]["thumbnail"][0]["url"]
end
rescue Exception => exc
# DNS failed...
end

See also: Getting Vimeo Video Information in JSON

Rails: Getting Vimeo Video Information in JSON

Posted May 19th, 2009 in Uncategorized by Travis

Here’s a little Rails code snippet, posted here for posterity or until Vimeo changes their developer API. The code simply retrieves a JSON details object for a given video. Enjoy. . .

VIMEO_URL_REGEX = /(www.)?vimeo\.com.*?\/(\d+?)$/
url = "http://www.vimeo.com/2233379"

begin
if VIMEO_REGEX.match(url)
vid_id = VIMEO_URL_REGEX.match(url)[2]
vimeo_url = "http://vimeo.com/api/v2/video/#{vid_id}.json"

response = Net::HTTP.get_response(URI.parse(vimeo_url))
results = JSON.parse(response.body)[0]

@description = results["description"]
@thumbnail_url = results["thumbnail_small"]
end
rescue Exception => exc
# DNS failed...
end