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
- #thumbnail_large ⇒ Object
- #thumbnail_medium ⇒ Object
- #thumbnail_small ⇒ Object
- #title ⇒ Object
- #view_count ⇒ Object
- #width ⇒ Object
Instance Method Details
#author ⇒ Object
10 11 12 13 14 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 10 def if available? json_info['author']['name'] end end |
#author_thumbnail ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 16 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
37 38 39 40 41 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 37 def if available? json_info['author']['url'] end end |
#available? ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 43 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
67 68 69 70 71 72 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 67 def date if available? upload_date = json_info['uploadDate'] ISO8601::DateTime.new(upload_date).to_time end end |
#description ⇒ Object
63 64 65 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 63 def description ('og:description') end |
#duration ⇒ Object
74 75 76 77 78 79 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 74 def duration if available? duration = json_info['duration'] ISO8601::Duration.new(duration).to_seconds.to_i end end |
#height ⇒ Object
93 94 95 96 97 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 93 def height if available? json_info['height'] end end |
#keywords ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 81 def keywords unless available? return nil end if json_info['keywords'] json_info['keywords'] else [] end end |
#thumbnail_large ⇒ Object
117 118 119 120 121 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 117 def thumbnail_large if available? thumbnail_url.split('_')[0] + '_640.jpg' end end |
#thumbnail_medium ⇒ Object
111 112 113 114 115 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 111 def thumbnail_medium if available? thumbnail_url.split('_')[0] + '_200x150.jpg' end end |
#thumbnail_small ⇒ Object
105 106 107 108 109 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 105 def thumbnail_small if available? thumbnail_url.split('_')[0] + '_100x75.jpg' end end |
#title ⇒ Object
59 60 61 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 59 def title ('og:title') end |
#view_count ⇒ Object
123 124 125 126 127 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 123 def view_count if available? user_interaction_count(interaction_type: "http://schema.org/WatchAction") end end |
#width ⇒ Object
99 100 101 102 103 |
# File 'lib/video_info/providers/vimeo_scraper.rb', line 99 def width if available? json_info['width'] end end |