Module: VideoInfo::Providers::VimeoScraper
- Defined in:
- lib/video_info/providers/vimeo_scraper.rb
Instance Method Summary collapse
- #author ⇒ Object
- #author_thumbnail ⇒ Object
- #author_url ⇒ Object
- #available? ⇒ Boolean
- #date ⇒ Object
- #description ⇒ Object
- #duration ⇒ Object
- #height ⇒ Object
- #keywords ⇒ Object
- #stats ⇒ Object
- #thumbnail_large ⇒ Object
- #thumbnail_medium ⇒ Object
- #thumbnail_small ⇒ Object
- #title ⇒ Object
- #view_count ⇒ Object
- #width ⇒ Object
Instance Method Details
#author ⇒ Object
7 8 9 10 11 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 7 def if available? json_info["author"]["name"] end end |
#author_thumbnail ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 13 def unless available? return nil end split_point = "window.vimeo.clip_page_config =" = data.css("script") script_index = .find_index do |x| x.text.include?(split_point) end script_text = [script_index].text split_script_text = script_text.split(split_point)[1] parsed_data = JSON.parse(split_script_text.split(";\n")[0]) parsed_data["owner"]["portrait"]["src"] end |
#author_url ⇒ Object
34 35 36 37 38 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 34 def if available? json_info["author"]["url"] end end |
#available? ⇒ Boolean
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 40 def available? is_available = super if data.nil? is_available = false elsif is_available password_elements = data.css(".exception_title--password") unless password_elements.empty? is_available = false end end is_available end |
#date ⇒ Object
64 65 66 67 68 69 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 64 def date if available? upload_date = json_info["uploadDate"] ISO8601::DateTime.new(upload_date).to_time end end |
#description ⇒ Object
60 61 62 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 60 def description ("og:description") end |
#duration ⇒ Object
71 72 73 74 75 76 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 71 def duration if available? duration = json_info["duration"] ISO8601::Duration.new(duration).to_seconds.to_i end end |
#height ⇒ Object
86 87 88 89 90 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 86 def height if available? json_info["height"] end end |
#keywords ⇒ Object
78 79 80 81 82 83 84 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 78 def keywords unless available? return nil end json_info["keywords"] || [] end |
#stats ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 122 def stats return {} unless available? { "plays" => view_count, "likes" => user_interaction_count(interaction_type: "LikeAction"), "comments" => user_interaction_count(interaction_type: "CommentAction") } end |
#thumbnail_large ⇒ Object
110 111 112 113 114 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 110 def thumbnail_large if available? thumbnail_url.split("_")[0] + "_640.jpg" end end |
#thumbnail_medium ⇒ Object
104 105 106 107 108 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 104 def thumbnail_medium if available? thumbnail_url.split("_")[0] + "_200x150.jpg" end end |
#thumbnail_small ⇒ Object
98 99 100 101 102 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 98 def thumbnail_small if available? thumbnail_url.split("_")[0] + "_100x75.jpg" end end |
#title ⇒ Object
56 57 58 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 56 def title ("og:title") end |
#view_count ⇒ Object
116 117 118 119 120 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 116 def view_count if available? user_interaction_count(interaction_type: "WatchAction") end end |
#width ⇒ Object
92 93 94 95 96 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 92 def width if available? json_info["width"] end end |