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

Using --trim-filenames with --write-info-json or --write-comments results in info.json file name being trimmed at first dot #1837

Closed
6 tasks done
NilEinne opened this issue Nov 29, 2021 · 6 comments
Labels
bug Bug that is not site-specific

Comments

@NilEinne
Copy link

Checklist

  • I'm reporting a bug unrelated to a specific site
  • I've verified that I'm running yt-dlp version 2021.11.10.1. (update instructions)
  • I've checked that all provided URLs are alive and playable in a browser
  • I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • I've searched the bugtracker for similar issues including closed ones. DO NOT post duplicates
  • I've read the guidelines for opening an issue

Description

There seems to be a bug when --trim-filenames is used together with --write-info-json or --write-comments or probably any option which outputs info.json, and the filename contains a dot/period. The info.json is always trimmed at the first dot, even when it should not be trimmed at all.

A simple test is this
yt-dlp.exe -Uv --trim-filenames 200 --write-info-json https://www.youtube.com/watch?v=PXBJIZ1NXFU
I've included the output for this command in the below log.

Although not shown above, other files like the video itself, but also description, thumbnails (even all thumbnails), and the 3 link formats do not suffer this problem e.g.
--write-description --write-info-json --write-thumbnail --write-all-thumbnails --write-url-link --write-webloc-link --write-desktop-link
and you will find all the other files have the expected file names. The problem is not simply with automated filenames, for example if you add --output Meow.Test.Name to any download, it will be cutoff at Meow.

BTW, you probably don't want to try comments on the earlier video given the large number of comments. If you want to test with comments you can try this video https://www.youtube.com/watch?v=HsftmWKwGvQ or just use the output parameter with any video.

This problem is not unique to Youtube. It also occurs with Twitch. For example this video https://www.twitch.tv/videos/1200763265 or again any video using the output parameter e.g. https://www.stuff.co.nz/national/politics/300465842/covid19-nz-auckland-and-lowervaccinated-areas-to-start-at-red-while-wellington-waikato-and-south-island-are-orange

Verbose log

[debug] Command-line config: ['-Uv', '--trim-filenames', '200', '--write-info-json', 'https://www.youtube.com/watch?v=PXBJIZ1NXFU']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, err utf-8, pref cp1252
[debug] yt-dlp version 2021.11.10.1 (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 4.4.1-full_build-www.gyan.dev (setts), ffprobe 4.4.1-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
yt-dlp is up to date (2021.11.10.1)
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=PXBJIZ1NXFU
[youtube] PXBJIZ1NXFU: Downloading webpage
[youtube] PXBJIZ1NXFU: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] PXBJIZ1NXFU: Downloading 1 format(s): 248+251
[info] Writing video metadata as JSON to: Jim Henson vs Stan Lee.info.json
[download] Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].webm has already been downloaded
PS P:\test\trim> cd 2
PS P:\test\trim\2> C:\yt-dlp\yt-dlp.latestversion.exe -Uv --trim-filenames 200 --write-info-json https://www.youtube.com/watch?v=PXBJIZ1NXFU
[debug] Command-line config: ['-Uv', '--trim-filenames', '200', '--write-info-json', 'https://www.youtube.com/watch?v=PXBJIZ1NXFU']
[debug] Encodings: locale cp1252, fs utf-8, out utf-8, err utf-8, pref cp1252
[debug] yt-dlp version 2021.11.10.1 (win_exe)
[debug] Python version 3.8.10 (CPython 64bit) - Windows-10-10.0.19041-SP0
[debug] exe versions: ffmpeg 4.4.1-full_build-www.gyan.dev (setts), ffprobe 4.4.1-full_build-www.gyan.dev
[debug] Optional libraries: Cryptodome, mutagen, sqlite, websockets
[debug] Proxy map: {}
yt-dlp is up to date (2021.11.10.1)
[debug] [youtube] Extracting URL: https://www.youtube.com/watch?v=PXBJIZ1NXFU
[youtube] PXBJIZ1NXFU: Downloading webpage
[youtube] PXBJIZ1NXFU: Downloading android player API JSON
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, codec:vp9.2, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), acodec, lang, proto, filesize, fs_approx, tbr, vbr, abr, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] PXBJIZ1NXFU: Downloading 1 format(s): 248+251
[info] Writing video metadata as JSON to: Jim Henson vs Stan Lee.info.json
[debug] Invoking downloader on "https://r4---sn-j5aa2a0n-53as.googlevideo.com/videoplayback?expire=1638227592&ei=KAqlYbyoIpHcoQPlrZH4Cw&ip=2404%3A4408%3A133b%3A7b00%3A8d8a%3Ad6ab%3A1cfe%3Ab65b&id=o-AF8Xje06fTQfrZgZzrTna-4EsONK0mER8hH3W78ZtZbD&itag=248&source=youtube&requiressl=yes&mh=MJ&mm=31%2C26&mn=sn-j5aa2a0n-53as%2Csn-a5meknzk&ms=au%2Conr&mv=m&mvi=4&pl=40&initcwndbps=1520000&vprv=1&mime=video%2Fwebm&gir=yes&clen=100870013&dur=331.163&lmt=1576463490709548&mt=1638205508&fvip=4&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=5535432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgJu0FgKW17kLlrYg97nKMF44zKdsGsK0C9mxSxYD3EswCID47zWei5B3kfxskxIYfMVJjsCqCBK6bjbJYW0xAEah6&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAItNbk69IRQH_zlKpI_H7hWkCIpj5Ao9SOzTDOE3bs3wAiEA6jGmGm11S11t69m01CMWyvH8EG729J-RxvoAg82l-xM%3D"
[download] Destination: Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].f248.webm
[download] 100% of 96.20MiB in 00:03
[debug] Invoking downloader on "https://r4---sn-j5aa2a0n-53as.googlevideo.com/videoplayback?expire=1638227592&ei=KAqlYbyoIpHcoQPlrZH4Cw&ip=2404%3A4408%3A133b%3A7b00%3A8d8a%3Ad6ab%3A1cfe%3Ab65b&id=o-AF8Xje06fTQfrZgZzrTna-4EsONK0mER8hH3W78ZtZbD&itag=251&source=youtube&requiressl=yes&mh=MJ&mm=31%2C26&mn=sn-j5aa2a0n-53as%2Csn-a5meknzk&ms=au%2Conr&mv=m&mvi=4&pl=40&initcwndbps=1520000&vprv=1&mime=audio%2Fwebm&gir=yes&clen=5295594&dur=331.201&lmt=1576459388617512&mt=1638205508&fvip=4&keepalive=yes&fexp=24001373%2C24007246&c=ANDROID&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRQIgFJhLfI5JhTeBSFXRE51Bdvjby-pyjwQDWV_rRWlK1LYCIQDBSdSfePXL5fsIeosoxsQCTiAprj6SZIrC30gOZefGbg%3D%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRgIhAItNbk69IRQH_zlKpI_H7hWkCIpj5Ao9SOzTDOE3bs3wAiEA6jGmGm11S11t69m01CMWyvH8EG729J-RxvoAg82l-xM%3D"
[download] Destination: Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].f251.webm
[download] 100% of 5.05MiB in 00:00
[Merger] Merging formats into "Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].webm"
[debug] ffmpeg command line: ffmpeg -y -loglevel "repeat+info" -i "file:Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].f248.webm" -i "file:Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].f251.webm" -c copy -map "0:v:0" -map "1:a:0" "file:Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].temp.webm"
Deleting original file Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].f251.webm (pass -k to keep)
Deleting original file Jim Henson vs Stan Lee. Epic Rap Battles of History [PXBJIZ1NXFU].f248.webm (pass -k to keep)
@NilEinne NilEinne added bug Bug that is not site-specific triage Untriaged issue labels Nov 29, 2021
@pukkandan pukkandan removed the triage Untriaged issue label Nov 29, 2021
@pukkandan
Copy link
Member

--trim-filename was added in youtube-dlc and actually quite buggy. I can fix this particular issue, but I recommend using the string formatting to achieve a similar effect. Eg: -o %(title).200s.%(ext)s

@GlassedSilver
Copy link

--trim-filename was added in youtube-dlc and actually quite buggy. I can fix this particular issue, but I recommend using the string formatting to achieve a similar effect. Eg: -o %(title).200s.%(ext)s

Is this Unicode aware? (because a single unicode character is "longer" if I'm not mistaken)

@pukkandan
Copy link
Member

Use .200s for 200 characters and .200B for 200 bytes

@GlassedSilver
Copy link

Use .200s for 200 characters and .200B for 200 bytes

Holy crap, thank you! Much appreciated!

@GlassedSilver
Copy link

Use .200s for 200 characters and .200B for 200 bytes

Could it be that this only propagates to the video file name and the info.json can still fail? Either that or the application I'm trying to maintain interferes with yt-dlp handling this well otherwise.

@pukkandan
Copy link
Member

Could it be that this only propagates to the video file name and the info.json can still fail

Cant say without seeing your exact options. Open a new issue with verbose log

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
Projects
None yet
Development

No branches or pull requests

3 participants