Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix passing arguments to yt-dlp. #2250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions spotdl/utils/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
import pykakasi
from rapidfuzz import fuzz
from slugify import slugify as py_slugify
from yt_dlp.options import create_parser
from yt_dlp.options import optparse as yt_dlp_optparse
from yt_dlp import parse_options
from yt_dlp.utils import sanitize_filename

from spotdl.types.song import Song
Expand Down Expand Up @@ -70,7 +69,6 @@
)

DISALLOWED_REGEX = re.compile(r"[^-a-zA-Z0-9\!\@\$]+")
YT_DLP_PARSER = create_parser()

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -622,6 +620,17 @@ def args_to_ytdlp_options(
- the dictionary of options
"""

new_args = YT_DLP_PARSER.parse_args(argument_list, yt_dlp_optparse.Values(defaults))
parsed_options = parse_options(argument_list).ydl_opts

return vars(new_args[0])
if defaults is None:
return parsed_options

default_options = parse_options([]).ydl_opts

for key, value in defaults.items():
if key not in parsed_options:
parsed_options[key] = value
elif parsed_options[key] == default_options[key]:
parsed_options[key] = value

return parsed_options