added another setting
This commit is contained in:
parent
3edc4e46f2
commit
984f5335bb
@ -7,8 +7,11 @@ from .base_classes import (
|
|||||||
Section,
|
Section,
|
||||||
Description,
|
Description,
|
||||||
EmptyLine,
|
EmptyLine,
|
||||||
BoolAttribute
|
BoolAttribute,
|
||||||
|
ListAttribute
|
||||||
)
|
)
|
||||||
|
from ...utils.enums.album import AlbumType
|
||||||
|
from ...utils.exception.config import SettingValueError
|
||||||
|
|
||||||
# Only the formats with id3 metadata can be used
|
# Only the formats with id3 metadata can be used
|
||||||
# https://www.audioranger.com/audio-formats.php
|
# https://www.audioranger.com/audio-formats.php
|
||||||
@ -32,6 +35,15 @@ _sorted_id3_1_formats = sorted(ID3_1_FILE_FORMATS)
|
|||||||
|
|
||||||
|
|
||||||
class AudioFormatAttribute(SingleAttribute):
|
class AudioFormatAttribute(SingleAttribute):
|
||||||
|
def validate(self, value: str):
|
||||||
|
v = self.value.strip().lower()
|
||||||
|
if v not in ID3_1_FILE_FORMATS and v not in ID3_2_FILE_FORMATS:
|
||||||
|
raise SettingValueError(
|
||||||
|
setting_name=self.name,
|
||||||
|
setting_value=value,
|
||||||
|
rule="has to be a valid audio format, supporting id3 metadata"
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def object_from_value(self) -> str:
|
def object_from_value(self) -> str:
|
||||||
v = self.value.strip().lower()
|
v = self.value.strip().lower()
|
||||||
@ -44,6 +56,21 @@ class AudioFormatAttribute(SingleAttribute):
|
|||||||
raise ValueError(f"Invalid Audio Format: {v}")
|
raise ValueError(f"Invalid Audio Format: {v}")
|
||||||
|
|
||||||
|
|
||||||
|
class AlbumTypeListAttribute(ListAttribute):
|
||||||
|
def validate(self, value: str):
|
||||||
|
try:
|
||||||
|
AlbumType(value.strip())
|
||||||
|
except ValueError:
|
||||||
|
raise SettingValueError(
|
||||||
|
setting_name=self.name,
|
||||||
|
setting_value=value,
|
||||||
|
rule="has to be an existing album type"
|
||||||
|
)
|
||||||
|
|
||||||
|
def single_object_from_element(self, value: str) -> AlbumType:
|
||||||
|
return AlbumType(value)
|
||||||
|
|
||||||
|
|
||||||
class AudioSection(Section):
|
class AudioSection(Section):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.BITRATE = FloatAttribute(
|
self.BITRATE = FloatAttribute(
|
||||||
@ -124,6 +151,18 @@ ID3.1: {', '.join(_sorted_id3_1_formats)}
|
|||||||
value="Other",
|
value="Other",
|
||||||
description="Weirdly enough I barely see this used in file systems."
|
description="Weirdly enough I barely see this used in file systems."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
self.ALBUM_TYPE_BLACKLIST = AlbumTypeListAttribute(
|
||||||
|
name="album_type_blacklist",
|
||||||
|
description="Music Kraken ignores all albums of those types.\n"
|
||||||
|
"Following album types exist in the programm:\n"
|
||||||
|
f"{', '.join(album.value for album in AlbumType)}",
|
||||||
|
value=[
|
||||||
|
AlbumType.COMPILATION_ALBUM.value,
|
||||||
|
AlbumType.LIVE_ALBUM.value,
|
||||||
|
AlbumType.MIXTAPE.value
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
self.attribute_list = [
|
self.attribute_list = [
|
||||||
self.BITRATE,
|
self.BITRATE,
|
||||||
@ -146,7 +185,8 @@ There are multiple fields, you can use for the path and file name:
|
|||||||
self.DEFAULT_ARTIST,
|
self.DEFAULT_ARTIST,
|
||||||
self.DEFAULT_GENRE,
|
self.DEFAULT_GENRE,
|
||||||
self.DEFAULT_LABEL,
|
self.DEFAULT_LABEL,
|
||||||
self.DEFAULT_SONG
|
self.DEFAULT_SONG,
|
||||||
|
self.ALBUM_TYPE_BLACKLIST,
|
||||||
]
|
]
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from typing import List, Tuple
|
|||||||
|
|
||||||
from .path_manager import LOCATIONS
|
from .path_manager import LOCATIONS
|
||||||
from .config import LOGGING_SECTION, AUDIO_SECTION, CONNECTION_SECTION, MISC_SECTION, PATHS_SECTION
|
from .config import LOGGING_SECTION, AUDIO_SECTION, CONNECTION_SECTION, MISC_SECTION, PATHS_SECTION
|
||||||
|
from .enums.album import AlbumType
|
||||||
|
|
||||||
CONFIG_FILE = LOCATIONS.CONFIG_FILE
|
CONFIG_FILE = LOCATIONS.CONFIG_FILE
|
||||||
|
|
||||||
@ -100,3 +100,9 @@ SHOW_DOWNLOAD_ERRORS_THRESHOLD = CONNECTION_SECTION.SHOW_DOWNLOAD_ERRORS_THRESHO
|
|||||||
|
|
||||||
SORT_BY_DATE = AUDIO_SECTION.SORT_BY_DATE.object_from_value
|
SORT_BY_DATE = AUDIO_SECTION.SORT_BY_DATE.object_from_value
|
||||||
SORT_BY_ALBUM_TYPE = AUDIO_SECTION.SORT_BY_ALBUM_TYPE.object_from_value
|
SORT_BY_ALBUM_TYPE = AUDIO_SECTION.SORT_BY_ALBUM_TYPE.object_from_value
|
||||||
|
|
||||||
|
ALBUM_TYPE_BLACKLIST: List[AlbumType] = [
|
||||||
|
AlbumType.COMPILATION_ALBUM,
|
||||||
|
AlbumType.MIXTAPE,
|
||||||
|
AlbumType.LIVE_ALBUM
|
||||||
|
]
|
||||||
|
Loading…
Reference in New Issue
Block a user