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

Unexpected output file template formatting with dollar underscore in filename #26881

Closed
gradha opened this issue Oct 13, 2020 · 2 comments
Closed

Comments

@gradha
Copy link

@gradha gradha commented Oct 13, 2020

Checklist

  • I'm reporting a broken site support issue
  • I've verified that I'm running youtube-dl version 2020.09.20
  • 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 bug reports including closed ones
  • I've read bugs section in FAQ

Verbose log

$ youtube-dl -v -o 'dash.a$_.mkv' -f 394 -- -80miaG2wF0 
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'-o', u'dash.a$_.mkv', u'-f', u'394', u'--', u'-80miaG2wF0']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 2.7.15 (CPython) - Darwin-18.7.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.2.1-tessus, ffprobe 3.2.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] -80miaG2wF0: Downloading webpage
[debug] Invoking downloader on u'https://r3---sn-h5nhv8pa-cjoe.googlevideo.com/videoplayback?expire=1602645682&ei=URqGX6S-O4n_xwLnxr2YBA&ip=93.115.152.239&id=o-AEYwO0tJwLAmByb2CXPOfsUj2DliKbuzaWqk2gfWo4CG&itag=394&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C298%2C299%2C302%2C303%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&mh=IJ&mm=31%2C29&mn=sn-h5nhv8pa-cjoe%2Csn-h5q7kne6&ms=au%2Crdu&mv=m&mvi=3&pcm2cms=yes&pl=24&initcwndbps=1581250&vprv=1&mime=video%2Fmp4&gir=yes&clen=10529263&dur=1199.866&lmt=1602132954559368&mt=1602623914&fvip=3&keepalive=yes&fexp=23915654&beids=9466587&c=WEB&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRAIgSUW50H8x9_ChacWZo9bbpH2wRPMPtLwavFNkfV2PheECIA_X3bhSEETRIZbS19HaOMy-fMkUFeZMDa5govuwdOzV&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgHxA3HG_ppwx7X5B3Q-HJbCXiWVWl-khXbpUsyMGBNMUCIFnH1_KhXW1tnm2kV-4kiaz8K8PLXs9rbvdki9pop_fT&ratebypass=yes'
[download] Destination: dash.a/Users/gradha/bin/youtube-dl.mkv
[download] 100% of 10.04MiB in 00:02

Description

For some reason when using the -o template option containing the $_ substring, this substring is expanded to the path where youtube-dl script lives. Changing the parameter to dash.a$ _.mkv works fine and will create a file named dash.a$ _.mkv.

I have checked the documented output template options and I see nothing about $_ being any escape sequence.

I have also checked python string formatting operations and don't see any $_ formatting either.

If instead of running the command I prefix the command with echo to see what the bash interpreter understands, I get the expected output including the $_ substring not being replaced:

$ echo youtube-dl -v -o 'dash.a$_.mkv' -f 394 -- -80miaG2wF0 
youtube-dl -v -o dash.a$_.mkv -f 394 -- -80miaG2wF0

If I try to use python3 instead the bug happens as well, just with a different path being replaced:

$ python3 ~/bin/youtube-dl -v -o 'dash.a$_.mkv' -f 394 -- -80miaG2wF0 
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '-o', 'dash.a$_.mkv', '-f', '394', '--', '-80miaG2wF0']
[debug] Encodings: locale UTF-8, fs utf-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2020.09.20
[debug] Python version 3.7.2 (CPython) - Darwin-18.7.0-x86_64-i386-64bit
[debug] exe versions: ffmpeg 4.2.1-tessus, ffprobe 3.2.2, rtmpdump 2.4
[debug] Proxy map: {}
[youtube] -80miaG2wF0: Downloading webpage
[debug] Invoking downloader on 'https://r3---sn-h5nhv8pa-cjoe.googlevideo.com/videoplayback?expire=1602646178&ei=QhyGX9SENcyrW8yIstgN&ip=93.115.152.239&id=o-AMEz5JOYsxyHyOIyOMtwEg058va7jXfm3mCc_iqfnpyt&itag=394&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278%2C298%2C299%2C302%2C303%2C394%2C395%2C396%2C397%2C398%2C399&source=youtube&requiressl=yes&mh=IJ&mm=31%2C29&mn=sn-h5nhv8pa-cjoe%2Csn-h5q7kne6&ms=au%2Crdu&mv=m&mvi=3&pcm2cms=yes&pl=24&initcwndbps=1585000&vprv=1&mime=video%2Fmp4&gir=yes&clen=10529263&dur=1199.866&lmt=1602132954559368&mt=1602624396&fvip=3&keepalive=yes&fexp=23915654&c=WEB&txp=5531432&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cgir%2Cclen%2Cdur%2Clmt&sig=AOq0QJ8wRgIhALMcpCM74NRxMRRljsoQ7SmPSKLiIoC1S29aCCU2QmVPAiEA3RQ7GKyUuca1Xdd8C_vJd6WJrBOVwZcxnjqp09Byl4M%3D&lsparams=mh%2Cmm%2Cmn%2Cms%2Cmv%2Cmvi%2Cpcm2cms%2Cpl%2Cinitcwndbps&lsig=AG3C_xAwRAIgGISHkhr6taHJBUs9nTJLRWEcCgtgRLlKyRaB8I3FvMUCIGYXSaitIGW4PMEDZSm-YskubVyOHqQS1fEofHa4L9Gt&ratebypass=yes'
[download] Destination: dash.a/Library/Frameworks/Python.framework/Versions/3.7/bin/python3.mkv
[download]  97.0% of 10.04MiB at  4.25MiB/s ETA 00:00^C
ERROR: Interrupted by user

Adding dollar signs does not change the effect: the last $_ will still be replaced. However, adding underscores seems to not trigger the substitution, so a name like dash.a$__.mkv works as expected.

Where does the substitution come from?

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Oct 17, 2020

From your shell.

@dstftw dstftw closed this Oct 17, 2020
@gradha
Copy link
Author

@gradha gradha commented Oct 17, 2020

Is Python buggy then since I'm passing shell = False?:

$ ./test.py 
/Users/gradha/bin/youtube-dl really.a$_.mkv -f 394 -- -80miaG2wF0
[youtube] -80miaG2wF0: Downloading webpage
[download] Destination: really.a./test.py.mkv
[download] 100% of 10.04MiB in 00:02
$ cat test.py 
#!/usr/bin/env python3

import os
import subprocess

binary = os.path.expanduser("~/bin/youtube-dl")
subprocess.run(
    ["/bin/echo", binary, "really.a$_.mkv", "-f", "394", "--", "-80miaG2wF0"],
    shell = False)
subprocess.run(
    [binary, "-o", "really.a$_.mkv", "-f", "394", "--", "-80miaG2wF0"],
    shell = False)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.