mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-16 00:12:49 +00:00
fix media_url change in reindex, #424
This commit is contained in:
parent
8d76961e77
commit
b52aa4daba
@ -259,6 +259,7 @@ class Reindex(ReindexBase):
|
||||
video.get_from_es()
|
||||
player = video.json_data["player"]
|
||||
date_downloaded = video.json_data["date_downloaded"]
|
||||
media_url = video.json_data["media_url"]
|
||||
channel_dict = video.json_data["channel"]
|
||||
playlist = video.json_data.get("playlist")
|
||||
subtitles = video.json_data.get("subtitles")
|
||||
@ -280,6 +281,8 @@ class Reindex(ReindexBase):
|
||||
video.json_data["playlist"] = playlist
|
||||
|
||||
video.upload_to_es()
|
||||
if media_url != video.json_data["media_url"]:
|
||||
self._rename_media_file(media_url, video.json_data["media_url"])
|
||||
|
||||
thumb_handler = ThumbManager(youtube_id)
|
||||
thumb_handler.delete_video_thumb()
|
||||
@ -289,6 +292,14 @@ class Reindex(ReindexBase):
|
||||
|
||||
return
|
||||
|
||||
def _rename_media_file(self, media_url_is, media_url_should):
|
||||
"""handle title change"""
|
||||
print(f"[reindex] fix media_url {media_url_is} to {media_url_should}")
|
||||
videos = self.config["application"]["videos"]
|
||||
old_path = os.path.join(videos, media_url_is)
|
||||
new_path = os.path.join(videos, media_url_should)
|
||||
os.rename(old_path, new_path)
|
||||
|
||||
@staticmethod
|
||||
def _reindex_single_channel(channel_id):
|
||||
"""refresh channel data and sync to videos"""
|
||||
|
Loading…
Reference in New Issue
Block a user