finished audio config

This commit is contained in:
Hellow 2023-04-14 13:03:48 +02:00
parent d8c0cc288f
commit b07ea4aff0
3 changed files with 82 additions and 34 deletions

View File

@ -47,8 +47,8 @@ class AudioSection(Section):
self.AUDIO_FORMAT = AudioFormatAttribute(name="audio_format", value="mp3", description=f"""
Music Kraken will stream the audio into this format.
You can use Audio formats which support ID3.2 and ID3.1,\n
but you will have cleaner Metadata using ID3.2.\n
You can use Audio formats which support ID3.2 and ID3.1,
but you will have cleaner Metadata using ID3.2.
ID3.2: {', '.join(_sorted_id3_2_formats)}
ID3.1: {', '.join(_sorted_id3_1_formats)}
""".strip())
@ -65,9 +65,62 @@ ID3.1: {', '.join(_sorted_id3_1_formats)}
description="The filename of the audio file."
)
self.DEFAULT_GENRE = StringAttribute(
name="default_genre",
value="Various Genre",
description="The default value for the genre field."
)
self.DEFAULT_LABEL = StringAttribute(
name="default_label",
value="Various Labels",
description="The Label refers to a lable that signs artists."
)
self.DEFAULT_ARTIST = StringAttribute(
name="default_artist",
value="Various Artists",
description="You know Various Artist."
)
self.DEFAULT_ALBUM = StringAttribute(
name="default_album",
value="Various Album",
description="This value will hopefully not be used."
)
self.DEFAULT_SONG = StringAttribute(
name="default_song",
value="Various Song",
description="If it has to fall back to this value, something did go really wrong."
)
self.DEFAULT_ALBUM_TYPE = StringAttribute(
name="default_album_type",
value="Other",
description="Weirdly enough I barely see this used in file systems."
)
self.attribute_list = [
EmptyLine(),
self.BITRATE,
self.AUDIO_FORMAT
self.AUDIO_FORMAT,
Description("""
There are multiple fields, you can use for the path and file name:
- genre
- label
- artist
- album
- song
- album_type
""".strip()),
self.DOWNLOAD_PATH,
self.DOWNLOAD_FILE,
self.DEFAULT_ALBUM_TYPE,
self.DEFAULT_ARTIST,
self.DEFAULT_GENRE,
self.DEFAULT_LABEL,
self.DEFAULT_SONG
]

View File

@ -1,7 +1,7 @@
from dataclasses import dataclass
from typing import Optional, List, Union
COMMENT_PREFIX = "// "
COMMENT_PREFIX = "# "
@dataclass
@ -31,7 +31,7 @@ class SingleAttribute(Attribute):
class StringAttribute(SingleAttribute):
@property
def object_from_value(self) -> str:
return self.value
return self.value.strip()
class IntAttribute(SingleAttribute):
@ -42,6 +42,7 @@ class IntAttribute(SingleAttribute):
return int(self.value)
class FloatAttribute(SingleAttribute):
@property
def object_from_value(self) -> float:
@ -72,6 +73,9 @@ class EmptyLine(Description):
def __init__(self):
self.description = "\n"
def __str__(self):
return self.description
class Section:
"""

View File

@ -11,6 +11,9 @@ from .config import LOGGING_SECTION, AUDIO_SECTION
# https://web.archive.org/web/20221124122222/https://mkennedy.codes/posts/python-gc-settings-change-this-and-make-your-app-go-20pc-faster/
MODIFY_GC: bool = True
ID_BITS: int = 64
ID_RANGE: Tuple[int, int] = (0, int(2**ID_BITS))
"""
I will now and then use those messages in the programm.
But I won't overuse them dw.
@ -35,13 +38,14 @@ def get_random_message() -> str:
return random.choice(HAPPY_MESSAGES)
ID_BITS: int = 64
ID_RANGE: Tuple[int, int] = (0, int(2**ID_BITS))
TEMP_DIR = LOCATIONS.TEMP_DIRECTORY
LOG_PATH = LOCATIONS.get_log_file("download_logs.log")
MUSIC_DIR: Path = LOCATIONS.MUSIC_DIRECTORY
NOT_A_GENRE_REGEX: Tuple[str] = (
r'^\.', # is hidden/starts with a "."
)
# configure logger default
logging.basicConfig(
@ -69,9 +73,19 @@ CODEX_LOGGER = LOGGING_SECTION.CODEX_LOGGER.object_from_value
BITRATE = AUDIO_SECTION.BITRATE.object_from_value
AUDIO_FORMAT = AUDIO_SECTION.AUDIO_FORMAT.object_from_value
NOT_A_GENRE_REGEX: Tuple[str] = (
r'^\.', # is hidden/starts with a "."
)
DOWNLOAD_PATH = AUDIO_SECTION.DOWNLOAD_PATH.object_from_value
DOWNLOAD_FILE = AUDIO_SECTION.DOWNLOAD_FILE.object_from_value
DEFAULT_VALUES = {
"genre": AUDIO_SECTION.DEFAULT_GENRE.object_from_value,
"label": AUDIO_SECTION.DEFAULT_LABEL.object_from_value,
"artist": AUDIO_SECTION.DEFAULT_ARTIST.object_from_value,
"album": AUDIO_SECTION.DEFAULT_ALBUM.object_from_value,
"song": AUDIO_SECTION.DEFAULT_SONG.object_from_value,
"album_type": AUDIO_SECTION.DEFAULT_ALBUM_TYPE.object_from_value,
"audio_format": AUDIO_FORMAT
}
TOR: bool = False
proxies = {
@ -79,29 +93,6 @@ proxies = {
'https': 'socks5h://127.0.0.1:9150'
} if TOR else {}
"""
available variables:
- genre
- label
- artist
- album
- song
- album_type
"""
DOWNLOAD_PATH = AUDIO_SECTION.DOWNLOAD_PATH.object_from_value
DOWNLOAD_FILE = AUDIO_SECTION.DOWNLOAD_FILE.object_from_value
DEFAULT_VALUES = {
"genre": "Various Genre",
"label": "Various Labels",
"artist": "Various Artists",
"album": "Various Album",
"song": "Various Song",
"album_type": "Other",
"audio_format": AUDIO_FORMAT
}
# size of the chunks that are streamed
CHUNK_SIZE = 1024
# this is a percentage describing the percentage of failed downloads,