mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 21:49:38 +00:00
implement youtube_meta and media_path overwritein YoutubeVideo
This commit is contained in:
@@ -426,17 +426,20 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
self.video_overwrites = video_overwrites
|
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, youtube_meta_overwrite=False, media_path=False):
|
||||||
"""build json dict of video"""
|
"""build json dict of video"""
|
||||||
self.get_from_youtube()
|
self.get_from_youtube()
|
||||||
if not self.youtube_meta:
|
if not self.youtube_meta and not youtube_meta_overwrite:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if not self.youtube_meta:
|
||||||
|
self.youtube_meta = youtube_meta_overwrite
|
||||||
|
|
||||||
self._process_youtube_meta()
|
self._process_youtube_meta()
|
||||||
self._add_channel()
|
self._add_channel()
|
||||||
self._add_stats()
|
self._add_stats()
|
||||||
self.add_file_path()
|
self.add_file_path()
|
||||||
self.add_player()
|
self.add_player(media_path)
|
||||||
if self.config["downloads"]["integrate_ryd"]:
|
if self.config["downloads"]["integrate_ryd"]:
|
||||||
self._get_ryd_stats()
|
self._get_ryd_stats()
|
||||||
|
|
||||||
@@ -518,8 +521,28 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
|
|
||||||
raise FileNotFoundError
|
raise FileNotFoundError
|
||||||
|
|
||||||
def add_player(self):
|
def add_player(self, media_path=False):
|
||||||
"""add player information for new videos"""
|
"""add player information for new videos"""
|
||||||
|
vid_path = self._get_vid_path(media_path)
|
||||||
|
|
||||||
|
duration_handler = DurationConverter()
|
||||||
|
duration = duration_handler.get_sec(vid_path)
|
||||||
|
duration_str = duration_handler.get_str(duration)
|
||||||
|
self.json_data.update(
|
||||||
|
{
|
||||||
|
"player": {
|
||||||
|
"watched": False,
|
||||||
|
"duration": duration,
|
||||||
|
"duration_str": duration_str,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
def _get_vid_path(self, media_path=False):
|
||||||
|
"""get path of media file"""
|
||||||
|
if media_path:
|
||||||
|
return media_path
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# when indexing from download task
|
# when indexing from download task
|
||||||
vid_path = self.build_dl_cache_path()
|
vid_path = self.build_dl_cache_path()
|
||||||
@@ -535,18 +558,7 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||||||
else:
|
else:
|
||||||
raise FileNotFoundError("could not find video file") from err
|
raise FileNotFoundError("could not find video file") from err
|
||||||
|
|
||||||
duration_handler = DurationConverter()
|
return vid_path
|
||||||
duration = duration_handler.get_sec(vid_path)
|
|
||||||
duration_str = duration_handler.get_str(duration)
|
|
||||||
self.json_data.update(
|
|
||||||
{
|
|
||||||
"player": {
|
|
||||||
"watched": False,
|
|
||||||
"duration": duration,
|
|
||||||
"duration_str": duration_str,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
def add_file_path(self):
|
def add_file_path(self):
|
||||||
"""build media_url for where file will be located"""
|
"""build media_url for where file will be located"""
|
||||||
|
|||||||
Reference in New Issue
Block a user