mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 12:35:13 +00:00
refactor(api): give every served service its dl options from the run plan
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
import click
|
||||
import pytest
|
||||
@@ -16,7 +15,6 @@ from unshackle.core.dl_options import (
|
||||
DL_OPTIONS,
|
||||
FORWARDED_DL_PARAMS,
|
||||
cast_dl_params,
|
||||
forwarded_dl_params,
|
||||
remote_dl_params,
|
||||
)
|
||||
from unshackle.core.tracks import Audio, Subtitle, Video
|
||||
@@ -39,19 +37,6 @@ def test_the_openapi_yaml_names_each_api_dl_option_and_no_other():
|
||||
assert properties.keys() - DEFAULT_DOWNLOAD_PARAMS.keys() == {"service", "title_id", "remote", "client_name", "cdm"}
|
||||
|
||||
|
||||
def test_the_server_reads_back_what_a_remote_client_forwards():
|
||||
params = {
|
||||
"lang": ["orig", "es-419"],
|
||||
"v_lang": [],
|
||||
"a_lang": ["en"],
|
||||
"s_lang": ["all"],
|
||||
"acodec": [Audio.Codec.EC3],
|
||||
"forced_subs": True,
|
||||
"exact_lang": True,
|
||||
}
|
||||
assert forwarded_dl_params({"dl_params": remote_dl_params(params)}) == params
|
||||
|
||||
|
||||
def test_api_defaults_cast_to_the_dl_defaults():
|
||||
"""``wanted`` keeps its API default of no keys, which dl reads as every title, like the CLI's None."""
|
||||
ctx = click.Context(dl.cli)
|
||||
@@ -121,26 +106,6 @@ def test_every_dl_option_reaches_dl_result():
|
||||
}
|
||||
|
||||
|
||||
def test_the_server_reads_the_forwarded_dl_params(caplog):
|
||||
data = {
|
||||
"dl_params": {"a_lang": "x", "acodec": ["ddp", "NOPE"], "exact_lang": 1, "forced_subs": True, "lang": ["en"]}
|
||||
}
|
||||
with caplog.at_level(logging.WARNING, logger="api"):
|
||||
assert list(forwarded_dl_params(data).items()) == [
|
||||
("lang", ["en"]),
|
||||
("v_lang", []),
|
||||
("a_lang", []),
|
||||
("s_lang", ["all"]),
|
||||
("acodec", [Audio.Codec.EC3]),
|
||||
("forced_subs", True),
|
||||
("exact_lang", False),
|
||||
]
|
||||
assert [(r.name, r.getMessage()) for r in caplog.records] == [
|
||||
("api", "Ignoring dl_params.a_lang: it must be an array of strings"),
|
||||
("api", "Ignoring unknown dl_params.acodec value: NOPE"),
|
||||
]
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"parent_params,sent",
|
||||
[
|
||||
|
||||
Reference in New Issue
Block a user