aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorAlex Shnitman <alexta69@gmail.com>2021-08-17 23:53:49 +0300
committerAlex Shnitman <alexta69@gmail.com>2021-08-17 23:53:49 +0300
commit6e986a88ca8217e8546e8648a149e2be7aa087da (patch)
tree7808f3db734f04c013b686e10ee7b1abbbd1b0c9 /app
parentMerge pull request #38 from Rpsl/retry_button (diff)
downloadmetube-6e986a88ca8217e8546e8648a149e2be7aa087da.tar.gz
metube-6e986a88ca8217e8546e8648a149e2be7aa087da.tar.bz2
metube-6e986a88ca8217e8546e8648a149e2be7aa087da.zip
switched to the yt-dlp fork of youtube-dl (closes #41)
Diffstat (limited to 'app')
-rw-r--r--app/main.py2
-rw-r--r--app/ytdl.py24
2 files changed, 17 insertions, 9 deletions
diff --git a/app/main.py b/app/main.py
index dad19e3..d94967b 100644
--- a/app/main.py
+++ b/app/main.py
@@ -3,9 +3,7 @@
import os
from aiohttp import web
-import asyncio
import socketio
-import time
import logging
import json
diff --git a/app/ytdl.py b/app/ytdl.py
index 4475704..47cfdcd 100644
--- a/app/ytdl.py
+++ b/app/ytdl.py
@@ -1,6 +1,5 @@
import os
-import sys
-import youtube_dl
+import yt_dlp
from collections import OrderedDict
import asyncio
import multiprocessing
@@ -57,7 +56,18 @@ class Download:
def _download(self):
try:
- ret = youtube_dl.YoutubeDL(params={
+ def put_status(st):
+ self.status_queue.put({k: v for k, v in st.items() if k in (
+ 'tmpfilename',
+ 'status',
+ 'msg',
+ 'total_bytes',
+ 'total_bytes_estimate',
+ 'downloaded_bytes',
+ 'speed',
+ 'eta',
+ )})
+ ret = yt_dlp.YoutubeDL(params={
'quiet': True,
'no_color': True,
#'skip_download': True,
@@ -65,10 +75,10 @@ class Download:
'format': self.format,
'cachedir': False,
'socket_timeout': 30,
- 'progress_hooks': [lambda d: self.status_queue.put(d)],
+ 'progress_hooks': [put_status],
}).download([self.info.url])
self.status_queue.put({'status': 'finished' if ret == 0 else 'error'})
- except youtube_dl.utils.YoutubeDLError as exc:
+ except yt_dlp.utils.YoutubeDLError as exc:
self.status_queue.put({'status': 'error', 'msg': str(exc)})
async def start(self, notifier):
@@ -129,7 +139,7 @@ class DownloadQueue:
asyncio.ensure_future(self.__download())
def __extract_info(self, url):
- return youtube_dl.YoutubeDL(params={
+ return yt_dlp.YoutubeDL(params={
'quiet': True,
'no_color': True,
'extract_flat': True,
@@ -168,7 +178,7 @@ class DownloadQueue:
already.add(url)
try:
entry = await asyncio.get_running_loop().run_in_executor(None, self.__extract_info, url)
- except youtube_dl.utils.YoutubeDLError as exc:
+ except yt_dlp.utils.YoutubeDLError as exc:
return {'status': 'error', 'msg': str(exc)}
return await self.__add_entry(entry, quality, already)
bgstack15