mirror of
https://github.com/tubearchivist/tubearchivist
synced 2024-11-02 09:41:07 +00:00
add cookiefile to PendingList and VideoDownloader
This commit is contained in:
parent
6cc5fd8890
commit
088e87bccf
@ -13,8 +13,10 @@ from home.src.download.subscriptions import (
|
|||||||
PlaylistSubscription,
|
PlaylistSubscription,
|
||||||
)
|
)
|
||||||
from home.src.download.thumbnails import ThumbManager
|
from home.src.download.thumbnails import ThumbManager
|
||||||
|
from home.src.download.yt_cookie import CookieHandler
|
||||||
from home.src.es.connect import ElasticWrap, IndexPaginate
|
from home.src.es.connect import ElasticWrap, IndexPaginate
|
||||||
from home.src.index.playlist import YoutubePlaylist
|
from home.src.index.playlist import YoutubePlaylist
|
||||||
|
from home.src.ta.config import AppConfig
|
||||||
from home.src.ta.helper import DurationConverter
|
from home.src.ta.helper import DurationConverter
|
||||||
from home.src.ta.ta_redis import RedisArchivist
|
from home.src.ta.ta_redis import RedisArchivist
|
||||||
|
|
||||||
@ -119,12 +121,29 @@ class PendingInteract:
|
|||||||
class PendingList(PendingIndex):
|
class PendingList(PendingIndex):
|
||||||
"""manage the pending videos list"""
|
"""manage the pending videos list"""
|
||||||
|
|
||||||
|
yt_obs = {
|
||||||
|
"default_search": "ytsearch",
|
||||||
|
"quiet": True,
|
||||||
|
"check_formats": "selected",
|
||||||
|
"noplaylist": True,
|
||||||
|
"writethumbnail": True,
|
||||||
|
"simulate": True,
|
||||||
|
}
|
||||||
|
|
||||||
def __init__(self, youtube_ids=False):
|
def __init__(self, youtube_ids=False):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
self.process_config()
|
||||||
self.youtube_ids = youtube_ids
|
self.youtube_ids = youtube_ids
|
||||||
self.to_skip = False
|
self.to_skip = False
|
||||||
self.missing_videos = False
|
self.missing_videos = False
|
||||||
|
|
||||||
|
def process_config(self):
|
||||||
|
"""add user config to yt_obs"""
|
||||||
|
config = AppConfig().config
|
||||||
|
if config["downloads"]["cookie_import"]:
|
||||||
|
cookie_path = CookieHandler().use()
|
||||||
|
self.yt_obs.update({"cookiefile": cookie_path})
|
||||||
|
|
||||||
def parse_url_list(self):
|
def parse_url_list(self):
|
||||||
"""extract youtube ids from list"""
|
"""extract youtube ids from list"""
|
||||||
self.missing_videos = []
|
self.missing_videos = []
|
||||||
@ -223,16 +242,8 @@ class PendingList(PendingIndex):
|
|||||||
|
|
||||||
def get_youtube_details(self, youtube_id):
|
def get_youtube_details(self, youtube_id):
|
||||||
"""get details from youtubedl for single pending video"""
|
"""get details from youtubedl for single pending video"""
|
||||||
obs = {
|
|
||||||
"default_search": "ytsearch",
|
|
||||||
"quiet": True,
|
|
||||||
"check_formats": "selected",
|
|
||||||
"noplaylist": True,
|
|
||||||
"writethumbnail": True,
|
|
||||||
"simulate": True,
|
|
||||||
}
|
|
||||||
try:
|
try:
|
||||||
vid = yt_dlp.YoutubeDL(obs).extract_info(youtube_id)
|
vid = yt_dlp.YoutubeDL(self.yt_obs).extract_info(youtube_id)
|
||||||
except yt_dlp.utils.DownloadError:
|
except yt_dlp.utils.DownloadError:
|
||||||
print("failed to extract info for: " + youtube_id)
|
print("failed to extract info for: " + youtube_id)
|
||||||
return False
|
return False
|
||||||
|
@ -14,6 +14,7 @@ from time import sleep
|
|||||||
import yt_dlp
|
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.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
|
||||||
@ -290,6 +291,9 @@ class VideoDownloader:
|
|||||||
self.obs["ratelimit"] = (
|
self.obs["ratelimit"] = (
|
||||||
self.config["downloads"]["limit_speed"] * 1024
|
self.config["downloads"]["limit_speed"] * 1024
|
||||||
)
|
)
|
||||||
|
if self.config["downloads"]["cookie_import"]:
|
||||||
|
cookie_path = CookieHandler().use()
|
||||||
|
self.obs["cookiefile"] = cookie_path
|
||||||
|
|
||||||
throttle = self.config["downloads"]["throttledratelimit"]
|
throttle = self.config["downloads"]["throttledratelimit"]
|
||||||
if throttle:
|
if throttle:
|
||||||
|
Loading…
Reference in New Issue
Block a user