Module: TwitterVine

Defined in:
lib/twitter-vine.rb,
lib/twitter-vine/client.rb,
lib/twitter-vine/version.rb

Defined Under Namespace

Modules: Client

Constant Summary collapse

DEBUG =
false
VERSION =
"0.1.8"

Class Method Summary collapse

Class Method Details

.parse(vine_url) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/twitter-vine.rb', line 8

def self.parse(vine_url)
  vine_url.gsub!("http://", "https://")
  vine_url.gsub!("/embed/simple", "")
  puts "Got vine_url [#{vine_url}]" if DEBUG
  doc = Nokogiri::HTML(open(vine_url))
  {
      vine_id: vine_url.match(/.*\/(.*)/)[1],
      vine_url: vine_url,
      vine_thumbnail: doc.xpath("//meta[@property='og:image']").first[:content],
      vine_author_thumbnail: doc.css("article.post a img").first["src"],
      vine_author: doc.css("article.post a span[itemprop=author]").text,
      vine_description: doc.xpath("//meta[@property='og:description']").first[:content],
      vine_src: doc.xpath("//meta[@property='twitter:player:stream']").first[:content],
      vine_type: doc.xpath("//meta[@property='twitter:player:stream:content_type']").first[:content].split(";").first
  }
end