replace with yt-dlp
This commit is contained in:
parent
9c9fb37a0e
commit
0a12a7e452
|
@ -11,7 +11,7 @@ import sys
|
|||
import time
|
||||
from subprocess import call
|
||||
|
||||
import youtube_dl
|
||||
import yt_dlp #youtube_dl
|
||||
|
||||
done = False
|
||||
urlRegex = re.compile(
|
||||
|
@ -30,7 +30,7 @@ parser.add_argument('--encrypt', '-e', action='store_true', help='encrypt the co
|
|||
parser.add_argument('--password', '-p', action='store_true', help='password to encrypt the compressed 7z archive with')
|
||||
parser.add_argument('--no-update', '-nu', action='store_true', help='don\t update Pip packages')
|
||||
parser.add_argument('--cmd', '-c', help='use the bash youtube-dl instead of the embedded python version', action='store_true')
|
||||
parser.add_argument('--max-size', '-m', type=int, default=2000, help="max size of video in mb")
|
||||
parser.add_argument('--max-size', '-m', type=int, default=1000, help="max size of video in mb")
|
||||
parser.add_argument('--check-size', '-ch', action='store_true', help="verify the video is smaller than the max size and skip if not")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
@ -67,7 +67,7 @@ fh.setFormatter(formatter)
|
|||
logging.StreamHandler(stream=sys.stderr)
|
||||
logger.addHandler(fh)
|
||||
|
||||
os.system('youtube-dl --rm-cache-dir')
|
||||
os.system('yt-dlp --rm-cache-dir')
|
||||
|
||||
# since youtube-dl updates so much check for updates
|
||||
# if not args.no_update:
|
||||
|
@ -116,7 +116,7 @@ def compress(name):
|
|||
|
||||
def checkSize(url):
|
||||
if args.check_size:
|
||||
ytdl = youtube_dl.YoutubeDL()
|
||||
ytdl = yt_dlp.YoutubeDL()
|
||||
info = ytdl.extract_info(url, download=False)
|
||||
max = 0
|
||||
maxBytes = args.max_size * 1000000
|
||||
|
@ -196,7 +196,8 @@ ydl_opts = {
|
|||
'allsubtitles': True,
|
||||
'logtostderr': True,
|
||||
'format': ytdlFormat,
|
||||
'outtmpl': 'downloads/\'%(title)s\' - (\'%(uploader)s\' - \'%(uploader_id)s\') - %(id)s',
|
||||
'outtmpl': 'downloads/%(title)s - (%(uploader)s, %(uploader_id)s) - %(id)s',
|
||||
# 'outtmpl': 'downloads/%(title)s',
|
||||
'postprocessors': [{
|
||||
'key': 'FFmpegMetadata',
|
||||
'key': 'EmbedThumbnail',
|
||||
|
@ -222,7 +223,7 @@ if not isURL:
|
|||
logger.info(x.strip('\n'))
|
||||
print(x.strip('\n'))
|
||||
else:
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
ydl.download([x])
|
||||
print()
|
||||
if args.playlists:
|
||||
|
@ -247,10 +248,10 @@ else:
|
|||
logger.info(x.strip('\n'))
|
||||
print(x.strip('\n'))
|
||||
else:
|
||||
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
try:
|
||||
ydl.download([x])
|
||||
except youtube_dl.utils.DownloadError as e:
|
||||
except Exception as e:
|
||||
print(e)
|
||||
print()
|
||||
else:
|
||||
|
|
Reference in New Issue