consolidate available info, switch manual and filesystem logic
This commit is contained in:
parent
5c3898e7b8
commit
83280ddcc9
|
|
@ -8,7 +8,7 @@ import os
|
|||
from common.src.env_settings import EnvironmentSettings
|
||||
from common.src.es_connect import IndexPaginate
|
||||
from common.src.helper import ignore_filelist
|
||||
from video.src.comments import CommentList
|
||||
from video.src.comments import Comments
|
||||
from video.src.index import YoutubeVideo, index_new_video
|
||||
|
||||
|
||||
|
|
@ -88,8 +88,5 @@ class Scanner:
|
|||
)
|
||||
json_data = index_new_video(youtube_id)
|
||||
if json_data:
|
||||
Comments(youtube_id).build_json(upload=True)
|
||||
YoutubeVideo(youtube_id).embed_metadata()
|
||||
|
||||
comment_list = CommentList(task=self.task)
|
||||
comment_list.add(video_ids=list(self.to_index))
|
||||
comment_list.index()
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ from common.src.env_settings import EnvironmentSettings
|
|||
from common.src.helper import ignore_filelist
|
||||
from download.src.thumbnails import ThumbManager
|
||||
from PIL import Image
|
||||
from video.src.comments import CommentList
|
||||
from video.src.comments import Comments
|
||||
from video.src.index import YoutubeVideo
|
||||
from yt_dlp.utils import ISO639Utils
|
||||
|
||||
|
|
@ -145,13 +145,9 @@ class ImportFolderScanner:
|
|||
print(f"manual import: {current_video}")
|
||||
|
||||
ManualImport(current_video, config).run()
|
||||
Comments(current_video["video_id"]).build_json(upload=True)
|
||||
YoutubeVideo(current_video["video_id"]).embed_metadata()
|
||||
|
||||
video_ids = [i["video_id"] for i in self.to_import]
|
||||
comment_list = CommentList(task=self.task)
|
||||
comment_list.add(video_ids=video_ids)
|
||||
comment_list.index()
|
||||
|
||||
def _notify(self, idx, current_video):
|
||||
"""send notification back to task"""
|
||||
filename = os.path.split(current_video["media"])[-1]
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class Comments:
|
|||
self.is_activated = False
|
||||
self.comments_format = False
|
||||
|
||||
def build_json(self):
|
||||
def build_json(self, upload: bool = False):
|
||||
"""build json document for es"""
|
||||
print(f"{self.youtube_id}: get comments")
|
||||
self.check_config()
|
||||
|
|
@ -44,6 +44,8 @@ class Comments:
|
|||
"comment_channel_id": channel_id,
|
||||
"comment_comments": self.comments_format,
|
||||
}
|
||||
if upload:
|
||||
self.upload_comments()
|
||||
|
||||
def check_config(self):
|
||||
"""read config if not attached"""
|
||||
|
|
|
|||
|
|
@ -424,14 +424,6 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||
|
||||
def embed_metadata(self):
|
||||
"""embed metadata for video"""
|
||||
if self.config["downloads"].get("add_metadata"):
|
||||
self._embed_text_data()
|
||||
|
||||
if self.config["downloads"].get("add_thumbnail"):
|
||||
self._embed_artwork()
|
||||
|
||||
def _embed_text_data(self):
|
||||
print(f"{self.youtube_id}: embed metadata")
|
||||
if not self.json_data:
|
||||
self.get_from_es()
|
||||
|
||||
|
|
@ -439,6 +431,15 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||
print(f"{self.youtube_id}: skip embed, video not indexed")
|
||||
return
|
||||
|
||||
if self.config["downloads"].get("add_metadata"):
|
||||
self._embed_text_data()
|
||||
|
||||
if self.config["downloads"].get("add_thumbnail"):
|
||||
self._embed_artwork()
|
||||
|
||||
def _embed_text_data(self):
|
||||
"""embed text metadata"""
|
||||
print(f"{self.youtube_id}: embed metadata")
|
||||
video_base = EnvironmentSettings.MEDIA_DIR
|
||||
media_url = self.json_data.get("media_url")
|
||||
file_path = os.path.join(video_base, media_url)
|
||||
|
|
@ -492,13 +493,6 @@ class YoutubeVideo(YouTubeItem, YoutubeSubtitle):
|
|||
def _embed_artwork(self):
|
||||
"""embed artwork"""
|
||||
print(f"{self.youtube_id}: embed artwork")
|
||||
if not self.json_data:
|
||||
self.get_from_es()
|
||||
|
||||
if not self.json_data:
|
||||
print(f"{self.youtube_id}: skip embed, video not indexed")
|
||||
return
|
||||
|
||||
ThumbManager(self.youtube_id).embed_video_art(self.json_data)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,8 @@
|
|||
"""bulk metadata embedding"""
|
||||
"""
|
||||
Functionality:
|
||||
- bulk metadata embedding
|
||||
- restore from embedded metadata
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
|
|
|
|||
Loading…
Reference in New Issue