linting
This commit is contained in:
parent
14d8440ee7
commit
b225461339
7 changed files with 20 additions and 23 deletions
|
|
@ -58,5 +58,5 @@ class SoundcloudAlbumsAndSinglesSubscription(SoundcloudSubscription):
|
||||||
if not any(album.contains(track) for album in albums)
|
if not any(album.contains(track) for album in albums)
|
||||||
]
|
]
|
||||||
|
|
||||||
for e in tracks:
|
for entry in tracks:
|
||||||
self.post_process_entry(e)
|
self.post_process_entry(entry)
|
||||||
|
|
|
||||||
|
|
@ -30,8 +30,6 @@ DOWNLOADER_T = TypeVar("DOWNLOADER_T", bound=Downloader)
|
||||||
|
|
||||||
|
|
||||||
class Subscription(object):
|
class Subscription(object):
|
||||||
SOURCE_T = TypeVar("SOURCE_T", bound=SourceValidator)
|
|
||||||
|
|
||||||
source_validator_type: Type[SOURCE_T]
|
source_validator_type: Type[SOURCE_T]
|
||||||
download_strategy_type: Type[DOWNLOAD_STRATEGY_T]
|
download_strategy_type: Type[DOWNLOAD_STRATEGY_T]
|
||||||
downloader_type: Type[Downloader]
|
downloader_type: Type[Downloader]
|
||||||
|
|
@ -96,14 +94,14 @@ class Subscription(object):
|
||||||
|
|
||||||
def _post_process_tagging(self, entry: Entry):
|
def _post_process_tagging(self, entry: Entry):
|
||||||
id3_options = self.metadata_options.id3
|
id3_options = self.metadata_options.id3
|
||||||
t = music_tag.load_file(
|
audio_file = music_tag.load_file(
|
||||||
entry.file_path(relative_directory=self.working_directory)
|
entry.file_path(relative_directory=self.working_directory)
|
||||||
)
|
)
|
||||||
for tag, tag_formatter in id3_options.tags.dict.items():
|
for tag, tag_formatter in id3_options.tags.dict.items():
|
||||||
t[tag] = entry.apply_formatter(
|
audio_file[tag] = entry.apply_formatter(
|
||||||
format_string=tag_formatter, overrides=self.overrides.dict
|
format_string=tag_formatter, overrides=self.overrides.dict
|
||||||
)
|
)
|
||||||
t.save()
|
audio_file.save()
|
||||||
|
|
||||||
def _post_process_nfo(self, entry):
|
def _post_process_nfo(self, entry):
|
||||||
nfo = {}
|
nfo = {}
|
||||||
|
|
@ -128,14 +126,14 @@ class Subscription(object):
|
||||||
nfo_file_path = Path(self.output_options.output_directory.value) / Path(
|
nfo_file_path = Path(self.output_options.output_directory.value) / Path(
|
||||||
nfo_file_name
|
nfo_file_name
|
||||||
)
|
)
|
||||||
with open(nfo_file_path, "wb") as f:
|
with open(nfo_file_path, "wb") as nfo_file:
|
||||||
f.write(xml)
|
nfo_file.write(xml)
|
||||||
|
|
||||||
def extract_info(self):
|
def extract_info(self):
|
||||||
"""
|
"""
|
||||||
Extracts only the info of the source, does not download it
|
Extracts only the info of the source, does not download it
|
||||||
"""
|
"""
|
||||||
raise NotImplemented("Each source needs to implement how it extracts info")
|
raise NotImplementedError("Each source needs to implement how it extracts info")
|
||||||
|
|
||||||
def post_process_entry(self, entry: Entry):
|
def post_process_entry(self, entry: Entry):
|
||||||
if self.metadata_options.id3:
|
if self.metadata_options.id3:
|
||||||
|
|
@ -176,8 +174,8 @@ class Subscription(object):
|
||||||
# If the thumbnail is to be converted, then save the converted thumbnail to the
|
# If the thumbnail is to be converted, then save the converted thumbnail to the
|
||||||
# output filepath
|
# output filepath
|
||||||
if self.output_options.convert_thumbnail:
|
if self.output_options.convert_thumbnail:
|
||||||
im = Image.open(source_thumbnail_path).convert("RGB")
|
image = Image.open(source_thumbnail_path).convert("RGB")
|
||||||
im.save(
|
image.save(
|
||||||
fp=output_thumbnail_path,
|
fp=output_thumbnail_path,
|
||||||
format=self.output_options.convert_thumbnail.value,
|
format=self.output_options.convert_thumbnail.value,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -33,5 +33,5 @@ class YoutubePlaylistSubscription(YoutubeSubscription):
|
||||||
playlist_id=self.download_strategy_options.playlist_id.value
|
playlist_id=self.download_strategy_options.playlist_id.value
|
||||||
)
|
)
|
||||||
|
|
||||||
for e in entries:
|
for entry in entries:
|
||||||
self.post_process_entry(e)
|
self.post_process_entry(entry)
|
||||||
|
|
|
||||||
|
|
@ -184,8 +184,10 @@ class LiteralDictValidator(DictValidator):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def dict(self) -> Dict:
|
def dict(self) -> Dict:
|
||||||
|
"""Returns the entire dict"""
|
||||||
return super()._dict
|
return super()._dict
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def keys(self) -> List[str]:
|
def keys(self) -> List[str]:
|
||||||
|
"""Returns a sorted list of the dict's keys"""
|
||||||
return super()._keys
|
return super()._keys
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
from ytdl_subscribe.validators.base.strict_dict_validator import StrictDictValidator
|
from ytdl_subscribe.validators.base.strict_dict_validator import StrictDictValidator
|
||||||
from ytdl_subscribe.validators.base.validators import DictValidator
|
|
||||||
from ytdl_subscribe.validators.base.validators import LiteralDictValidator
|
from ytdl_subscribe.validators.base.validators import LiteralDictValidator
|
||||||
from ytdl_subscribe.validators.base.validators import StringValidator
|
from ytdl_subscribe.validators.base.validators import StringValidator
|
||||||
|
|
||||||
|
|
||||||
class ConfigOptionsValidator(StrictDictValidator):
|
class ConfigOptionsValidator(StrictDictValidator):
|
||||||
|
"""Validation for the config options"""
|
||||||
|
|
||||||
_required_keys = {"working_directory"}
|
_required_keys = {"working_directory"}
|
||||||
|
|
||||||
def __init__(self, name: str, value: Any):
|
def __init__(self, name: str, value: Any):
|
||||||
|
|
@ -23,8 +23,6 @@ class ConfigOptionsValidator(StrictDictValidator):
|
||||||
class ConfigPresetsValidator(LiteralDictValidator):
|
class ConfigPresetsValidator(LiteralDictValidator):
|
||||||
"""Shallow validator checking for the presets dict in the config"""
|
"""Shallow validator checking for the presets dict in the config"""
|
||||||
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
class ConfigFileValidator(StrictDictValidator):
|
class ConfigFileValidator(StrictDictValidator):
|
||||||
_required_keys = {"configuration", "presets"}
|
_required_keys = {"configuration", "presets"}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
from typing import Optional
|
|
||||||
|
|
||||||
from ytdl_subscribe.validators.base.strict_dict_validator import StrictDictValidator
|
from ytdl_subscribe.validators.base.strict_dict_validator import StrictDictValidator
|
||||||
from ytdl_subscribe.validators.base.string_formatter_validator import (
|
from ytdl_subscribe.validators.base.string_formatter_validator import (
|
||||||
StringFormatterValidator,
|
StringFormatterValidator,
|
||||||
|
|
@ -8,10 +6,14 @@ from ytdl_subscribe.validators.base.string_select_validator import StringSelectV
|
||||||
|
|
||||||
|
|
||||||
class ConvertThumbnailValidator(StringSelectValidator):
|
class ConvertThumbnailValidator(StringSelectValidator):
|
||||||
|
"""Valid image types that thumbnails can be converted to"""
|
||||||
|
|
||||||
_select_values = {"jpeg"}
|
_select_values = {"jpeg"}
|
||||||
|
|
||||||
|
|
||||||
class OutputOptionsValidator(StrictDictValidator):
|
class OutputOptionsValidator(StrictDictValidator):
|
||||||
|
"""Where to output the final files and thumbnails"""
|
||||||
|
|
||||||
_required_keys = {"output_directory", "file_name"}
|
_required_keys = {"output_directory", "file_name"}
|
||||||
_optional_keys = {"convert_thumbnail", "thumbnail_name"}
|
_optional_keys = {"convert_thumbnail", "thumbnail_name"}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,7 @@
|
||||||
import copy
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Tuple
|
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
import sanitize_filename
|
import sanitize_filename
|
||||||
|
|
@ -12,7 +10,6 @@ from ytdl_subscribe.validators.base.strict_dict_validator import StrictDictValid
|
||||||
from ytdl_subscribe.validators.base.string_formatter_validator import (
|
from ytdl_subscribe.validators.base.string_formatter_validator import (
|
||||||
DictFormatterValidator,
|
DictFormatterValidator,
|
||||||
)
|
)
|
||||||
from ytdl_subscribe.validators.base.validators import DictValidator
|
|
||||||
from ytdl_subscribe.validators.base.validators import LiteralDictValidator
|
from ytdl_subscribe.validators.base.validators import LiteralDictValidator
|
||||||
from ytdl_subscribe.validators.config.metadata_options.metadata_options_validator import (
|
from ytdl_subscribe.validators.config.metadata_options.metadata_options_validator import (
|
||||||
MetadataOptionsValidator,
|
MetadataOptionsValidator,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue