|
|
|
@@ -35,9 +35,10 @@ module Youtube |
|
|
|
end |
|
|
|
|
|
|
|
playlist_ids.each do |playlist_id| |
|
|
|
response = @client.playlist_items(playlist_id:) |
|
|
|
response.fetch('items', []).each do |item| |
|
|
|
each_playlist_item(playlist_id) do |item| |
|
|
|
video_id = item.dig('contentDetails', 'videoId') |
|
|
|
video_id ||= item.dig('snippet', 'resourceId', 'videoId') |
|
|
|
|
|
|
|
ids << video_id if video_id.present? |
|
|
|
end |
|
|
|
end |
|
|
|
@@ -70,7 +71,7 @@ module Youtube |
|
|
|
title: video.title, |
|
|
|
url: video.url, |
|
|
|
thumbnail_base: video.thumbnail_url, |
|
|
|
uploaded_user: nil, |
|
|
|
uploaded_user_id: nil, |
|
|
|
original_created_from:, |
|
|
|
original_created_before:) |
|
|
|
|
|
|
|
@@ -84,6 +85,7 @@ module Youtube |
|
|
|
|
|
|
|
deerjikist = Deerjikist.find_by(platform: :youtube, code: video.channel_id) |
|
|
|
if deerjikist |
|
|
|
desired_tag_ids.delete(Tag.no_deerjikist.id) |
|
|
|
desired_tag_ids << deerjikist.tag_id |
|
|
|
elsif post.tags.where(category: :deerjikist).none? |
|
|
|
desired_tag_ids << Tag.no_deerjikist.id |
|
|
|
@@ -147,5 +149,20 @@ module Youtube |
|
|
|
end |
|
|
|
|
|
|
|
def sync_since = 14.days.ago |
|
|
|
|
|
|
|
def each_playlist_item playlist_id |
|
|
|
page_token = nil |
|
|
|
|
|
|
|
loop do |
|
|
|
response = @client.playlist_items(playlist_id:, page_token:) |
|
|
|
|
|
|
|
response.fetch('items', []).each do |item| |
|
|
|
yield item |
|
|
|
end |
|
|
|
|
|
|
|
page_token = response['nextPageToken'] |
|
|
|
break if page_token.blank? |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |