mirror of
https://github.com/tubearchivist/tubearchivist-frontend.git
synced 2024-11-04 19:30:13 +00:00
fix legacy import alias for yt-dlp
This commit is contained in:
parent
6d16d75ef9
commit
fd334bcafe
@ -13,7 +13,7 @@ from datetime import datetime
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import yt_dlp as youtube_dl
|
import yt_dlp
|
||||||
from home.src.config import AppConfig
|
from home.src.config import AppConfig
|
||||||
from home.src.helper import (
|
from home.src.helper import (
|
||||||
DurationConverter,
|
DurationConverter,
|
||||||
@ -155,8 +155,8 @@ class PendingList:
|
|||||||
"simulate": True,
|
"simulate": True,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
vid = youtube_dl.YoutubeDL(obs).extract_info(youtube_id)
|
vid = yt_dlp.YoutubeDL(obs).extract_info(youtube_id)
|
||||||
except youtube_dl.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
|
||||||
# stop if video is streaming live now
|
# stop if video is streaming live now
|
||||||
@ -309,7 +309,7 @@ class ChannelSubscription:
|
|||||||
}
|
}
|
||||||
if limit:
|
if limit:
|
||||||
obs["playlistend"] = self.channel_size
|
obs["playlistend"] = self.channel_size
|
||||||
chan = youtube_dl.YoutubeDL(obs).extract_info(url, download=False)
|
chan = yt_dlp.YoutubeDL(obs).extract_info(url, download=False)
|
||||||
last_videos = [(i["id"], i["title"]) for i in chan["entries"]]
|
last_videos = [(i["id"], i["title"]) for i in chan["entries"]]
|
||||||
return last_videos
|
return last_videos
|
||||||
|
|
||||||
@ -551,7 +551,7 @@ class VideoDownloader:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.dl_single_vid(youtube_id)
|
self.dl_single_vid(youtube_id)
|
||||||
except youtube_dl.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)
|
||||||
@ -593,7 +593,7 @@ class VideoDownloader:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def progress_hook(response):
|
def progress_hook(response):
|
||||||
"""process the progress_hooks from youtube_dl"""
|
"""process the progress_hooks from yt_dlp"""
|
||||||
# title
|
# title
|
||||||
path = os.path.split(response["filename"])[-1][12:]
|
path = os.path.split(response["filename"])[-1][12:]
|
||||||
filename = os.path.splitext(os.path.splitext(path)[0])[0]
|
filename = os.path.splitext(os.path.splitext(path)[0])[0]
|
||||||
@ -683,10 +683,10 @@ class VideoDownloader:
|
|||||||
for file_name in all_cached:
|
for file_name in all_cached:
|
||||||
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 youtube_dl.YoutubeDL(obs) as ydl:
|
with yt_dlp.YoutubeDL(obs) as ydl:
|
||||||
try:
|
try:
|
||||||
ydl.download([youtube_id])
|
ydl.download([youtube_id])
|
||||||
except youtube_dl.utils.DownloadError:
|
except yt_dlp.utils.DownloadError:
|
||||||
print("retry failed download: " + youtube_id)
|
print("retry failed download: " + youtube_id)
|
||||||
sleep(10)
|
sleep(10)
|
||||||
ydl.download([youtube_id])
|
ydl.download([youtube_id])
|
||||||
|
@ -13,7 +13,7 @@ from urllib.parse import parse_qs, urlparse
|
|||||||
|
|
||||||
import redis
|
import redis
|
||||||
import requests
|
import requests
|
||||||
import yt_dlp as youtube_dl
|
import yt_dlp
|
||||||
|
|
||||||
|
|
||||||
def get_total_hits(index, es_url, es_auth, match_field):
|
def get_total_hits(index, es_url, es_auth, match_field):
|
||||||
@ -139,7 +139,7 @@ class UrlListParser:
|
|||||||
"extract_flat": True,
|
"extract_flat": True,
|
||||||
"playlistend": 0,
|
"playlistend": 0,
|
||||||
}
|
}
|
||||||
url_info = youtube_dl.YoutubeDL(obs).extract_info(url, download=False)
|
url_info = yt_dlp.YoutubeDL(obs).extract_info(url, download=False)
|
||||||
try:
|
try:
|
||||||
channel_id = url_info["channel_id"]
|
channel_id = url_info["channel_id"]
|
||||||
except KeyError as error:
|
except KeyError as error:
|
||||||
|
@ -12,7 +12,7 @@ from datetime import datetime
|
|||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import yt_dlp as youtube_dl
|
import yt_dlp
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from home.src.config import AppConfig
|
from home.src.config import AppConfig
|
||||||
from home.src.helper import DurationConverter, UrlListParser, clean_string
|
from home.src.helper import DurationConverter, UrlListParser, clean_string
|
||||||
@ -257,7 +257,7 @@ class YoutubeChannel:
|
|||||||
"skip_download": True,
|
"skip_download": True,
|
||||||
"extract_flat": True,
|
"extract_flat": True,
|
||||||
}
|
}
|
||||||
playlists = youtube_dl.YoutubeDL(obs).extract_info(url)
|
playlists = yt_dlp.YoutubeDL(obs).extract_info(url)
|
||||||
all_entries = [(i["id"], i["title"]) for i in playlists["entries"]]
|
all_entries = [(i["id"], i["title"]) for i in playlists["entries"]]
|
||||||
|
|
||||||
return all_entries
|
return all_entries
|
||||||
@ -289,7 +289,7 @@ class YoutubeVideo:
|
|||||||
self.vid_dict = None
|
self.vid_dict = None
|
||||||
|
|
||||||
def get_vid_dict(self):
|
def get_vid_dict(self):
|
||||||
"""wrapper to loop around youtube_dl to retry on failure"""
|
"""wrapper to loop around yt_dlp to retry on failure"""
|
||||||
print(f"get video data for {self.youtube_id}")
|
print(f"get video data for {self.youtube_id}")
|
||||||
vid_dict = False
|
vid_dict = False
|
||||||
for i in range(3):
|
for i in range(3):
|
||||||
@ -315,10 +315,10 @@ class YoutubeVideo:
|
|||||||
"noplaylist": True,
|
"noplaylist": True,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
vid = youtube_dl.YoutubeDL(obs).extract_info(youtube_id)
|
vid = yt_dlp.YoutubeDL(obs).extract_info(youtube_id)
|
||||||
except (
|
except (
|
||||||
youtube_dl.utils.ExtractorError,
|
yt_dlp.utils.ExtractorError,
|
||||||
youtube_dl.utils.DownloadError,
|
yt_dlp.utils.DownloadError,
|
||||||
):
|
):
|
||||||
print("failed to get info for " + youtube_id)
|
print("failed to get info for " + youtube_id)
|
||||||
return False
|
return False
|
||||||
@ -489,12 +489,10 @@ class YoutubePlaylist:
|
|||||||
"playlistend": 0,
|
"playlistend": 0,
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
playlist = youtube_dl.YoutubeDL(obs).extract_info(
|
playlist = yt_dlp.YoutubeDL(obs).extract_info(url, download=False)
|
||||||
url, download=False
|
|
||||||
)
|
|
||||||
except (
|
except (
|
||||||
youtube_dl.utils.ExtractorError,
|
yt_dlp.utils.ExtractorError,
|
||||||
youtube_dl.utils.DownloadError,
|
yt_dlp.utils.DownloadError,
|
||||||
):
|
):
|
||||||
print("failed to get info for " + self.playlist_id)
|
print("failed to get info for " + self.playlist_id)
|
||||||
return False
|
return False
|
||||||
@ -535,12 +533,10 @@ class YoutubePlaylist:
|
|||||||
obs["playlistend"] = playlistend
|
obs["playlistend"] = playlistend
|
||||||
|
|
||||||
try:
|
try:
|
||||||
playlist = youtube_dl.YoutubeDL(obs).extract_info(
|
playlist = yt_dlp.YoutubeDL(obs).extract_info(url, download=False)
|
||||||
url, download=False
|
|
||||||
)
|
|
||||||
except (
|
except (
|
||||||
youtube_dl.utils.ExtractorError,
|
yt_dlp.utils.ExtractorError,
|
||||||
youtube_dl.utils.DownloadError,
|
yt_dlp.utils.DownloadError,
|
||||||
):
|
):
|
||||||
print("failed to get plealist entries for " + self.playlist_id)
|
print("failed to get plealist entries for " + self.playlist_id)
|
||||||
return False
|
return False
|
||||||
|
Loading…
Reference in New Issue
Block a user