### Upload Video from Specific URL Example Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md An example of uploading a video from a specific remote URL to YouTube, demonstrating the usage with `youtube_it` and `yt` Ruby gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_upload("http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test]) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.upload_video 'http://media.railscasts.com/assets/episodes/videos/412-fast-rails-commands.mp4', title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test) ``` -------------------------------- ### Install Yt Gem via Command Line Source: https://github.com/nullscreen/yt/blob/master/README.md Provides the command-line instruction to install the Yt Ruby gem globally on the system, making it available for Ruby applications. ```Shell gem install yt ``` -------------------------------- ### Initializing client with OAuth 2.0 Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Compares OAuth 2.0 client setup for `youtube_it` and `Yt`. `Yt` uses a global configuration for client credentials and instantiates an `Account` with access and refresh tokens. ```ruby # with youtube_it client = YouTubeIt::OAuth2Client.new(client_access_token: "access_token", client_refresh_token: "refresh_token", client_id: "client_id", client_secret: "client_secret", dev_key: "dev_key", expires_at: "expiration time") client.refresh_access_token! ``` ```ruby # with yt Yt.configure do |config| config.client_id = 'client_id' config.client_secret = 'client_secret' end account = Yt::Account.new access_token: 'access_token', refresh_token: 'refresh_token' ``` -------------------------------- ### Initializing client with username, password, and developer key Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates `youtube_it` client setup using a username, password, and developer key. `Yt` does not support this authentication method, requiring OAuth 2.0 instead. ```ruby # with youtube_it client = YouTubeIt::Client.new(:username => "youtube_username", :password => "youtube_passwd", :dev_key => "developer_key") ``` -------------------------------- ### Create a New YouTube Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Creates a new playlist with a specified title and description for the authenticated user. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub playlist = client.add_playlist(:title => "new playlist", :description => "playlist description") ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.create_playlist title: 'new playlist', description: 'playlist description' ``` -------------------------------- ### Initializing client with AuthSub token Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Illustrates `youtube_it` client setup using an AuthSub token. `Yt` does not support AuthSub, as it has been deprecated by YouTube Data API V3. ```ruby # with youtube_it client = YouTubeIt::AuthSubClient.new(:token => "token" , :dev_key => "developer_key") ``` -------------------------------- ### List User Subscriptions (Channels) Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves a list of channels the authenticated user is subscribed to. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.subscriptions(user) # default: current user ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.subscribed_channels ``` -------------------------------- ### Subscribe to a YouTube Channel Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Subscribes the authenticated user to a specified YouTube channel. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.subscribe_channel(channel_name) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' channel = Yt::Channel.new id: channel_id, auth: account channel.subscribe ``` -------------------------------- ### Retrieve All Videos from a Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Fetches all video entries within a specified playlist. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it playlist = client.playlist(playlist_id) playlist.videos ``` ```Ruby # with yt playlist = Yt::Playlist.new id: playlist_id playlist.playlist_items.map &:video ``` -------------------------------- ### Like a YouTube Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Marks a video as liked by the authenticated user. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.like_video(video_id) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: video_id, auth: account video.like ``` -------------------------------- ### Select a Specific Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Selects a specific playlist by its ID. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client.playlist(playlist_id) ``` ```Ruby # with yt Yt::Playlist.new id: playlist_id ``` -------------------------------- ### Add Video to a Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Adds a video to an existing playlist at a specified position. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.add_video_to_playlist(playlist_id, video_id, position) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' playlist = Yt::Playlist.new id: playlist_id, auth: account playlist.add_video video_id, position: position ``` -------------------------------- ### Initialize Yt Account with Authorization Code Source: https://github.com/nullscreen/yt/blob/master/README.md Demonstrates how to authenticate and initialize a Yt account using an authorization code and redirect URI. Shows examples of accessing account email and video lists after initialization. ```ruby account = Yt::Account.new authorization_code: '4/Ja60jJ7_Kw0', redirect_uri: redirect_uri account.email #=> (retrieves the account’s e-mail address) account.videos #=> (lists a video to an account’s playlist) ``` -------------------------------- ### Retrieve Specific YouTube Video by ID Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to retrieve details for a specific YouTube video using its ID, with examples for `youtube_it` and `yt` Ruby gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.my_video(video_id) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' Yt::Video.new id: video_id, auth: account ``` -------------------------------- ### Update Video Position in Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Updates the position of a video within a specified playlist. Only an example for `youtube_it` is provided. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.update_position_video_from_playlist(playlist_id, playlist_entry_id, position) ``` -------------------------------- ### Unsubscribe from a YouTube Channel Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Unsubscribes the authenticated user from a specified YouTube channel. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.unsubscribe_channel(subscription_id) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' channel = Yt::Channel.new id: channel_id, auth: account channel.unsubscribe ``` -------------------------------- ### Dislike a YouTube Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Marks a video as disliked by the authenticated user. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.dislike_video(video_id) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: video_id, auth: account video.dislike ``` -------------------------------- ### Delete YouTube Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Provides examples for deleting a video from YouTube using its ID, demonstrated with both `youtube_it` and `yt` Ruby gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_delete("FQK1URcxmb4") ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: 'FQK1URcxmb4' video.delete ``` -------------------------------- ### Retrieve All Videos from Watch Later Playlist in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Fetches all video entries from the user's 'Watch Later' playlist. Examples are provided for both the `youtube_it` and `Yt` Ruby gems, demonstrating how to access this special playlist. ```Ruby # with youtube_it watcher_later = client.watcherlater(user) #default: current user watcher_later.videos # with yt account = Yt::Account.new access_token: 'access_token' watch_later = account.related_playlists.find{|p| p.title == 'Watch Later'} watch_later.playlist_items.map{|item| item.video} ``` -------------------------------- ### Find Favorites Playlist (Deprecated) Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to find the 'Favorites' playlist, which has been deprecated by YouTube in favor of 'Liked Videos'. This example uses the `yt` gem. ```Ruby account = Yt::Account.new access_token: 'access_token' account.related_playlists.find{|p| p.title == 'Favorites'} ``` -------------------------------- ### Remove Video from a Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Removes a specific video entry from a playlist. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.delete_video_from_playlist(playlist_id, playlist_entry_id) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' playlist_item = Yt::PlaylistItem.new id: playlist_entry_id, auth: account playlist_item.delete ``` -------------------------------- ### Manage Yt Claim Attributes, History, and Creation Source: https://github.com/nullscreen/yt/blob/master/README.md This comprehensive example demonstrates various operations on `Yt::Claim` objects, including reading attributes like `video_id` and `asset_id`, viewing claim history, deleting existing claims, and inserting new claims with detailed match information. Authentication as the video's content owner is necessary. ```Ruby content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.1.ABCDEFGHIJ' claim = Yt::Claim.new id: 'ABCD12345678', auth: content_owner claim.video_id #=> 'va141cJga2' claim.asset_id #=> 'A1234' claim.content_type #=> 'audiovisual' claim.active? #=> true claim.claim_history #=> # claim.claim_history.events[0].type #=> "claim_create" claim.delete #=> true data = { is_manual_claim: true, content_type: 'audiovisual', asset_id: 'A123123123123123', policy: { id: 'S123123123123123' }, video_id: 'myvIdeoIdYT', match_info: { match_segments: [ { manual_segment: { start: '00:00:20.000', finish: '00:01:20.000' } }, { manual_segment: { start: '00:02:30.000', finish: '00:03:50.000' } } ] } } content_owner.claims.insert(data) ``` -------------------------------- ### Manage Yt Asset Ownership and Update Metadata Source: https://github.com/nullscreen/yt/blob/master/README.md This example illustrates how to read and manipulate the ownership details of a `Yt::Asset`, including obtaining and releasing ownership. It also shows how to update general metadata for an asset, such as adding notes. An authenticated `Yt::ContentOwner` is required. ```Ruby content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.1.ABCDEFGHIJ' asset = Yt::Asset.new id: 'ABCD12345678', auth: content_owner asset.ownership #=> # asset.ownership.obtain! #=> true asset.general_owners.first.owner #=> 'CMSname' asset.general_owners.first.everywhere? #=> true asset.ownership.release! #=> true asset.update metadata_mine: {notes: 'Some notes'} #=> true ``` -------------------------------- ### Delete a YouTube Playlist Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Deletes a specified playlist from the authenticated user's account. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.delete_playlist(playlist_id) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' playlist = Yt::Playlist.new id: playlist_id, auth: account playlist.delete ``` -------------------------------- ### Retrieve Yt Asset Effective Ownership Details Source: https://github.com/nullscreen/yt/blob/master/README.md This example focuses on retrieving the `ownership_effective` details for a `Yt::Asset`. This is useful for understanding the actual ownership status, especially when there are conflicts. It requires an authenticated content owner and the asset ID. ```Ruby asset = content_owner.assets.where(id: 'A125058570526569', fetch_ownership: 'effective').first asset.ownership_effective.general_owners.first.owner # => "XOuN81q-MeEUVrsiZeK1lQ" ``` -------------------------------- ### Add Video to Favorites / Like Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Adds a video to a user's favorites. With YouTube API V3, this action is equivalent to 'liking' a video. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.add_favorite(video_id) ``` ```Ruby # with yt: "like" a video to mark as favorite with YouTube API V3 account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: video_id, auth: account video.like ``` -------------------------------- ### Configure Yt with Public API Key for Read-Only Access Source: https://github.com/nullscreen/yt/blob/master/README.md This snippet demonstrates how to configure the Yt library with a public API key. This setup is suitable for applications that only need to fetch public data from YouTube and do not require user interactions or destructive operations. The API key should be obtained from the Google Developers Console. ```Ruby Yt.configure do |config| config.api_key = 'AIzaSyAO8dXpvZcaP2XSDFBD91H8yQ' end ``` -------------------------------- ### Remove Video from Watch Later Playlist in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Deletes a video from the user's 'Watch Later' playlist. Examples show how to achieve this using both the `youtube_it` and `Yt` Ruby gems. ```Ruby # with youtube_it client.delete_video_from_watchlater(watchlater_entry_id) # with yt account = Yt::Account.new access_token: 'access_token' watch_later = account.related_playlists.find{|p| p.title == 'Watch Later'} watch_later.delete_playlist_items video_id: video_id ``` -------------------------------- ### Update Yt Video Advertising Settings Source: https://github.com/nullscreen/yt/blob/master/README.md This example demonstrates how to modify the advertising settings for a specific video using `Yt::AdvertisingOptionsSet`. It shows updating the `ad_formats` to include 'standard_instream' and 'long'. Authentication as the video's content owner is necessary for this operation. ```Ruby content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.1.ABCDEFGHIJ' ad_options = Yt::AdvertisingOptionsSet.new video_id: 'jNQXAC9IVRw', auth: $content_owner ad_options.update ad_formats: %w(standard_instream long) #=> true ``` -------------------------------- ### Delete Video from Favorites / Unlike Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Removes a video from a user's favorites. With YouTube API V3, this action is equivalent to 'unliking' a video. Examples are provided for both `youtube_it` and `yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.delete_favorite(favorite_entry_id) ``` ```Ruby # with yt: "unlike" a video to remove from favorites with YouTube API V3 account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: video_id, auth: account video.unlike ``` -------------------------------- ### Establishing a basic YouTube API client Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Compares the basic client instantiation in `youtube_it` and `Yt`. `Yt` allows specifying whether to authenticate as a YouTube `Account` or as a `ContentOwner`. ```ruby # with youtube_it client = YouTubeIt::Client.new ``` ```ruby # with yt account = Yt::Account.new # or Yt::ContentOwner.new ``` -------------------------------- ### Listing videos by keyword Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Compares how to query videos by a specific keyword using `youtube_it` and `Yt`. ```ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:query => "penguin") ``` ```ruby # with yt videos = Yt::Collections::Videos.new videos.where(q: 'penguin') ``` -------------------------------- ### Initializing client with developer key Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how `youtube_it` initializes a client with a developer key. `Yt` does not support this method, as YouTube Data API V3 requires OAuth 2.0. ```ruby # with youtube_it client = YouTubeIt::Client.new(:dev_key => "developer_key") ``` -------------------------------- ### Listing videos with pagination Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Illustrates pagination differences. `youtube_it` requires explicit page and per_page parameters, while `Yt` collections automatically handle iteration through all pages. ```ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:query => "penguin", :page => 2, :per_page => 15) ``` ```ruby # with yt: pagination is automatically supported by collection, which iterates # though all the pages, not just the first one videos = Yt::Collections::Videos.new videos.where(q: 'penguin') ``` -------------------------------- ### Initializing client with OAuth 1.0 Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows `youtube_it` client initialization with OAuth 1.0. `Yt` does not support OAuth 1.0, requiring OAuth 2.0. ```ruby # with youtube_it client = YouTubeIt::OAuthClient.new("consumer_key", "consumer_secret", "youtube_username", "developer_key") client.authorize_from_access("access_token", "access_secret") ``` -------------------------------- ### Configure Yt with Environment Variables Source: https://github.com/nullscreen/yt/blob/master/README.md Sets up Yt client ID, client secret, and API key using environment variables. This provides an alternative configuration method to the Ruby initializer block. ```bash export YT_CLIENT_ID="1234567890.apps.googleusercontent.com" export YT_CLIENT_SECRET="1234567890" export YT_API_KEY="123456789012345678901234567890" ``` -------------------------------- ### Accessing user profiles or channels Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Explains how `youtube_it` handles multiple profiles within an account, while `Yt` focuses on accessing individual channels managed by an account. ```ruby profiles = client.profiles(['username1','username2']) profiles['username1'].username, "username1" ``` ```ruby first_channel = Yt::Channel.new id: 'UCx12345', auth: account second_channel = Yt::Channel.new id: 'UCy45678', auth: account first_channel.title ``` -------------------------------- ### Retrieve User Profile Details Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Illustrates how to fetch profile information for a YouTube user using `youtube_it` and `yt` Ruby gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.profile(user) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.user_info ``` -------------------------------- ### Retrieve Video by URL Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to retrieve a video using its full YouTube URL. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU") ``` ```Ruby # with yt Yt::Video.new url: 'https://www.youtube.com/watch?v=QsbmrCtiEUU' ``` -------------------------------- ### Retrieve Current User's YouTube Videos Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to fetch a list of videos uploaded by the authenticated user using `youtube_it` and `yt` Ruby gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.my_videos ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.videos ``` -------------------------------- ### Upload Local Video File to YouTube Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to upload a video file from the local filesystem to YouTube using both `youtube_it` and `yt` Ruby gems. Requires an authenticated client or account. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test]) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.upload_video 'test.mov', title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test) ``` -------------------------------- ### Listing videos by tags Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how `youtube_it` filters videos by tags. The text does not provide an equivalent `Yt` method, implying it might not be directly supported or is handled differently. ```ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:tags => ['tiger', 'leopard']) client.videos_by(:categories => [:news, :sports], :tags => ['soccer', 'football']) ``` -------------------------------- ### Initialize Yt::ContentOwner and Access YouTube Data Source: https://github.com/nullscreen/yt/blob/master/README.md Demonstrates how to initialize a `Yt::ContentOwner` instance using an access token and then access various associated YouTube data, including partnered channels, claims, references, policies, and assets. This requires authentication. ```ruby content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.1.ABCDEFGHIJ' content_owner.partnered_channels.count #=> 12 content_owner.partnered_channels.map &:title #=> ["Fullscreen", "Best of Fullscreen", ...] content_owner.partnered_channels.where(part: 'statistics').map &:subscriber_count #=> [136925, 56945, ...] content_owner.claims.where(q: 'Fullscreen').count #=> 24 content_owner.claims.first #=> # content_owner.claims.first.video_id #=> 'jNQXAC9IVRw' content_owner.claims.first.status #=> "active" reference = content_owner.references.where(asset_id: "ABCDEFG").first #=> # reference.delete #=> true content_owner.policies.first #=> # content_owner.policies.first.name #=> "Track in all countries" content_owner.policies.first.rules.first #=> # content_owner.policies.first.rules.first.action #=> "monetize" content_owner.policies.first.rules.first.included_territories #=> ["US", "CA"] content_owner.create_asset type: 'web' #=> # content_owner.assets.first #=> # content_owner.assets.first.id #=> ``` -------------------------------- ### Retrieve Video by ID Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Illustrates how to fetch a specific video using its unique ID. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.video_by("FQK1URcxmb4") ``` ```Ruby # with yt Yt::Video.new id: 'FQK1URcxmb4' ``` -------------------------------- ### Custom Query Parameters for Video Search Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to apply various custom query parameters like search term, safe search, duration, HD quality, and region to video searches. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:query => "penguin", :safe_search => "strict") client.videos_by(:query => "penguin", :duration => "long") client.videos_by(:query => "penguin", :hd => "true") client.videos_by(:query => "penguin", :region => "AR") ``` ```Ruby # with yt videos = Yt::Collections::Videos.new videos.where(q: 'penguin', safe_search: 'strict') videos.where(q: 'penguin', duration: 'long') videos.where(q: 'penguin', video_definition: 'high') videos.where(q: 'penguin', region_code: 'AR') ``` -------------------------------- ### List User's Favorite YouTube Videos Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to retrieve a list of favorite videos for a user using `youtube_it`. Notes that `yt` only supports this for older channels due to YouTube API changes. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.favorites(user) # default: current user ``` -------------------------------- ### Initialize Yt Account with Existing Access Token Source: https://github.com/nullscreen/yt/blob/master/README.md If your application already possesses an account's access token, this code shows how to initialize a Yt::Account object directly. This allows immediate access to account-specific operations like retrieving email or listing videos without needing to re-authenticate. ```Ruby account = Yt::Account.new access_token: 'ya29.1.ABCDEFGHIJ' account.email #=> (retrieves the account’s e-mail address) account.videos #=> (lists a video to an account’s playlist) ``` -------------------------------- ### Retrieve Video of a User by ID Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates fetching a specific video by its ID, associated with a particular user. Note that `yt` simplifies this by directly using the video ID. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.video_by_user("chebyte","FQK1URcxmb4") ``` ```Ruby # with yt Yt::Video.new id: 'FQK1URcxmb4' ``` -------------------------------- ### Upload Remote Video to YouTube by URL Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to upload a video to YouTube by providing its remote URL, using both `youtube_it` and `yt` Ruby gems. This avoids local file handling. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_upload("http://url/myvideo.mp4", :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test]) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.upload_video 'http://url/myvideo.mp4', title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test) ``` -------------------------------- ### Update YouTube Video Metadata Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to update existing video metadata like title and description using `youtube_it` and `yt` Ruby gems. Notes that `yt` allows partial updates. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_update("FQK1URcxmb4", :title => "new test",:description => 'new description', :category => 'People',:keywords => %w[cool blah test]) ``` ```Ruby # with yt: only provides the values that need to be updated; the remaining ones # will automatically be kept as they are account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: 'FQK1URcxmb4', auth: account video.update title: 'new test', description: 'new description' ``` -------------------------------- ### Filter Including Private Videos Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to access and filter a user's private videos. This requires an authenticated client (OAuth or AuthSub). ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.my_video("FQK1URcxmb4") client.my_videos(:query => "penguin") ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: 'FQK1URcxmb4', auth: account account.videos.where(q: 'penguin') ``` -------------------------------- ### List User Playlists Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves a list of playlists for the authenticated user. The `youtube_it` gem allows ordering, while `yt` does not, reflecting YouTube API V3 changes. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.playlists(user) # default order, by position client.playlists(user, "title") # order by title ``` ```Ruby # with yt: available without order; ordering was removed from YouTube API V3 account = Yt::Account.new access_token: 'access_token' account.playlists ``` -------------------------------- ### Batch Retrieve Multiple Videos in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Fetches details for multiple videos by their IDs in a single request. This snippet shows how to perform batch retrieval efficiently using both `youtube_it` and `Yt` gems. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.videos(['video_id_1', 'video_id_2',...]) # with yt Yt::Collections::Videos.new.where(id: 'video_id_1,video_id_2') ``` -------------------------------- ### List YouTube Video Comments Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to retrieve comments for a given YouTube video using `youtube_it`. Notes that `yt` does not support this feature due to YouTube API V3 changes. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.comments(video_id) ``` -------------------------------- ### Configure Yt with Ruby Block Source: https://github.com/nullscreen/yt/blob/master/README.md Configures Yt client ID, client secret, and API key using a Ruby `Yt.configure` block. This method takes precedence over environment variables if both are set. ```ruby Yt.configure do |config| config.client_id = '1234567890.apps.googleusercontent.com' config.client_secret = '1234567890' config.api_key = '123456789012345678901234567890' end ``` -------------------------------- ### Add Response Video in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Adds a video as a response to another video using `youtube_it`. Note that this feature is no longer supported by the YouTube Data API V3, and thus not available in the `Yt` gem. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub video.add_response(original_video_id, response_video_id) # with yt: not supported (was removed from YouTube API V3) ``` -------------------------------- ### Release New Yt Gem Version Source: https://github.com/nullscreen/yt/blob/master/README.md Command to perform a new release of the Yt gem. This should be done after ensuring all tests pass, documenting changes in CHANGELOG.md and README.md, and bumping the version according to Semantic Versioning. ```bash rake release ``` -------------------------------- ### Run RSpec Tests Source: https://github.com/nullscreen/yt/blob/master/README.md Command to execute the RSpec test suite for the Yt project. It is recommended to use RSpec version 3.8 or higher. ```bash rspec ``` -------------------------------- ### Upload Video with Developer Tag Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Illustrates adding a developer tag during video upload using `youtube_it`. Notes that this feature is not supported by `yt` due to YouTube API V3 changes. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :dev_tag => 'tagdev') ``` -------------------------------- ### List Response Videos in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves a list of videos that are responses to a given video using `youtube_it`. This feature is no longer supported by the YouTube Data API V3, and consequently, is not available in the `Yt` gem. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub video = client.video_by("https://www.youtube.com/watch?v=QsbmrCtiEUU&feature=player_embedded") video.responses.videos # with yt: not supported (was removed from YouTube API V3) ``` -------------------------------- ### List Videos by User Channel Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to retrieve a list of videos uploaded by a specific user. The `youtube_it` gem uses a direct user filter, while `yt` requires fetching the channel first due to changes in YouTube API v3 where the 'author' filter was removed. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:user => 'liz') ``` ```Ruby # with yt: the 'author' filter was removed from YouTube API V3, so the # request must be done using the channel of the requested author channel = Yt::Channel.new url: 'youtube.com/liz' channel.videos.where(q: 'penguin') ``` -------------------------------- ### Listing videos by author Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Explains that the 'author' filter was removed in YouTube API V3. `Yt` requires querying videos through the author's channel instead. ```ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:query => "penguin", :author => "liz") ``` ```ruby # with yt: the 'author' filter was removed from YouTube API V3, so the # request must be done using the channel of the requested author channel = Yt::Channel.new url: 'youtube.com/liz' channel.videos.where(q: 'penguin') ``` -------------------------------- ### List New Videos from Subscriptions Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves new videos from channels the user is subscribed to. Note that this functionality is not supported by the `yt` gem as it was removed from YouTube API V3. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.new_subscription_videos(user) # default: current user ``` ```Ruby # with yt: not supported (was removed from YouTube API V3) ``` -------------------------------- ### Upload Private Video to YouTube Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to upload a video with a private privacy status using `youtube_it` and `yt` Ruby gems. This ensures the video is not publicly accessible. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :private => true) ``` ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' account.upload_video 'test.mov', privacy_status: :private, title: 'test', description: 'some description', category_id: '22', tags: %w(cool blah test) ``` -------------------------------- ### List Videos Favorited by User Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to retrieve videos marked as favorites by a user. Note that YouTube has deprecated 'Favorites' in favor of 'Liked Videos', so only older channels might have a 'Favorites' playlist. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:favorites, :user => 'liz') ``` ```Ruby # with yt: note that only *old* channels have a "Favorites" playlist, since # "Favorites" has been deprecated by YouTube in favor of "Liked Videos". channel = Yt::Channel.new url: 'youtube.com/liz' channel.related_playlists.find{|p| p.title == 'Favorites'} ``` -------------------------------- ### Add Yt Gem to Gemfile for Bundled Projects Source: https://github.com/nullscreen/yt/blob/master/README.md Shows how to include the Yt gem in a Ruby project's Gemfile, specifying a version constraint to ensure compatibility and adherence to semantic versioning during bundle updates. ```Ruby gem 'yt', '~> 0.34.0' ``` -------------------------------- ### Advanced Queries with Boolean Operators Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates complex video searches using boolean logic (OR, AND, NOT) on categories and tags. This advanced query functionality is not supported by YouTube API v3. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:categories => { :either => [:news, :sports], :exclude => [:comedy] }, :tags => { :include => ['football'], :exclude => ['soccer'] }) ``` ```Ruby # with yt: not supported (was removed from YouTube API V3) ``` -------------------------------- ### Initialize Yt Account with Refresh Token Source: https://github.com/nullscreen/yt/blob/master/README.md After configuring the Client ID and Secret, this snippet demonstrates how to initialize a Yt::Account object using a refresh token. This allows the application to manage a YouTube account persistently without requiring the user to re-authorize frequently. ```Ruby account = Yt::Account.new refresh_token: '1/1234567890' account.email #=> (retrieves the account’s e-mail address) account.videos #=> (lists a video to an account’s playlist) ``` -------------------------------- ### List Most Viewed Videos Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to retrieve a list of the most viewed videos. `yt` uses the 'viewCount' order parameter. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:most_viewed) ``` ```Ruby # with yt videos = Yt::Collections::Videos.new videos.where(order: 'viewCount') ``` -------------------------------- ### List All Most Popular Videos Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves a collection of most popular videos. YouTube API v3 typically returns a maximum of 50 results for this type of query. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:top_rated, :time => :today) ``` ```Ruby # with yt: YouTube API V3 only returns the top 50 videos = Yt::Collections::Videos.new videos.where(chart: 'mostPopular') ``` -------------------------------- ### List Most Popular Videos by Region and Category Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Filters most popular videos by a specific region and category. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:top_rated, :region => "RU", :category => "News").first ``` ```Ruby # with yt videos = Yt::Collections::Videos.new videos.where(chart: 'mostPopular', region_code: 'RU', video_category_id: 25).first ``` -------------------------------- ### Add Reply Comment to YouTube Comment Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Illustrates how to add a reply to an existing comment on a YouTube video using `youtube_it`. This feature is not available in `yt` due to YouTube API V3 changes. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.add_comment(video_id, "test reply!", :reply_to => another_comment) ``` -------------------------------- ### Add Video to Watch Later Playlist in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Adds a specified video to the user's 'Watch Later' playlist. This snippet demonstrates how to perform this action using both the `youtube_it` and `Yt` Ruby gems. ```Ruby # with youtube_it client.add_video_to_watchlater(video_id) # with yt account = Yt::Account.new access_token: 'access_token' watch_later = account.related_playlists.find{|p| p.title == 'Watch Later'} watch_later.add_video video_id ``` -------------------------------- ### Retrieve YouTube Channel Information with Yt Source: https://github.com/nullscreen/yt/blob/master/README.md Demonstrates how to initialize a Yt::Channel object using a YouTube channel ID and access various properties such as the channel's title, public status, and the total count of its videos. ```Ruby channel = Yt::Channel.new id: 'UCxO1tY8h1AhOz0T4ENwmpow' channel.title #=> "Fullscreen" channel.public? #=> true channel.videos.count #=> 12 ``` -------------------------------- ### Yt::ContentOwner API Capabilities Source: https://github.com/nullscreen/yt/blob/master/README.md Outlines the key functionalities provided by the Yt::ContentOwner class, enabling interaction with the YouTube API as a content owner for tasks such as authentication, managing channels, claims, references, policies, and assets. ```APIDOC Yt::ContentOwner: - Authenticate as a YouTube content owner - List channels partnered with a YouTube content owner - List claims administered by the content owner - List and delete references administered by the content owner - List policies and policy rules administered by the content owner - Create assets - List assets ``` -------------------------------- ### Search Yt Assets by Custom Labels Source: https://github.com/nullscreen/yt/blob/master/README.md This snippet illustrates how to search for `Yt::Asset` objects based on custom labels. It demonstrates counting matching assets and accessing properties like the title of the first result. An authenticated `Yt::ContentOwner` is required to perform the search. ```Ruby content_owner.assets.where(labels: "campaign:cpiuwdz-8oc").size #=> 417 content_owner.assets.where(labels: "campaign:cpiuwdz-8oc").first.title #=> "Whoomp! (Supadupafly) (Xxl Hip House Mix)" ``` -------------------------------- ### Add Comment to YouTube Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates how to add a new comment to a YouTube video using `youtube_it`. This functionality is not supported by `yt` due to YouTube API V3 changes. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.add_comment(video_id, "test comment!") ``` -------------------------------- ### Listing videos by categories Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Highlights that the 'categories' filter was removed from YouTube API V3. `Yt` requires filtering by `video_category_id` one at a time. ```ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:categories => [:news, :sports]) ``` ```ruby # with yt: the 'categories' filter was removed from YouTube API V3, so the # request must be done using one category_id at the time videos = Yt::Collections::Videos.new videos.where(video_category_id: 25) #=> News videos.where(video_category_id: 17) #=> Sports ``` -------------------------------- ### Filter Videos by View Count Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves videos based on their view count. `yt` provides a similar method by ordering results by 'viewCount'. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:fields => {:view_count => "1000"}) ``` ```Ruby # with yt: the most similar method in YouTube API V3 is to return the results by view count videos = Yt::Collections::Videos.new videos.where(order: 'viewCount') ``` -------------------------------- ### List Most Popular Video Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Retrieves the single most popular video. `youtube_it` allows filtering by time, while `yt` uses the 'mostPopular' chart parameter. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:top_rated, :time => :today).first ``` ```Ruby # with yt videos = Yt::Collections::Videos.new videos.where(chart: 'mostPopular').first ``` -------------------------------- ### List Most Linked Videos Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Demonstrates retrieving videos that are most linked. This functionality is no longer supported by YouTube API v3. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:most_linked, :page => 3) ``` ```Ruby # with yt: not supported (was removed from YouTube API V3) ``` -------------------------------- ### Perform Partial Update on Video Title in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Updates only the title of a video without affecting other fields. This snippet demonstrates the difference in partial update behavior between `youtube_it` (explicit method) and `Yt` (default behavior). ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.video_partial_update(video_id, :title => 'new title') # with yt account = Yt::Account.new access_token: 'access_token' video = Yt::Video.new id: video_id, auth: account video.update title: 'new title' ``` -------------------------------- ### Update Yt Asset Ownership Details Source: https://github.com/nullscreen/yt/blob/master/README.md This snippet shows how to update the ownership details of an asset using the `Yt::Ownership` class. It demonstrates setting new general owner attributes, including ratio, owner name, type, and territories. Authentication as the video's content owner is required. ```Ruby content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.1.ABCDEFGHIJ' ownership = Yt::Ownership.new asset_id: 'ABCD12345678', auth: $content_owner new_general_owner_attrs = {ratio: 100, owner: 'CMSname', type: 'include', territories: ['US', 'CA']} ownership.update general: [new_general_owner_attrs] ``` -------------------------------- ### Block Embedding of Video During Upload in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Uploads a video and sets its embeddability to 'denied' using `youtube_it`. While documented in YouTube Data API V3, this setting may not function correctly via the API, and is not reliably supported by `Yt`. ```Ruby # with youtube_it client = YouTubeIt::Client.new(:username => "youtube_username", :password => "youtube_passwd", :dev_key => "developer_key") client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :embed => "denied") # with yt: not supported (it is documented in YouTube API V3 but looks like it is not working) ``` -------------------------------- ### Access YouTube Video Details and Comments with Yt Source: https://github.com/nullscreen/yt/blob/master/README.md Illustrates how to create a Yt::Video object from a video ID and retrieve detailed information including the video's title, comment count, HD status, annotation count, and how to iterate through comment threads, optionally limiting the number of fetched pages. ```Ruby video = Yt::Video.new id: 'jNQXAC9IVRw' video.title #=> "Fullscreen Creator Platform" video.comment_count #=> 308 video.hd? #=> true video.annotations.count #=> 1 video.comment_threads #=> # # Use #take to limit the number of pages need to fetch from server video.comment_threads.take(99).map(&:author_display_name) #=> ["Paul", "Tommy", ...] ``` -------------------------------- ### Configure Yt with Client ID and Secret for OAuth Web Flow Source: https://github.com/nullscreen/yt/blob/master/README.md For web applications that need to obtain user authorization via Google OAuth, the Yt library must be configured with the application's Client ID and Client Secret. These are essential for initiating the OAuth flow and generating the authentication URL. ```Ruby Yt.configure do |config| config.client_id = '49781862760-4t610gtk35462g.apps.googleusercontent.com' config.client_secret = 'NtFHjZkJcwYZDfYVz9mp8skz9' end ``` -------------------------------- ### Listing videos by region code Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Compares regional video filtering. Notes that `regionCode` might not work reliably in YouTube API V3 for `Yt`. ```ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:query => "penguin", :restriction => "DE") ``` ```ruby # with yt # Note that some users report that regionCode does not work in YouTube API V3 # See https://code.google.com/p/gdata-issues/issues/detail?id=4110 videos = Yt::Collections::Videos.new videos.where(q: 'penguin', region_code: 'DE') ``` -------------------------------- ### Retrieve Yt Asset Metadata (Mine and Effective) Source: https://github.com/nullscreen/yt/blob/master/README.md This snippet demonstrates how to fetch different types of metadata for a `Yt::Asset`. It shows retrieving `metadata_mine` for user-defined data and `metadata_effective` which reflects potential ownership conflicts. An authenticated content owner and the asset ID are necessary. ```Ruby content_owner = Yt::ContentOwner.new(...) asset = content_owner.assets.where(id: 'A969176766549462', fetch_metadata: 'mine').first asset.metadata_mine.title #=> "Master Final Neu La Anh Fix" asset = content_owner.assets.where(id: 'A969176766549462', fetch_metadata: 'effective').first asset.metadata_effective.title #=> "Neu la anh" (different due to ownership conflicts) ``` -------------------------------- ### Update Yt Match Policy for an Asset Source: https://github.com/nullscreen/yt/blob/master/README.md This Ruby snippet demonstrates how to update the match policy associated with a specific asset using the `Yt::MatchPolicy` class. It requires an authenticated `Yt::ContentOwner` instance and the `asset_id` and `policy_id` to be updated. ```Ruby content_owner = Yt::ContentOwner.new owner_name: 'CMSname', access_token: 'ya29.1.ABCDEFGHIJ' match_policy = Yt::MatchPolicy.new asset_id: 'ABCD12345678', auth: content_owner match_policy.update policy_id: 'aBcdEF6g-HJ' #=> true ``` -------------------------------- ### Update Playlist Item Position in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Updates the position of a specific playlist item within a YouTube playlist using the `Yt` gem. This operation requires an authenticated account and the ID of the playlist entry. ```Ruby # with yt account = Yt::Account.new access_token: 'access_token' playlist_item = Yt::PlaylistItem.new id: playlist_entry_id, auth: account playlist_item.update position: position ``` -------------------------------- ### Subscribe to Yt HTTP Request Notifications Source: https://github.com/nullscreen/yt/blob/master/README.md This snippet shows how to subscribe to `request.yt` notifications using Active Support Instrumentation. This allows developers to monitor HTTP requests made by the Yt gem, useful for tracking quota usage, audit trails, or request duration. The event payload provides details like `request_uri` and `method`. ```Ruby ActiveSupport::Notifications.subscribe 'request.yt' do |*args| event = ActiveSupport::Notifications::Event.new(*args) event.payload[:request_uri] #=> # event.payload[:method] #=> :get end ``` -------------------------------- ### Filter Videos by Date (Published/Recorded) Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Filters videos by their publication or recording date, including date ranges. YouTube API v3 only supports filtering by published date. ```Ruby # with youtube_it client = YouTubeIt::Client.new client.videos_by(:fields => {:published => (Date.today)}) client.videos_by(:fields => {:recorded => (Date.today)}) client.videos_by(:fields => {:published => ((Date.today - 30)..(Date.today))}) client.videos_by(:fields => {:recorded => ((Date.today - 30)..(Date.today))}) ``` ```Ruby # with yt (only published is available in YouTube API V3, not recorded date) videos = Yt::Collections::Videos.new videos.where(published_before: 0.days.ago.utc.iso8601(0), published_after: 30.day.ago.utc.iso8601(0)) ``` -------------------------------- ### Generate Google OAuth Authentication URL Source: https://github.com/nullscreen/yt/blob/master/README.md This code snippet shows how to generate the Google OAuth authentication URL. Users will be redirected to this URL to authorize your application. It requires specifying the desired YouTube API scopes and the redirect URI where the user will be sent after authorization. ```Ruby Yt::Account.new(scopes: scopes, redirect_uri: redirect_uri).authentication_url ``` -------------------------------- ### Configure Yt with Client ID and Secret for Refresh Token Usage Source: https://github.com/nullscreen/yt/blob/master/README.md When using a refresh token to manage YouTube accounts, the Yt library needs to be configured with the application's Client ID and Client Secret. These credentials enable the library to refresh expired access tokens automatically. ```Ruby Yt.configure do |config| config.client_id = '1234567890.apps.googleusercontent.com' config.client_secret = '1234567890' end ``` -------------------------------- ### Block Comments on Video During Upload in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Uploads a video and sets its comment access control to 'denied' using `youtube_it`. This feature is not supported by `Yt` as it was removed from YouTube Data API V3. ```Ruby # with youtube_it client = YouTubeIt::Client.new(:username => "youtube_username", :password => "youtube_passwd", :dev_key => "developer_key") client.video_upload(File.open("test.mov"), :title => "test",:description => 'some description', :category => 'People',:keywords => %w[cool blah test], :comment => "denied") # with yt: not supported (was removed from YouTube API V3; only the embeddable setting can be specified) ``` -------------------------------- ### Delete Response Video in Ruby Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Deletes a video response using `youtube_it`. This functionality is deprecated and not supported by the YouTube Data API V3, making it unavailable in the `Yt` gem. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub video.delete_response(original_video_id, response_video_id) # with yt: not supported (was removed from YouTube API V3) ``` -------------------------------- ### Delete YouTube Video Comment Source: https://github.com/nullscreen/yt/blob/master/YOUTUBE_IT.md Shows how to delete a specific comment from a YouTube video using `youtube_it`. This functionality is not supported by `yt` due to YouTube API V3 changes. ```Ruby # with youtube_it client = # new client initialized with either OAuth or AuthSub client.delete_comment(video_id, comment_id) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.