Sha256: 31e423f13b5dd705849d475ee30db726298a341831122bb4d534c097f271385a

Contents?: true

Size: 1.23 KB

Versions: 8

Compression:

Stored size: 1.23 KB

Contents

require 'oga'

class VideoInfo
  module Providers
    module YoutubePlaylistScraper
      def date
        nil
      end

      def duration
        nil
      end

      def keywords
        nil
      end

      def author
        data.css('.channel-header-profile-image').attr('title')[0].value
      end

      def author_thumbnail
        data.css('.channel-header-profile-image').attr('src')[0].value
      end

      def author_url
        element = data.css('.channel-header-profile-image-container')
        'https://www.youtube.com' + element.attr('href')[0].value
      end

      def videos
        raise(NotImplementedError,
              'To access videos, you must provide an API key ' \
              'to VideoInfo.provider_api_keys')
      end

      def view_count
        nil
      end

      def thumbnail_small
        thumbnail_medium.sub('mqdefault.jpg', 'default.jpg')
      end

      def thumbnail_medium
        'https:' + data.css('div.pl-header-thumb img').attr('src')[0].value
      end

      def thumbnail_large
        thumbnail_medium.sub('mqdefault.jpg', 'hqdefault.jpg')
      end

      private

      def available?
        !data.css('div#page').attr('class')[0].value.include?('oops-content')
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
video_info-3.1.0 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-3.0.2 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-3.0.1 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-3.0.0 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-2.8.0 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-2.7.1 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-2.7 lib/video_info/providers/youtubeplaylist_scraper.rb
video_info-2.6.1 lib/video_info/providers/youtubeplaylist_scraper.rb