yt-dlp / yt-dlp

A feature-rich command-line audio/video downloader
https://discord.gg/H5MNcFW63r
The Unlicense
89.82k stars 6.96k forks source link

Misalignment in special character replacement between -O and -o on Linux #9790

Closed ALTree closed 6 months ago

ALTree commented 6 months ago

DO NOT REMOVE OR SKIP THE ISSUE TEMPLATE

Checklist

Provide a description that is worded well enough to be understood

$ yt-dlp --version
2024.04.21.232710

On Linux, on default settings, yt-dlp uses a unicode vertical bar character (U+FF5C FULLWIDTH VERTICAL LINE) for the ascii | in the output for the -o flag, but not on -O, creating a misalignment between the expected filename as printed by -O and the actual filename on the fs. Reproducer:

$ yt-dlp -O "%(title)s.%(ext)s" "https://www.youtube.com/watch?v=RfSVFtv7-90"
Passenger | Simple Song (Official Audio).webm
          ^
   ascii vertical bar
$ yt-dlp -o "%(title)s.%(ext)s" "https://www.youtube.com/watch?v=RfSVFtv7-90"

[youtube] Extracting URL: https://www.youtube.com/watch?v=RfSVFtv7-90
[youtube] RfSVFtv7-90: Downloading webpage
[youtube] RfSVFtv7-90: Downloading ios player API JSON
[youtube] RfSVFtv7-90: Downloading android player API JSON
[youtube] RfSVFtv7-90: Downloading m3u8 information
[info] RfSVFtv7-90: Downloading 1 format(s): 616+251
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 46
[download] Destination: Passenger | Simple Song (Official Audio).f616.mp4
[download] 100% of   15.15MiB in 00:00:07 at 2.13MiB/s
[download] Destination: Passenger | Simple Song (Official Audio).f251.webm
[download] 100% of    3.87MiB in 00:00:01 at 3.87MiB/s
[Merger] Merging formats into "Passenger | Simple Song (Official Audio).webm"
Deleting original file Passenger | Simple Song (Official Audio).f251.webm (pass -k to keep)
Deleting original file Passenger | Simple Song (Official Audio).f616.mp4 (pass -k to keep)
                                 ^
              unicode vertical bar character

$ ls *.webm
'Passenger | Simple Song (Official Audio).webm'
           ^
      unicode vertical bar in filename

Provide verbose output that clearly demonstrates the problem

Complete Verbose Output

Complete verbose output for -O invocation:

$ yt-dlp -vUO "%(title)s.%(ext)s" "https://www.youtube.com/watch?v=RfSVFtv7-90"

[debug] Command-line config: ['-vUO', '%(title)s.%(ext)s', 'https://www.youtube.com/watch?v=RfSVFtv7-90']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.04.21.232710 from yt-dlp/yt-dlp-nightly-builds [ff38a011d] (zip)
[debug] Python 3.11.8 (CPython x86_64 64bit) - Linux-6.6.15-amd64-x86_64-with-glibc2.37 (OpenSSL 3.1.5 30 Jan 2024, glibc 2.37)
[debug] exe versions: ffmpeg 6.1.1-1 (setts), ffprobe 6.1.1-1
[debug] Optional libraries: certifi-2023.11.17, requests-2.31.0, sqlite3-3.45.1, urllib3-1.26.18
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests
[debug] Loaded 1810 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.04.21.232710 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.04.21.232710 from yt-dlp/yt-dlp-nightly-builds)
[youtube] Extracting URL: https://www.youtube.com/watch?v=RfSVFtv7-90
[youtube] RfSVFtv7-90: Downloading webpage
[youtube] RfSVFtv7-90: Downloading ios player API JSON
[youtube] RfSVFtv7-90: Downloading android player API JSON
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "RfSVFtv7-90")
[debug] [youtube] Extracting signature function js_652ba3a2_110
[debug] Loading youtube-sigfuncs.js_652ba3a2_110 from cache
[debug] Loading youtube-nsig.652ba3a2 from cache
[debug] [youtube] Decrypted nsig Rlf4GYF6I8B0f-SbzD => V0FLnBEALQV4wQ
[debug] Loading youtube-nsig.652ba3a2 from cache
[debug] [youtube] Decrypted nsig _vbzZHJXR9Zg1iUZzj => lPNjZQTXzHiIpg
[youtube] RfSVFtv7-90: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] RfSVFtv7-90: Downloading 1 format(s): 616+251
Passenger | Simple Song (Official Audio).webm

Complete verbose output for -o invocation:

$ yt-dlp -vUo "%(title)s.%(ext)s" "https://www.youtube.com/watch?v=RfSVFtv7-90"

[debug] Command-line config: ['-vUo', '%(title)s.%(ext)s', 'https://www.youtube.com/watch?v=RfSVFtv7-90']
[debug] Encodings: locale UTF-8, fs utf-8, pref UTF-8, out utf-8, error utf-8, screen utf-8
[debug] yt-dlp version nightly@2024.04.21.232710 from yt-dlp/yt-dlp-nightly-builds [ff38a011d] (zip)
[debug] Python 3.11.8 (CPython x86_64 64bit) - Linux-6.6.15-amd64-x86_64-with-glibc2.37 (OpenSSL 3.1.5 30 Jan 2024, glibc 2.37)
[debug] exe versions: ffmpeg 6.1.1-1 (setts), ffprobe 6.1.1-1
[debug] Optional libraries: certifi-2023.11.17, requests-2.31.0, sqlite3-3.45.1, urllib3-1.26.18
[debug] Proxy map: {}
[debug] Request Handlers: urllib, requests
[debug] Loaded 1810 extractors
[debug] Fetching release info: https://api.github.com/repos/yt-dlp/yt-dlp-nightly-builds/releases/latest
Latest version: nightly@2024.04.21.232710 from yt-dlp/yt-dlp-nightly-builds
yt-dlp is up to date (nightly@2024.04.21.232710 from yt-dlp/yt-dlp-nightly-builds)
[youtube] Extracting URL: https://www.youtube.com/watch?v=RfSVFtv7-90
[youtube] RfSVFtv7-90: Downloading webpage
[youtube] RfSVFtv7-90: Downloading ios player API JSON
[youtube] RfSVFtv7-90: Downloading android player API JSON
WARNING: [youtube] Skipping player responses from android clients (got player responses for video "aQvGIIdgFDM" instead of "RfSVFtv7-90")
[debug] [youtube] Extracting signature function js_652ba3a2_110
[debug] Loading youtube-sigfuncs.js_652ba3a2_110 from cache
[debug] Loading youtube-nsig.652ba3a2 from cache
[debug] [youtube] Decrypted nsig n1LvAvaVdvXm667Nhp => fIhskjzqwyIgdg
[debug] Loading youtube-nsig.652ba3a2 from cache
[debug] [youtube] Decrypted nsig UsVdIoW3XpMwMixLh4 => a7srCLw6aRllSQ
[youtube] RfSVFtv7-90: Downloading m3u8 information
[debug] Sort order given by extractor: quality, res, fps, hdr:12, source, vcodec:vp9.2, channels, acodec, lang, proto
[debug] Formats sorted by: hasvid, ie_pref, quality, res, fps, hdr:12(7), source, vcodec:vp9.2(10), channels, acodec, lang, proto, size, br, asr, vext, aext, hasaud, id
[debug] Default format spec: bestvideo*+bestaudio/best
[info] RfSVFtv7-90: Downloading 1 format(s): 616+251
[debug] Invoking hlsnative downloader on "https://manifest.googlevideo.com/api/manifest/hls_playlist/expire/1714144690/ei/UnErZrWsOoOJ8gPywbLADA/ip/178.249.211.94/id/45f49516dbfbfbdd/itag/616/source/youtube/requiressl/yes/ratebypass/yes/pfa/1/wft/1/sgovp/clen%3D15847877%3Bdur%3D227.999%3Bgir%3Dyes%3Bitag%3D356%3Blmt%3D1706996806947486/rqh/1/hls_chunk_host/rr4---sn-hpa7knle.googlevideo.com/xpc/EgVo2aDSNQ%3D%3D/mh/Wt/mm/31,29/mn/sn-hpa7knle,sn-hpa7znz6/ms/au,rdu/mv/m/mvi/4/pl/24/initcwndbps/2615000/vprv/1/playlist_type/DVR/dover/13/txp/4432434/mt/1714122781/fvip/5/short_key/1/keepalive/yes/sparams/expire,ei,ip,id,itag,source,requiressl,ratebypass,pfa,wft,sgovp,rqh,xpc,vprv,playlist_type/sig/AJfQdSswRQIhAOB2tJINuBM2ez5V7nAj7PXGe2shd-ns-7-WMLCdeF2hAiB3RgLRu2HQGArvHGiWCgrN0VA-c6x0eXvmk95XSuESPQ%3D%3D/lsparams/hls_chunk_host,mh,mm,mn,ms,mv,mvi,pl,initcwndbps/lsig/AHWaYeowRQIgZsuT2JkRjQ_l1wrqHHGeDMOFtYm0wqWDbTu4adoJSvECIQCCb4p1B5pShHdaD8aJXmpH2KvRalOKqwTiLrlzsumn2g%3D%3D/playlist/index.m3u8"
[hlsnative] Downloading m3u8 manifest
[hlsnative] Total fragments: 46
[download] Destination: Passenger | Simple Song (Official Audio).f616.mp4
[download] 100% of   15.15MiB in 00:00:06 at 2.33MiB/s
[debug] Invoking http downloader on "https://rr4---sn-hpa7knle.googlevideo.com/videoplayback?expire=1714144690&ei=UXErZvPGPJ7L6dsPl4W8wAM&ip=178.249.211.94&id=o-ABpLLqc02tx5Zyc6s_bNlhmPPmi_kMlWF3ZmtJBT--tA&itag=251&source=youtube&requiressl=yes&xpc=EgVo2aDSNQ%3D%3D&mh=Wt&mm=31%2C26&mn=sn-hpa7knle%2Csn-hgn7rn7k&ms=au%2Conr&mv=m&mvi=4&pl=24&initcwndbps=2615000&bui=AWRWj2RrkwqtCB5hzIyVVxBtTFu9ohQVbLuDTxoTQBdKeZIYuRuNB0ZBfkqSnhR9S8Bl9p5_YJu4Vthm&spc=UWF9f-6bTw5-3TI1gt5r8dwJvO-kXwcT5cnFh4PsHXN4hbPufCqYK_28m6mt&vprv=1&svpuc=1&mime=audio%2Fwebm&ns=3r_IOGWtfdamvMIj9q8b4kEQ&gir=yes&clen=4056352&dur=228.021&lmt=1706996343505244&mt=1714122781&fvip=4&keepalive=yes&c=WEB&sefc=1&txp=4432434&n=a7srCLw6aRllSQ&sparams=expire%2Cei%2Cip%2Cid%2Citag%2Csource%2Crequiressl%2Cxpc%2Cbui%2Cspc%2Cvprv%2Csvpuc%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpl%2Cinitcwndbps&lsig=AHWaYeowRgIhALKwUqI8HA7FFv0dasTLlw8zOIlhtmN035__LRIc1q2ZAiEAjUiFaAQgbRvMiIA65-T0QcSK6KZu7CO5U8Y2YMu1DTM%3D&sig=AJfQdSswRgIhAOFFWlqeA5AeJ5hFrhrH4LeKMdhaU8FYRtnUyslpe8JHAiEAitxJLwhbsQN9ZnTBzsiBVO7PjnawKhycVKckyEOME4c%3D"
[download] Destination: Passenger | Simple Song (Official Audio).f251.webm
[download] 100% of    3.87MiB in 00:00:00 at 4.80MiB/s
[Merger] Merging formats into "Passenger | Simple Song (Official Audio).webm"
[debug] ffmpeg command line: ffmpeg -y -loglevel repeat+info -i 'file:Passenger | Simple Song (Official Audio).f616.mp4' -i 'file:Passenger | Simple Song (Official Audio).f251.webm' -c copy -map 0:v:0 -map 1:a:0 -movflags +faststart 'file:Passenger | Simple Song (Official Audio).temp.webm'
Deleting original file Passenger | Simple Song (Official Audio).f251.webm (pass -k to keep)
Deleting original file Passenger | Simple Song (Official Audio).f616.mp4 (pass -k to keep)
pukkandan commented 6 months ago

Use -O filename or %(title)S (capital S)

https://github.com/yt-dlp/yt-dlp/blob/89f535e2656964b4061c25a7739d4d6ba0a30568/README.md?plain=1#L1213

ALTree commented 6 months ago

Using S fixed my script. Thank you! Closing.