#!/usr/bin/env ruby
# encoding: UTF-8
require 'net/http'
require 'uri'
require 'public_suffix_list'
require 'public_suffix'
require 'fileutils'
require 'mechanize'
require 'nokogiri'
require 'watir-webdriver'
require 'selenium/webdriver'
module VideoDescription
class ViewDesc
def initialize
make_agent
end
def find_site(url)
uri = URI.parse(url)
domain = PublicSuffix.parse(uri.host)
return domain.sld
end
def get_youtube_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//*[@id="eow-description"]')
return views.to_s.strip # sortie en html, supprimer les tags?
end
def get_dailymotion_description(url) #ok
page = @agent.get url
views = page.at('meta[@property="og:description"]')[:content]
return views
end
def get_izlesene_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//p[@id="videoDesc"]/text()')
return views.to_s.strip
end
def get_trilulilu_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//html/body/div[5]/div[3]/div/div/div/div[3]/div/div/div/div/div[2]/p/span/text()')
return views.to_s.strip
end
def get_clipfish_description(url) #ok
page = @agent.get url
details = page.parser.xpath('//*[@id="description-head"]/text()')
details2 = page.parser.xpath('//*[@id="additional-description"]/text()')
views = details.to_s.strip << details2.to_s.strip
return views
end
def get_metacafe_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//html/body/div/div[6]/div[5]/div/div[3]/p/text()')
return views.to_s.strip
end
def get_myspace_description(url) #ok
page = @agent.get url
views = page.at('meta[@property="og:description"]')[:content]
return views
end
def get_photobucket_description(url) #ok
page = @agent.get url
views = page.at('meta[@property="og:description"]')[:content]
return views
end
def get_daleplay_description(url) #ko no available vid
page = @agent.get url
views = page.parser.xpath('//*[@id="video_views_countv2"]/b/text()')
return views.to_s.strip
end
def get_vxv_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//*[@id="description-full"]/text()')
return views.to_s.strip
end
def get_rutube_description(url) #ok
page = @agent.get url
views = page.at('meta[@property="og:description"]')[:content]
return views
end
def get_smotri_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//html/body/div[6]/div/div/div[2]/div[5]/div/div/div[2]/div/div/div[5]/span/text()')
return views.to_s.strip
end
def get_miwim_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//div[@id="small-rightbox-content"]/text()')
return views[6].to_s.strip
end
def get_wat_description(url) #ok
page = @agent.get url
views = page.at('meta[@itemprop="description"]')[:content]
return views
end
def get_viddler_description(url) #ok
page = @agent.get url
views = page.at('meta[@property="og:description"]')[:content]
return views.to_s.strip
end
def get_veoh_description(url) #ok
page = @agent.get url
views = page.at('meta[@name="og:description"]')[:content]
return views.to_s.strip
end
def get_myvideo_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//span[@itemprop="description"]/text()')
#views = page.parser.xpath('//html/body/div[6]/div[3]/div[6]/div[2]/div/div[5]/div[4]/div[3]/div[5]/div[3]/div/div[5]/text()')
return views.to_s.strip
end
def get_kewego_description(url) #ok
page = @agent.get url
views = page.parser.xpath('//html/body/div/div[4]/div[2]/div/div/div[2]/div[3]/div/p/text()')
return views.to_s.strip
end
private
def make_agent
@agent = Mechanize.new do |a|
a.user_agent_alias = 'Mac Safari'
a.max_history = 1
a.open_timeout = 15
a.read_timeout = 5
a.keep_alive = false
end
end
end
end