added convertion of the audio itself vie ffmpeg

This commit is contained in:
Hellow
2023-04-05 17:40:22 +02:00
parent 4efef86793
commit 36ee456612
6 changed files with 61 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
from typing import List
from typing import List, Set
import logging
import tempfile
import os
@@ -94,6 +94,28 @@ proxies = {
'https': 'socks5h://127.0.0.1:9150'
} if TOR else {}
# Only the formats with id3 metadata can be used
# https://www.audioranger.com/audio-formats.php
# https://web.archive.org/web/20230322234434/https://www.audioranger.com/audio-formats.php
ALLOWED_FILE_FORMATS: Set[str] = {
"mp3", "mp2", "mp1", # MPEG-1 ID3.2
"wav", "wave", "rmi", # RIFF (including WAV) ID3.2
"aiff", "aif", "aifc", # AIFF ID3.2
"aac", "aacp", # Raw AAC ID3.2
"tta", # True Audio ID3.2
"ape", # Monkey's Audio ID3.1
"mpc", "mpp", "mp+", # MusePack ID3.1
"wv", # WavPack ID3.1
"ofr", "ofs" # OptimFrog ID3.1
}
# kB per second
BITRATE = 125
AUDIO_FORMAT = "mp3"
if AUDIO_FORMAT not in ALLOWED_FILE_FORMATS:
raise ValueError(f"The Audio Format is not in {ALLOWED_FILE_FORMATS} ({AUDIO_FORMAT}).")
"""
available variables:
- genre
@@ -104,17 +126,17 @@ available variables:
- album_type
"""
DOWNLOAD_PATH = "{genre}/{artist}/{album_type}/{album}"
DOWNLOAD_FILE = "{song}.mp3"
DOWNLOAD_FILE = "{song}.{audio_format}"
DEFAULT_VALUES = {
"genre": "Various Genre",
"label": "Various Labels",
"artist": "Various Artists",
"album": "Various Album",
"song": "Various Song",
"album_type": "Other"
"album_type": "Other",
"audio_format": AUDIO_FORMAT
}
# kB per second
BITRATE = 100
# size of the chunks that are streamed
CHUNK_SIZE = 1024