Merge branch 'master' of https://github.com/alexta69/metube into custom-download-folder

This commit is contained in:
Alex Shnitman 2022-09-30 09:09:41 +03:00
commit 68d4c89be0
5 changed files with 36 additions and 23 deletions

36
Pipfile.lock generated
View File

@ -204,11 +204,11 @@
}, },
"charset-normalizer": { "charset-normalizer": {
"hashes": [ "hashes": [
"sha256:5189b6f22b01957427f35b6a08d9a0bc45b46d3788ef5a92e978433c7a35f8a5", "sha256:5a3d016c7c547f69d6f81fb0db9449ce888b418b5b9952cc5e6e66843e9dd845",
"sha256:575e708016ff3a5e3681541cb9d79312c416835686d054a23accb873b254f413" "sha256:83e9a75d1911279afd89352c68b45348559d1fc0506b054b346651b5e7fee29f"
], ],
"markers": "python_version >= '3.6'", "markers": "python_version >= '3.6'",
"version": "==2.1.0" "version": "==2.1.1"
}, },
"frozenlist": { "frozenlist": {
"hashes": [ "hashes": [
@ -529,21 +529,21 @@
}, },
"yt-dlp": { "yt-dlp": {
"hashes": [ "hashes": [
"sha256:a01d3c7187683ec17db33ecd3b506436c7e94c5693002f059f76d32fb437083e", "sha256:af3721ecb286a95272008add3b9bebde4f370fb3bdd1bb6402727af9e2e3aa2b",
"sha256:cc290ac8a1fec626841765fed12f7a1ebdfe01791ae5c5f3794edfce35d81843" "sha256:bc74ee255790043e458197aaf25c6c104fefc9fcda4458f652619447ab4ae0d7"
], ],
"index": "pypi", "index": "pypi",
"version": "==2022.8.19" "version": "==2022.9.1"
} }
}, },
"develop": { "develop": {
"astroid": { "astroid": {
"hashes": [ "hashes": [
"sha256:86b0a340a512c65abf4368b80252754cda17c02cdbbd3f587dddf98112233e7b", "sha256:396c88d0a58d7f8daadf730b2ce90838bf338c6752558db719ec6f99c18ec20e",
"sha256:bb24615c77f4837c707669d16907331374ae8a964650a66999da3f5ca68dc946" "sha256:d612609242996c4365aeb0345e61edba34363eaaba55f1c0addf6a98f073bef6"
], ],
"markers": "python_full_version >= '3.6.2'", "markers": "python_full_version >= '3.7.2'",
"version": "==2.11.7" "version": "==2.12.5"
}, },
"dill": { "dill": {
"hashes": [ "hashes": [
@ -622,19 +622,11 @@
}, },
"pylint": { "pylint": {
"hashes": [ "hashes": [
"sha256:487ce2192eee48211269a0e976421f334cf94de1806ca9d0a99449adcdf0285e", "sha256:4b124affc198b7f7c9b5f9ab690d85db48282a025ef9333f51d2d7281b92a6c3",
"sha256:fabe30000de7d07636d2e82c9a518ad5ad7908590fe135ace169b44839c15f90" "sha256:4f3f7e869646b0bd63b3dfb79f3c0f28fc3d2d923ea220d52620fd625aed92b0"
], ],
"index": "pypi", "index": "pypi",
"version": "==2.14.5" "version": "==2.15.0"
},
"setuptools": {
"hashes": [
"sha256:10602cd0a6f5feab6656e9587f9075292ab777c5200f3bf00293ecd23d9f2788",
"sha256:d2e010624c781b26ad6629a8de9832327cf853dea93894487979e55f9ad06857"
],
"markers": "python_version >= '3.7'",
"version": "==65.1.0"
}, },
"tomli": { "tomli": {
"hashes": [ "hashes": [
@ -727,7 +719,7 @@
"sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015", "sha256:ee6acae74a2b91865910eef5e7de37dc6895ad96fa23603d1d27ea69df545015",
"sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af" "sha256:ef3f72c9666bba2bab70d2a8b79f2c6d2c1a42a7f7e2b0ec83bb2f9e383950af"
], ],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4'", "markers": "python_version < '3.11'",
"version": "==1.14.1" "version": "==1.14.1"
} }
} }

View File

@ -19,6 +19,10 @@ def get_format(format: str, quality: str) -> str:
if format.startswith("custom:"): if format.startswith("custom:"):
return format[7:] return format[7:]
if format == "thumbnail":
# Quality is irrelevant in this case since we skip the download
return "bestaudio/best"
if format == "mp3": if format == "mp3":
# Audio quality needs to be set post-download, set in opts # Audio quality needs to be set post-download, set in opts
return "bestaudio/best" return "bestaudio/best"
@ -66,4 +70,9 @@ def get_opts(format: str, quality: str, ytdl_opts: dict) -> dict:
opts["postprocessors"].append({"key": "FFmpegMetadata"}) opts["postprocessors"].append({"key": "FFmpegMetadata"})
opts["postprocessors"].append({"key": "EmbedThumbnail"}) opts["postprocessors"].append({"key": "EmbedThumbnail"})
if format == "thumbnail":
opts["skip_download"] = True
opts["writethumbnail"] = True
opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"})
return opts return opts

View File

@ -6,6 +6,7 @@ import time
import asyncio import asyncio
import multiprocessing import multiprocessing
import logging import logging
import re
from dl_formats import get_format, get_opts from dl_formats import get_format, get_opts
log = logging.getLogger('ytdl') log = logging.getLogger('ytdl')
@ -127,6 +128,10 @@ class Download:
self.tmpfilename = status.get('tmpfilename') self.tmpfilename = status.get('tmpfilename')
if 'filename' in status: if 'filename' in status:
self.info.filename = os.path.relpath(status.get('filename'), self.download_dir) self.info.filename = os.path.relpath(status.get('filename'), self.download_dir)
# Set correct file extension for thumbnails
if(self.info.format == 'thumbnail'):
self.info.filename = re.sub(r'\.webm$', '.jpg', self.info.filename)
self.info.status = status['status'] self.info.status = status['status']
self.info.msg = status.get('msg') self.info.msg = status.get('msg')
if 'downloaded_bytes' in status: if 'downloaded_bytes' in status:

View File

@ -26,7 +26,7 @@
<div class="container add-url-box"> <div class="container add-url-box">
<div class="row"> <div class="row">
<div class="col add-url-component input-group"> <div class="col add-url-component input-group">
<input type="text" class="form-control" placeholder="Video or playlist URL" name="addUrl" [(ngModel)]="addUrl" [disabled]="addInProgress || downloads.loading"> <input type="text" autocomplete="off" spellcheck="false" class="form-control" placeholder="Video or playlist URL" name="addUrl" [(ngModel)]="addUrl" [disabled]="addInProgress || downloads.loading">
</div> </div>
</div> </div>
<div class="row"> <div class="row">

View File

@ -43,4 +43,11 @@ export const Formats: Format[] = [
{ id: '128', text: '128 kbps' }, { id: '128', text: '128 kbps' },
], ],
}, },
{
id: 'thumbnail',
text: 'Thumbnail',
qualities: [
{ id: 'best', text: 'Best' }
],
},
]; ];