From 5e5b8a0450b22a7bae825209586906c3cbf6cc90 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Thu, 2 Jan 2025 16:45:11 +0000 Subject: [PATCH] YoutubeAPI: depublish every video url that we know of --- voctopublish/api_client/youtube_client.py | 36 ++++++++++------------- 1 file changed, 16 insertions(+), 20 deletions(-) diff --git a/voctopublish/api_client/youtube_client.py b/voctopublish/api_client/youtube_client.py index 3099799..6916f48 100644 --- a/voctopublish/api_client/youtube_client.py +++ b/voctopublish/api_client/youtube_client.py @@ -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