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

-o "%(duration>%H:%M:%S)s" is sanitized to 01_16_58 while -o "%(duration>%H: %M: %S)s" is sanitized to 01: 16: 58 #9964

Open
6 of 9 tasks
DavidPesticcio opened this issue May 19, 2024 · 6 comments
Labels
bug Bug that is not site-specific triage Untriaged issue

Comments

@DavidPesticcio
Copy link

DavidPesticcio commented May 19, 2024

EDIT: see #9964 (comment)

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

  • I understand that I will be blocked if I intentionally remove or skip any mandatory* field

Checklist

Please make sure the question is worded well enough to be understood

My question: Is this expected behaviour, or a bug?

If I put a space or other character before, or after, the colon : then I get a colon in the filename, otherwise I either get an underscore _ or NA depending on whether I use duration or duration_string respectively... 😿

Provide verbose output that clearly demonstrates the problem

  • Run your yt-dlp command with -vU flag added (yt-dlp -vU <your command line>)
  • If using API, add 'verbose': True to YoutubeDL params instead
  • Copy the WHOLE output (starting with [debug] Command-line config) and insert it below

Complete Verbose Output

Even after updating the behaviour still exists.

$ yt-dlp -vU
[debug] Command-line config: ['-vU']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version stable@2024.03.10 from yt-dlp/yt-dlp [615a84447] (zip)
[debug] Python 3.10.12 (CPython x86_64 64bit) - Linux-5.15.0-106-generic-x86_64-with-glibc2.35 (OpenSSL 3.0.2 15 Mar 2022, glibc 2.35)
[debug] exe versions: ffmpeg 4.4.2 (setts), ffprobe 4.4.2
[debug] Optional libraries: Cryptodome-3.11.0, brotli-1.0.9, certifi-2020.06.20, mutagen-1.45.1, requests-2.25.1, secretstorage-3.3.1, sqlite3-3.37.2, urllib3-1.26.5
[debug] Proxy map: {}
[debug] Request Handlers: urllib
[debug] Loaded 1803 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp/releases/latest
[debug] Downloading _update_spec from https://github.com/yt-dlp/yt-dlp/releases/latest/download/_update_spec
[debug] Downloading SHA2-256SUMS from https://github.com/yt-dlp/yt-dlp/releases/download/2024.04.09/SHA2-256SUMS
Current version: stable@2024.03.10 from yt-dlp/yt-dlp
Latest version: stable@2024.04.09 from yt-dlp/yt-dlp
Current Build Hash: 5576348930e44102add235c0a032e766f416a507db1dd2c75da833ff21e9fb6c
Updating to stable@2024.04.09 from yt-dlp/yt-dlp ...
[debug] Downloading yt-dlp from https://github.com/yt-dlp/yt-dlp/releases/download/2024.04.09/yt-dlp
Updated yt-dlp to stable@2024.04.09 from yt-dlp/yt-dlp
@DavidPesticcio DavidPesticcio added the question Question label May 19, 2024
@bashonly
Copy link
Member

bashonly commented May 19, 2024

duration is a numeric value (seconds) that can be interpreted by Python as a represenation of time and therefore formatted with a string template. duration_string has already been formatted with a string template. If duration_string is present in the metadata, then duration will be too, so why not just use duration?

@DavidPesticcio
Copy link
Author

Okay, so I've just gone through what I thought I had already done earlier and see that applying >%H:%M:%S to duration_string is indeed wrong and only works as I need for duration

My confusion was that while duration_string contains colons, I need it zero padded, which I presume is not an option, and certainly not possible by applying a format.

Using %(duration>%H:%M:%S)s is giving the desired zero padded output.

Although, while investigating with --print it all looks fine, but as soon as I use -o for constructing the filename, and use --print to show me the result, I get underscore _ instead of a colon : in the filename - for the same formatting. 🫤

Here's a stripped down version of my yt-dlp options that highlights what I mean.

Is this expected behaviour? Or am I going crazy! 😄

$ yt-dlp --print "%(upload_date>%Y-%m-%d)s [%(duration>%H:%M:%S)s] - filename %(filename)s" -o "%(upload_date>%Y-%m-%d)s [%(duration>%H:%M:%S)s]" https://youtube.com/playlist?list=PL0vfts4VzfNjQOM9VClyL5R0LeuTxlAR3
WARNING: [youtube:tab] Incomplete data received. Retrying (1/3)...
WARNING: [youtube:tab] Incomplete data received. Retrying (2/3)...
WARNING: [youtube:tab] Incomplete data received. Retrying (3/3)...
WARNING: [youtube:tab] Incomplete data received. Giving up after 3 retries
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "rIrNIzy6U_g")
2024-03-12 [00:08:28] - filename 2024-03-12 [00_08_28]
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "r5NQecwZs1A")
2023-08-26 [00:08:25] - filename 2023-08-26 [00_08_25]
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "lkIFF4maKMU")
^C
ERROR: Interrupted by user

@bashonly
Copy link
Member

On Windows, filenames cannot contain :, so yt-dlp sanitizes the filename by converting : to _. You could use a unicode full-width colon, e.g. "%(duration>%H:%M:%S)s"

@DavidPesticcio
Copy link
Author

I'm doing all this on Linux, and if I put a space either side of the colon, or any other regular character, including another colon, in the -o I get a unicode full-width colon in the filename by the look of it - but not if it's flanked by %H and co directly... 🤷

Seems like that might be a bug... 🫤

$ yt-dlp --print "%(upload_date>%Y-%m-%d)s [%(duration>%H:%M:%S)s] - filename %(filename)s" --playlist-reverse --embed-thumbnail --add-metadata -o "%(upload_date>%Y-%m-%d)s [%(duration>%H:%Hx:%M :%S: %S::)s]" https://youtube.com/playlist?list=PL0vfts4VzfNjQOM9VClyL5R0LeuTxlAR3
WARNING: [youtube:tab] Incomplete data received. Retrying (1/3)...
WARNING: [youtube:tab] Incomplete data received. Retrying (2/3)...
WARNING: [youtube:tab] Incomplete data received. Retrying (3/3)...
WARNING: [youtube:tab] Incomplete data received. Giving up after 3 retries
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "rIrNIzy6U_g")
2024-03-12 [00:08:28] - filename 2024-03-12 [00_00x:08 :28: 28::]
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "r5NQecwZs1A")
2023-08-26 [00:08:25] - filename 2023-08-26 [00_00x:08 :25: 25::]
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "lkIFF4maKMU")
^C
ERROR: Interrupted by user

@bashonly bashonly changed the title Why does -o "%(duration>%H:%M:%S)s" produce 01_16_58 while -o "%(duration_string>%H:%M:%S)s" produces NA instead of both producing 01:16:58 -o "%(duration>%H:%M:%S)s" is sanitized to 01_16_58 while -o "%(duration>%H: %M: %S)s" is sanitized to 01: 16: 58 May 19, 2024
@bashonly bashonly added bug Bug that is not site-specific triage Untriaged issue and removed question Question labels May 19, 2024
@DavidPesticcio
Copy link
Author

Additionally, as a workaround to get the desired format, I am using the following -o template to get a normal colon in the filename. Please don't break that, that's exactly what I need/want... 😄 lol

"[%(duration>%H)s:%(duration>%M)s:%(duration>%S)s]"

So it seems like the issue is isolated to whatever is used to parse %() sections.

Any presence of a colon elsewhere, for me, like the "%(title)", does seem to get converted to a unicode full-width colon. Which for Linux isn't strictly necessary.

@bashonly
Copy link
Member

Which for Linux isn't strictly necessary.

see #9591 for that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is not site-specific triage Untriaged issue
Projects
None yet
Development

No branches or pull requests

2 participants