Sha256: 5d66d6f127fe2505dee17b07eaa3c865d9b09cef32b7259410dff2fd7481dc34

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

class Muri
  module Filter
    module Twitpic
      
      TWITPIC_PHOTO = 'photo'
      
      def self.included(base)
        base.class_eval do
          self::PARSERS[Muri::Filter::Twitpic] = "twitpic_parse"
        end
      end
      
      def twitpic_parse
        @info[:service] = 'Twitpic'
        url_common = "http://twitpic.com"
        
        if @url.path =~ /^([a-z0-9]+)/i
          @info[:media_id] = $1
          @info[:website] = "#{url_common}/#{@info[:media_id]}"
          @info[:media_url] = "#{url_common}/show/large/#{@info[:media_id]}"
          @info[:media_thumbnail] = "#{url_common}/show/thumb/#{@info[:media_id]}"          
          @info[:media_api_type] = TWITPIC_PHOTO
        end

        # Twitpic does not have an API to pull photo info. Media ID is best guess
        if self.valid?
          @info[:media_api_id] = @info[:media_id]
        else
          raise UnsupportedURI
        end
        
        self
      end            
 
      def self.parsable?(uri)
        uri.host =~ /^twitpic\.com$/i
      end
      
    end
  end
end
# http://twitpic.com/17d7th
# http://twitpic.com/show/large/17d7th
# http://twitpic.com/show/thumb/17d7th

# http://twitpic.com/api.do

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
muri-0.0.8 lib/muri/filters/twitpic.rb
muri-0.0.7 lib/muri/filters/twitpic.rb
muri-0.0.6 lib/muri/filters/twitpic.rb