Skip to content

Commit

Permalink
YoutubeAPI: depublish every video url that we know of
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunsi committed Jan 2, 2025
1 parent 061b5d1 commit 5e5b8a0
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions voctopublish/api_client/youtube_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,26 +524,22 @@ def depublish(self):
i = 0
depublished_urls = []
props = {}
for lang in self.t.languages:
video_url = self.t._get_str(f"YouTube.Url{i}", optional=True)
if video_url:
try:
video_id = video_url.split("=", 2)[1]
self.update_metadata(
video_id,
{"id": video_id, "status": {"privacyStatus": "private"}},
)
LOG.info("depublished %s video track from %s" % (lang, video_url))
depublished_urls.append(video_url)
props[f"YouTube.Url{i}"] = ""

if self.t.youtube_playlists:
yt.remove_from_playlists(video_id, self.t.youtube_playlists)
except Exception as e:
LOG.error(f"debublishing of {video_url} failed with {e}")

i += 1
return depublished_urls, props
for prop, url in self.t.youtube_urls.items():
try:
video_id = video_url.split("=", 2)[1]
self.update_metadata(
video_id,
{"id": video_id, "status": {"privacyStatus": "private"}},
)
LOG.info("depublished %s video track from %s" % (lang, video_url))
depublished_urls.append(video_url)
props[prop] = ""

if self.t.youtube_playlists:
yt.remove_from_playlists(video_id, self.t.youtube_playlists)
except Exception as e:
LOG.error(f"debublishing of {video_url} failed with {e}")
return depublished_urls, props

def update_metadata(self, video_id, metadata):
# https://developers.google.com/youtube/v3/docs/videos#resource
Expand Down

0 comments on commit 5e5b8a0

Please sign in to comment.