aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex <alexta69@gmail.com>2023-03-05 11:43:00 +0200
committerGitHub <noreply@github.com>2023-03-05 11:43:00 +0200
commitf1851bf4aa3b176139183d70841dc7986c02d796 (patch)
treeaf0b76527e8430283ccabf22db1862edd13801ac
parentupgraded yt-dlp (diff)
parentDefine the audio formats tuple in python backend (diff)
downloadmetube-f1851bf4aa3b176139183d70841dc7986c02d796.tar.gz
metube-f1851bf4aa3b176139183d70841dc7986c02d796.tar.bz2
metube-f1851bf4aa3b176139183d70841dc7986c02d796.zip
Merge pull request #230 from georgekav2/feature/add_vorbis_opus_wav
Add support for opus and wav
-rw-r--r--app/dl_formats.py16
-rw-r--r--app/ytdl.py4
-rw-r--r--ui/src/app/app.component.ts2
-rw-r--r--ui/src/app/formats.ts32
4 files changed, 36 insertions, 18 deletions
diff --git a/app/dl_formats.py b/app/dl_formats.py
index e2f6591..8de79e9 100644
--- a/app/dl_formats.py
+++ b/app/dl_formats.py
@@ -1,5 +1,7 @@
import copy
+AUDIO_FORMATS = ("m4a", "mp3", "opus", "wav")
+
def get_format(format: str, quality: str) -> str:
"""
Returns format for download
@@ -23,7 +25,7 @@ def get_format(format: str, quality: str) -> str:
# Quality is irrelevant in this case since we skip the download
return "bestaudio/best"
- if format in ("m4a", "mp3"):
+ if format in AUDIO_FORMATS:
# Audio quality needs to be set post-download, set in opts
return "bestaudio/best"
@@ -59,17 +61,19 @@ def get_opts(format: str, quality: str, ytdl_opts: dict) -> dict:
if "postprocessors" not in opts:
opts["postprocessors"] = []
- if format in ("m4a", "mp3"):
+ if format in AUDIO_FORMATS:
opts["postprocessors"].append({
"key": "FFmpegExtractAudio",
"preferredcodec": format,
"preferredquality": 0 if quality == "best" else quality,
})
- opts["writethumbnail"] = True
- opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"})
- opts["postprocessors"].append({"key": "FFmpegMetadata"})
- opts["postprocessors"].append({"key": "EmbedThumbnail"})
+ #Audio formats without thumbnail
+ if format not in ("wav"):
+ opts["writethumbnail"] = True
+ opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"})
+ opts["postprocessors"].append({"key": "FFmpegMetadata"})
+ opts["postprocessors"].append({"key": "EmbedThumbnail"})
if format == "thumbnail":
opts["skip_download"] = True
diff --git a/app/ytdl.py b/app/ytdl.py
index 3c21e0e..c001a16 100644
--- a/app/ytdl.py
+++ b/app/ytdl.py
@@ -7,7 +7,7 @@ import asyncio
import multiprocessing
import logging
import re
-from dl_formats import get_format, get_opts
+from dl_formats import get_format, get_opts, AUDIO_FORMATS
log = logging.getLogger('ytdl')
@@ -234,7 +234,7 @@ class DownloadQueue:
if not self.queue.exists(entry['id']):
dl = DownloadInfo(entry['id'], entry['title'], entry.get('webpage_url') or entry['url'], quality, format, folder)
# Keep consistent with frontend
- base_directory = self.config.DOWNLOAD_DIR if (quality != 'audio' and format not in ("m4a", "mp3")) else self.config.AUDIO_DOWNLOAD_DIR
+ base_directory = self.config.DOWNLOAD_DIR if (quality != 'audio' and format not in AUDIO_FORMATS) else self.config.AUDIO_DOWNLOAD_DIR
if folder:
if not self.config.CUSTOM_DIRS:
return {'status': 'error', 'msg': f'A folder for the download was specified but CUSTOM_DIRS is not true in the configuration.'}
diff --git a/ui/src/app/app.component.ts b/ui/src/app/app.component.ts
index 5cbb84c..5dbcd5b 100644
--- a/ui/src/app/app.component.ts
+++ b/ui/src/app/app.component.ts
@@ -94,7 +94,7 @@ export class AppComponent implements AfterViewInit {
}
isAudioType() {
- return this.quality == 'audio' || this.format == 'mp3' || this.format == 'm4a';
+ return this.quality == 'audio' || this.format == 'mp3' || this.format == 'm4a' || this.format == 'opus' || this.format == 'wav'
}
getMatchingCustomDir() : Observable<string[]> {
diff --git a/ui/src/app/formats.ts b/ui/src/app/formats.ts
index 7668e49..81afe86 100644
--- a/ui/src/app/formats.ts
+++ b/ui/src/app/formats.ts
@@ -23,15 +23,6 @@ export const Formats: Format[] = [
],
},
{
- id: 'm4a',
- text: 'M4A',
- qualities: [
- { id: 'best', text: 'Best' },
- { id: '192', text: '192 kbps' },
- { id: '128', text: '128 kbps' },
- ],
- },
- {
id: 'mp4',
text: 'MP4',
qualities: [
@@ -43,6 +34,15 @@ export const Formats: Format[] = [
],
},
{
+ id: 'm4a',
+ text: 'M4A',
+ qualities: [
+ { id: 'best', text: 'Best' },
+ { id: '192', text: '192 kbps' },
+ { id: '128', text: '128 kbps' },
+ ],
+ },
+ {
id: 'mp3',
text: 'MP3',
qualities: [
@@ -53,6 +53,20 @@ export const Formats: Format[] = [
],
},
{
+ id: 'opus',
+ text: 'OPUS',
+ qualities: [
+ { id: 'best', text: 'Best' },
+ ],
+ },
+ {
+ id: 'wav',
+ text: 'WAV',
+ qualities: [
+ { id: 'best', text: 'Best' },
+ ],
+ },
+ {
id: 'thumbnail',
text: 'Thumbnail',
qualities: [
bgstack15