(scdl_args: SCDLArgs, in_playlist: bool, force_suffix: str | None = None)
| 338 | |
| 339 | |
| 340 | def _build_ytdl_output_filename(scdl_args: SCDLArgs, in_playlist: bool, force_suffix: str | None = None) -> str: |
| 341 | if scdl_args.get("name_format") == "-": |
| 342 | return "-" |
| 343 | |
| 344 | playlist_format = "%(playlist|)s" |
| 345 | if in_playlist: |
| 346 | track_format = _convert_v2_name_format(scdl_args["playlist_name_format"]) |
| 347 | else: |
| 348 | track_format = _convert_v2_name_format(scdl_args["name_format"]) |
| 349 | |
| 350 | if scdl_args.get("addtimestamp") or scdl_args.get("addtofile"): |
| 351 | track_format = "%(title)s.%(ext)s" |
| 352 | if scdl_args.get("addtofile"): |
| 353 | track_format = "%(uploader)s - " + track_format |
| 354 | if scdl_args.get("addtimestamp"): |
| 355 | track_format = "%(timestamp)s_" + track_format |
| 356 | |
| 357 | base = scdl_args["path"] |
| 358 | if scdl_args.get("no_playlist_folder") or not in_playlist: |
| 359 | ret = base / track_format |
| 360 | else: |
| 361 | ret = base / playlist_format / track_format |
| 362 | |
| 363 | if force_suffix: |
| 364 | ret = ret.with_suffix(force_suffix) |
| 365 | |
| 366 | return ret.as_posix() |
| 367 | |
| 368 | |
| 369 | def _build_ytdl_format_specifier(scdl_args: SCDLArgs) -> str: |
no test coverage detected