Giter Site home page Giter Site logo

`-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` about yt-dlp HOT 6 OPEN

DavidPesticcio avatar DavidPesticcio commented on June 15, 2024
`-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`

from yt-dlp.

Comments (6)

DavidPesticcio avatar DavidPesticcio commented on June 15, 2024 1

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

from yt-dlp.

bashonly avatar bashonly commented on June 15, 2024 1

Which for Linux isn't strictly necessary.

see #9591 for that

from yt-dlp.

bashonly avatar bashonly commented on June 15, 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?

from yt-dlp.

DavidPesticcio avatar DavidPesticcio commented on June 15, 2024

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

from yt-dlp.

bashonly avatar bashonly commented on June 15, 2024

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"

from yt-dlp.

DavidPesticcio avatar DavidPesticcio commented on June 15, 2024

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.

from yt-dlp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.