fix playlist description none data type

This commit is contained in:
Simon 2025-12-28 10:44:57 +07:00
parent 97210e0cba
commit a16f6160e9
No known key found for this signature in database
GPG Key ID: 2C15AA5E89985DD4
2 changed files with 33 additions and 1 deletions

View File

@ -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)

View File

@ -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",
}