Created
June 12, 2010 17:19
Revisions
-
marano revised this gist
Jun 12, 2010 . 3 changed files with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes.File renamed without changes.File renamed without changes. -
marano revised this gist
Jun 12, 2010 . 3 changed files with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,6 +6,8 @@ class FlickrEntry include SAXMachine include FeedEntryUtilities element :guid, :as => :id element :link, :as => :url element :title element :"media:title", :as => :title File renamed without changes.File renamed without changes. -
bananastalktome created this gist
Feb 25, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,59 @@ module Feedzirra module Parser class FlickrEntry include SAXMachine include FeedEntryUtilities element :guid, :as => :id element :title element :"media:title", :as => :title element :link, :as => :url element :pubDate, :as => :published element :pubdate, :as => :published element :"media:description", :as => :summary element :"media:credit", :as => :author, :with => { :role => "photographer" } element :"media:thumbnail", :as => :thumbnail, :value => :url element :"media:content", :as => :content, :value => :url element :"media:category", :as => :categories, :with => { :scheme => "urn:flickr:tags" } def tags @categories.blank? ? [] : @categories.split(" ") end end end end module Feedzirra module Parser class Flickr include SAXMachine include FeedUtilities element :title element :pubDate, :as => :published element :pubdate, :as => :published element :lastBuildDate, :as => :updated elements :item, :as => :entries, :class => FlickrEntry attr_accessor :feed_url def self.able_to_parse?(xml) #:nodoc: xml =~ /xmlns:flickr=\"urn:flickr:\"/im end end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,69 @@ module Feedzirra module Parser class VimeoEntry include SAXMachine include FeedEntryUtilities element :guid, :as => :id element :title element :"media:title", :as => :title element :link, :as => :url element :"dc:creator", :as => :author element :"media:credit", :as => :author, :with => { :role => "author" } element :description, :as => :summary element :pubDate, :as => :published element :pubdate, :as => :published element :"media:player", :as => :content, :value => :url element :enclosure, :as => :content, :value => :url, :with => { :type => "application/x-shockwave-flash" } element :"media:category", :as => :keyword_list element :"media:thumbnail", :as => :thumbnail, :value => :url def embed_code "<object width=\"400\" height=\"225\"><param name=\"allowfullscreen\" value=\"true\" /><param name=\"allowscriptaccess\" value=\"always\" /><param name=\"movie\" value=\"#{@content}&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1\" /><embed src=\"#{@content}&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&color=&fullscreen=1\" type=\"application/x-shockwave-flash\" allowfullscreen=\"true\" allowscriptaccess=\"always\" width=\"400\" height=\"225\"></embed></object>" end def media_id if @url =~ /http:\/\/vimeo.com\/(\d*)/i $1 elsif @content =~ /http:\/\/vimeo.com\/moogaloop.swf?clip_id=(\d*)/i $1 else '' end end def tags @keyword_list.blank? ? [] : @keyword_list.split(",") end end end end module Feedzirra module Parser class Vimeo include SAXMachine include FeedUtilities element :title element :link, :as => :url element :"atom:link", :as => :feed_url, :value => :href, :with => { :rel => "self" } elements :item, :as => :entries, :class => VimeoEntry def self.able_to_parse?(xml) #:nodoc: xml =~ /xmlns:atom=\"http:\/\/www.w3.org\/2005\/Atom\" xmlns:dc=\"http:\/\/purl.org\/dc\/elements\/1.1\/\" xmlns:media=\"http:\/\/search.yahoo.com\/mrss\/\"/im end end end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,78 @@ module Feedzirra module Parser class YoutubeEntry include SAXMachine include FeedEntryUtilities element :id element :title element :content, :as => :summary element :name, :as => :author element :link, :as => :url, :value => :href, :with => { :rel => "alternate" } element :published element :updated element :"media:player", :as => :url, :value => :url element :"media:content", :as => :content, :value => :url, :with => { :type => "application/x-shockwave-flash" } element :"media:keywords", :as => :keyword_list element :"yt:duration", :as => :duration, :value => :seconds elements :category, :as => :keywords, :value => :term, :with => { :scheme => "http://gdata.youtube.com/schemas/2007/keywords.cat" } elements :category, :as => :categories, :value => :term, :with => { :scheme => "http://gdata.youtube.com/schemas/2007/categories.cat" } elements :"media:thumbnail", :as => :thumbnails, :value => :url def embed_code "<object width=\"560\" height=\"340\"><param name=\"movie\" value=\"#{@content}\"></param><param name=\"allowFullScreen\" value=\"true\"></param><param name=\"allowscriptaccess\" value=\"always\"></param><embed src=\"#{@content}\" type=\"application/x-shockwave-flash\" allowscriptaccess=\"always\" allowfullscreen=\"true\" width=\"560\" height=\"340\"></embed></object>" end def thumbnail @thumbnails.reject { |t| t !~ /0.jpg/ }.to_s end def media_id if @id =~ /http:\/\/gdata.youtube.com\/feeds\/api\/videos\/(\S[^\/?]*)/i $1 elsif @url =~ /http:\/\/www.youtube.com\/watch\?v\=(\S[^(&\;)]*)/i $1 else '' end end def tags @keywords || @keyword_list.blank? ? [] : @keyword_list.split(",") end end end end module Feedzirra module Parser class Youtube include SAXMachine include FeedUtilities element :id element :updated element :title element :name, :as => :author element :link, :as => :feed_url, :value => :href, :with => { :rel => "http://schemas.google.com/g/2005#feed" } element :link, :as => :url, :value => :href, :with => { :rel => "alternate" } elements :entry, :as => :entries, :class => YoutubeEntry def self.able_to_parse?(xml) #:nodoc: xml =~ /xmlns:yt=\'http:\/\/gdata.youtube.com\/schemas\/2007\'/im end end end end