Sha256: 2584f1c615aa1f9cf54c2d8d5964ceb37d4f7c636308e1fc4d5bcdd2cdb3c00f

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

module Appydave
  module Tools
    module YouTubeManager
      # Manage YouTube video details
      class GetVideo < YouTubeBase
        attr_reader :video_id
        attr_reader :data
        attr_reader :video

        def get(video_id)
          @video_id = video_id
          response = @service.list_videos('snippet,contentDetails,status,statistics', id: video_id)
          @video = response.items.first

          data = {
            id: video.id,
            title: video.snippet.title,
            description: video.snippet.description,
            published_at: video.snippet.published_at,
            channel_id: video.snippet.channel_id,
            channel_title: video.snippet.channel_title,
            view_count: video.statistics.view_count,
            like_count: video.statistics.like_count,
            dislike_count: video.statistics.dislike_count,
            comment_count: video.statistics.comment_count,
            privacy_status: video.status.privacy_status,
            embeddable: video.status.embeddable,
            license: video.status.license,
            recording_location: video.recording_details&.location,
            recording_date: video.recording_details&.recording_date,
            tags: video.snippet.tags,
            thumbnails: video.snippet.thumbnails.to_h,
            duration: video.content_details.duration,
            definition: video.content_details.definition,
            caption: video.content_details.caption,
            licensed_content: video.content_details.licensed_content
          }

          @data = Appydave::Tools::IndifferentAccessHash.new(data)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
appydave-tools-0.9.3 lib/appydave/tools/youtube_manager/get_video.rb
appydave-tools-0.9.2 lib/appydave/tools/youtube_manager/get_video.rb
appydave-tools-0.9.1 lib/appydave/tools/youtube_manager/get_video.rb
appydave-tools-0.9.0 lib/appydave/tools/youtube_manager/get_video.rb