From a16f6160e94ee1dc6c35d82aecbddd891d147c69 Mon Sep 17 00:00:00 2001 From: Simon Date: Sun, 28 Dec 2025 10:44:57 +0700 Subject: [PATCH] fix playlist description none data type --- .../config/management/commands/ta_startup.py | 32 +++++++++++++++++++ backend/playlist/src/index.py | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/backend/config/management/commands/ta_startup.py b/backend/config/management/commands/ta_startup.py index a0eb6863..052c1e15 100644 --- a/backend/config/management/commands/ta_startup.py +++ b/backend/config/management/commands/ta_startup.py @@ -57,6 +57,7 @@ class Command(BaseCommand): self._mig_add_default_playlist_sort() self._mig_set_channel_tabs() self._mig_set_video_channel_tabs() + self._mig_fix_playlist_description() def _make_folders(self): """make expected cache folders""" @@ -408,3 +409,34 @@ class Command(BaseCommand): self.stdout.write(response) sleep(60) raise CommandError(message) + + def _mig_fix_playlist_description(self) -> None: + """migrate from 0.5.8 to 0.5.9 fix playlist desc null data type""" + self.stdout.write("[MIGRATION] fix playlist description data type") + + path = "ta_playlist/_update_by_query" + data = { + "query": {"term": {"playlist_description": {"value": False}}}, + "script": { + "source": "ctx._source.playlist_description = null", + "lang": "painless", + }, + } + response, status_code = ElasticWrap(path).post(data) + if status_code in [200, 201]: + updated = response.get("updated") + if updated: + self.stdout.write( + self.style.SUCCESS(f" ✓ updated {updated} playlists") + ) + else: + self.stdout.write( + self.style.SUCCESS(" no playlists need updating") + ) + return + + message = " 🗙 failed to fix playlist description null data type" + self.stdout.write(self.style.ERROR(message)) + self.stdout.write(response) + sleep(60) + raise CommandError(message) diff --git a/backend/playlist/src/index.py b/backend/playlist/src/index.py index d2e6e301..2f96ba8d 100644 --- a/backend/playlist/src/index.py +++ b/backend/playlist/src/index.py @@ -81,7 +81,7 @@ class YoutubePlaylist(YouTubeItem): "playlist_channel": self.youtube_meta["channel"], "playlist_channel_id": self.youtube_meta["channel_id"], "playlist_thumbnail": playlist_thumbnail, - "playlist_description": self.youtube_meta["description"] or False, + "playlist_description": self.youtube_meta["description"] or None, "playlist_last_refresh": int(datetime.now().timestamp()), "playlist_type": "regular", }