Skip to content

Commit

Permalink
[BUGFIX] Fix playlists not downloading correctly
Browse files Browse the repository at this point in the history
Due to url ytdl-options not materializing
  • Loading branch information
jmbannon authored Oct 26, 2024
1 parent 7676fd9 commit 88110a8
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
12 changes: 12 additions & 0 deletions src/ytdl_sub/config/preset_options.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
from typing import Any
from typing import Dict
from typing import Optional

from ytdl_sub.config.defaults import DEFAULT_DOWNLOAD_ARCHIVE_NAME
from ytdl_sub.config.overrides import Overrides
from ytdl_sub.validators.file_path_validators import OverridesStringFormatterFilePathValidator
from ytdl_sub.validators.file_path_validators import StringFormatterFileNameValidator
from ytdl_sub.validators.strict_dict_validator import StrictDictValidator
Expand Down Expand Up @@ -48,6 +50,16 @@ class YTDLOptions(UnstructuredOverridesDictFormatterValidator):
where each key is a ytdl argument. Include in the example are some popular ytdl_options.
"""

def to_native_dict(self, overrides: Overrides) -> Dict:
"""
Materializes the entire ytdl-options dict from OverrideStringFormatters into
native python
"""
return {
key: overrides.apply_overrides_formatter_to_native(val)
for key, val in self.dict.items()
}


# Disable for proper docstring formatting
# pylint: disable=line-too-long
Expand Down
2 changes: 1 addition & 1 deletion src/ytdl_sub/downloaders/url/downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ def _iterate_entries(

def _download_metadata(self, url: str, validator: UrlValidator) -> Iterable[Entry]:
metadata_ytdl_options = self.metadata_ytdl_options(
ytdl_option_overrides=validator.ytdl_options.dict
ytdl_option_overrides=validator.ytdl_options.to_native_dict(self.overrides)
)
download_reversed = ScriptUtils.bool_formatter_output(
self.overrides.apply_formatter(validator.download_reverse)
Expand Down
6 changes: 1 addition & 5 deletions src/ytdl_sub/subscriptions/subscription_ytdl_options.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,7 @@ def _plugin_ytdl_options(self, plugin: Type[PluginT]) -> Dict:

@property
def _user_ytdl_options(self) -> Dict:
native_ytdl_options = {
key: self._overrides.apply_overrides_formatter_to_native(val)
for key, val in self._preset.ytdl_options.dict.items()
}
return native_ytdl_options
return self._preset.ytdl_options.to_native_dict(self._overrides)

@property
def _plugin_match_filters(self) -> Dict:
Expand Down

0 comments on commit 88110a8

Please sign in to comment.