mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-22 03:40:14 +00:00
implement video overwrites index for sponsorblock
This commit is contained in:
parent
859bf2a28d
commit
9d73dbc45a
@ -177,7 +177,9 @@ class VideoDownloader:
|
|||||||
except yt_dlp.utils.DownloadError:
|
except yt_dlp.utils.DownloadError:
|
||||||
print("failed to download " + youtube_id)
|
print("failed to download " + youtube_id)
|
||||||
continue
|
continue
|
||||||
vid_dict = index_new_video(youtube_id)
|
vid_dict = index_new_video(
|
||||||
|
youtube_id, video_overwrites=self.video_overwrites
|
||||||
|
)
|
||||||
self.channels.add(vid_dict["channel"]["channel_id"])
|
self.channels.add(vid_dict["channel"]["channel_id"])
|
||||||
self.move_to_archive(vid_dict)
|
self.move_to_archive(vid_dict)
|
||||||
self._delete_from_pending(youtube_id)
|
self._delete_from_pending(youtube_id)
|
||||||
|
@ -358,9 +358,10 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
index_name = "ta_video"
|
index_name = "ta_video"
|
||||||
yt_base = "https://www.youtube.com/watch?v="
|
yt_base = "https://www.youtube.com/watch?v="
|
||||||
|
|
||||||
def __init__(self, youtube_id):
|
def __init__(self, youtube_id, video_overwrites=False):
|
||||||
super().__init__(youtube_id)
|
super().__init__(youtube_id)
|
||||||
self.channel_id = False
|
self.channel_id = False
|
||||||
|
self.video_overwrites = video_overwrites
|
||||||
self.es_path = f"{self.index_name}/_doc/{youtube_id}"
|
self.es_path = f"{self.index_name}/_doc/{youtube_id}"
|
||||||
|
|
||||||
def build_json(self):
|
def build_json(self):
|
||||||
@ -377,11 +378,24 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
if self.config["downloads"]["integrate_ryd"]:
|
if self.config["downloads"]["integrate_ryd"]:
|
||||||
self._get_ryd_stats()
|
self._get_ryd_stats()
|
||||||
|
|
||||||
if self.config["downloads"]["integrate_sponsorblock"]:
|
if self._check_get_sb():
|
||||||
self._get_sponsorblock()
|
self._get_sponsorblock()
|
||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
def _check_get_sb(self):
|
||||||
|
"""check if need to run sponsor block"""
|
||||||
|
if self.config["downloads"]["integrate_sponsorblock"]:
|
||||||
|
return True
|
||||||
|
try:
|
||||||
|
single_overwrite = self.video_overwrites[self.youtube_id]
|
||||||
|
_ = single_overwrite["integrate_sponsorblock"]
|
||||||
|
return True
|
||||||
|
except KeyError:
|
||||||
|
return False
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
def _process_youtube_meta(self):
|
def _process_youtube_meta(self):
|
||||||
"""extract relevant fields from youtube"""
|
"""extract relevant fields from youtube"""
|
||||||
# extract
|
# extract
|
||||||
@ -547,9 +561,9 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
_, _ = ElasticWrap(path).post(data=data)
|
_, _ = ElasticWrap(path).post(data=data)
|
||||||
|
|
||||||
|
|
||||||
def index_new_video(youtube_id):
|
def index_new_video(youtube_id, video_overwrites=False):
|
||||||
"""combined classes to create new video in index"""
|
"""combined classes to create new video in index"""
|
||||||
video = YoutubeVideo(youtube_id)
|
video = YoutubeVideo(youtube_id, video_overwrites=video_overwrites)
|
||||||
video.build_json()
|
video.build_json()
|
||||||
if not video.json_data:
|
if not video.json_data:
|
||||||
raise ValueError("failed to get metadata for " + youtube_id)
|
raise ValueError("failed to get metadata for " + youtube_id)
|
||||||
|
Loading…
Reference in New Issue
Block a user