integrate new YtWrap class in yt_dlp handler
This commit is contained in:
parent
33f27f018f
commit
4b00f454b7
|
@ -9,12 +9,11 @@ functionality:
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
import yt_dlp
|
|
||||||
from home.src.download.queue import PendingList
|
from home.src.download.queue import PendingList
|
||||||
from home.src.download.subscriptions import PlaylistSubscription
|
from home.src.download.subscriptions import PlaylistSubscription
|
||||||
from home.src.download.yt_cookie import CookieHandler
|
from home.src.download.yt_cookie import CookieHandler
|
||||||
|
from home.src.download.yt_dlp_base import YtWrap
|
||||||
from home.src.es.connect import ElasticWrap, IndexPaginate
|
from home.src.es.connect import ElasticWrap, IndexPaginate
|
||||||
from home.src.index.channel import YoutubeChannel
|
from home.src.index.channel import YoutubeChannel
|
||||||
from home.src.index.playlist import YoutubePlaylist
|
from home.src.index.playlist import YoutubePlaylist
|
||||||
|
@ -174,11 +173,10 @@ class VideoDownloader:
|
||||||
if not youtube_id:
|
if not youtube_id:
|
||||||
break
|
break
|
||||||
|
|
||||||
try:
|
success = self._dl_single_vid(youtube_id)
|
||||||
self._dl_single_vid(youtube_id)
|
if not success:
|
||||||
except yt_dlp.utils.DownloadError:
|
|
||||||
print("failed to download " + youtube_id)
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
vid_dict = index_new_video(
|
vid_dict = index_new_video(
|
||||||
youtube_id, video_overwrites=self.video_overwrites
|
youtube_id, video_overwrites=self.video_overwrites
|
||||||
)
|
)
|
||||||
|
@ -348,13 +346,7 @@ class VideoDownloader:
|
||||||
if youtube_id in file_name:
|
if youtube_id in file_name:
|
||||||
obs["outtmpl"] = os.path.join(dl_cache, file_name)
|
obs["outtmpl"] = os.path.join(dl_cache, file_name)
|
||||||
|
|
||||||
with yt_dlp.YoutubeDL(obs) as ydl:
|
success = YtWrap(obs).download(youtube_id)
|
||||||
try:
|
|
||||||
ydl.download([youtube_id])
|
|
||||||
except yt_dlp.utils.DownloadError:
|
|
||||||
print("retry failed download: " + youtube_id)
|
|
||||||
sleep(10)
|
|
||||||
ydl.download([youtube_id])
|
|
||||||
|
|
||||||
if self.obs["writethumbnail"]:
|
if self.obs["writethumbnail"]:
|
||||||
# webp files don't get cleaned up automatically
|
# webp files don't get cleaned up automatically
|
||||||
|
@ -364,6 +356,8 @@ class VideoDownloader:
|
||||||
file_path = os.path.join(dl_cache, file_name)
|
file_path = os.path.join(dl_cache, file_name)
|
||||||
os.remove(file_path)
|
os.remove(file_path)
|
||||||
|
|
||||||
|
return success
|
||||||
|
|
||||||
def move_to_archive(self, vid_dict):
|
def move_to_archive(self, vid_dict):
|
||||||
"""move downloaded video from cache to archive"""
|
"""move downloaded video from cache to archive"""
|
||||||
videos = self.config["application"]["videos"]
|
videos = self.config["application"]["videos"]
|
||||||
|
|
Loading…
Reference in New Issue