Add support for opus and wav
This commit is contained in:
parent
5a7f13b78a
commit
eca44aa950
|
|
@ -23,7 +23,7 @@ def get_format(format: str, quality: str) -> str:
|
||||||
# Quality is irrelevant in this case since we skip the download
|
# Quality is irrelevant in this case since we skip the download
|
||||||
return "bestaudio/best"
|
return "bestaudio/best"
|
||||||
|
|
||||||
if format in ("m4a", "mp3"):
|
if format in ("m4a", "mp3", "opus", "wav"):
|
||||||
# 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"
|
||||||
|
|
||||||
|
|
@ -59,17 +59,17 @@ def get_opts(format: str, quality: str, ytdl_opts: dict) -> dict:
|
||||||
if "postprocessors" not in opts:
|
if "postprocessors" not in opts:
|
||||||
opts["postprocessors"] = []
|
opts["postprocessors"] = []
|
||||||
|
|
||||||
if format in ("m4a", "mp3"):
|
if format in ("m4a", "mp3", "opus", "wav"):
|
||||||
opts["postprocessors"].append({
|
opts["postprocessors"].append({
|
||||||
"key": "FFmpegExtractAudio",
|
"key": "FFmpegExtractAudio",
|
||||||
"preferredcodec": format,
|
"preferredcodec": format,
|
||||||
"preferredquality": 0 if quality == "best" else quality,
|
"preferredquality": 0 if quality == "best" else quality,
|
||||||
})
|
})
|
||||||
|
if format not in ("wav"):
|
||||||
opts["writethumbnail"] = True
|
opts["writethumbnail"] = True
|
||||||
opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"})
|
opts["postprocessors"].append({"key": "FFmpegThumbnailsConvertor", "format": "jpg", "when": "before_dl"})
|
||||||
opts["postprocessors"].append({"key": "FFmpegMetadata"})
|
opts["postprocessors"].append({"key": "FFmpegMetadata"})
|
||||||
opts["postprocessors"].append({"key": "EmbedThumbnail"})
|
opts["postprocessors"].append({"key": "EmbedThumbnail"})
|
||||||
|
|
||||||
if format == "thumbnail":
|
if format == "thumbnail":
|
||||||
opts["skip_download"] = True
|
opts["skip_download"] = True
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ class DownloadQueue:
|
||||||
if not self.queue.exists(entry['id']):
|
if not self.queue.exists(entry['id']):
|
||||||
dl = DownloadInfo(entry['id'], entry['title'], entry.get('webpage_url') or entry['url'], quality, format, folder)
|
dl = DownloadInfo(entry['id'], entry['title'], entry.get('webpage_url') or entry['url'], quality, format, folder)
|
||||||
# Keep consistent with frontend
|
# 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 ("m4a", "mp3", "opus", "wav")) else self.config.AUDIO_DOWNLOAD_DIR
|
||||||
if folder:
|
if folder:
|
||||||
if not self.config.CUSTOM_DIRS:
|
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.'}
|
return {'status': 'error', 'msg': f'A folder for the download was specified but CUSTOM_DIRS is not true in the configuration.'}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ export class AppComponent implements AfterViewInit {
|
||||||
}
|
}
|
||||||
|
|
||||||
isAudioType() {
|
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[]> {
|
getMatchingCustomDir() : Observable<string[]> {
|
||||||
|
|
|
||||||
|
|
@ -22,15 +22,6 @@ export const Formats: Format[] = [
|
||||||
{ id: 'audio', text: 'Audio Only' },
|
{ id: 'audio', text: 'Audio Only' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'm4a',
|
|
||||||
text: 'M4A',
|
|
||||||
qualities: [
|
|
||||||
{ id: 'best', text: 'Best' },
|
|
||||||
{ id: '192', text: '192 kbps' },
|
|
||||||
{ id: '128', text: '128 kbps' },
|
|
||||||
],
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'mp4',
|
id: 'mp4',
|
||||||
text: 'MP4',
|
text: 'MP4',
|
||||||
|
|
@ -42,6 +33,15 @@ export const Formats: Format[] = [
|
||||||
{ id: '480', text: '480p' },
|
{ id: '480', text: '480p' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'm4a',
|
||||||
|
text: 'M4A',
|
||||||
|
qualities: [
|
||||||
|
{ id: 'best', text: 'Best' },
|
||||||
|
{ id: '192', text: '192 kbps' },
|
||||||
|
{ id: '128', text: '128 kbps' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'mp3',
|
id: 'mp3',
|
||||||
text: 'MP3',
|
text: 'MP3',
|
||||||
|
|
@ -52,6 +52,20 @@ export const Formats: Format[] = [
|
||||||
{ id: '128', text: '128 kbps' },
|
{ id: '128', text: '128 kbps' },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'opus',
|
||||||
|
text: 'OPUS',
|
||||||
|
qualities: [
|
||||||
|
{ id: 'best', text: 'Best' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 'wav',
|
||||||
|
text: 'WAV',
|
||||||
|
qualities: [
|
||||||
|
{ id: 'best', text: 'Best' },
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'thumbnail',
|
id: 'thumbnail',
|
||||||
text: 'Thumbnail',
|
text: 'Thumbnail',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue