convert variable in main() to lowercase

This commit is contained in:
Etienne Zind 2022-12-06 09:18:48 +01:00
parent d908e4f15b
commit 6401c25205
1 changed files with 14 additions and 14 deletions

View File

@ -118,38 +118,38 @@ def write_subtitles(m3u8_url, base_name):
def main():
"""CLI function, options passed as arguments."""
(UI_LANG, _, STREAM_ID, SLUG) = urlparse(sys.argv[1]).path[1:-1].split("/")
VERSION = " ".join(sys.argv[2:])
(ui_lang, _, stream_id, _slug) = urlparse(sys.argv[1]).path[1:-1].split("/")
version = " ".join(sys.argv[2:])
if UI_LANG not in ("fr", "de", "en", "es", "pl", "it") or _ != "videos":
if ui_lang not in ("fr", "de", "en", "es", "pl", "it") or _ != "videos":
raise ValueError("Invalid URL")
CONFIG = api_config(UI_LANG, STREAM_ID)
TITLE = CONFIG.title
VERSIONS = CONFIG.versions
config = api_config(ui_lang, stream_id)
title = config.title
versions = config.versions
FILENAME = TITLE.replace("/", "-")
filename = title.replace("/", "-")
if VERSION not in VERSIONS:
print(TITLE)
for v, (_, l) in VERSIONS.items():
if version not in versions:
print(title)
for v, (_, l) in versions.items():
print(f"\t{v} : {l}")
exit(1)
M3U8_URL, VERSION_NAME = VERSIONS[VERSION]
m3u8_url, _version_name = versions[version]
write_subtitles(M3U8_URL, FILENAME)
write_subtitles(m3u8_url, filename)
subprocess.run(
[
FFMPEG,
"-i",
M3U8_URL,
m3u8_url,
"-c",
"copy",
"-bsf:a",
"aac_adtstoasc",
f"{FILENAME}.mp4",
f"{filename}.mp4",
]
)