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

Post-Processing | --exec CMD | can't execute command #5613

Closed
fohrums opened this issue May 5, 2015 · 3 comments
Closed

Post-Processing | --exec CMD | can't execute command #5613

fohrums opened this issue May 5, 2015 · 3 comments

Comments

@fohrums
Copy link

@fohrums fohrums commented May 5, 2015

I want to be able to play a download finished sound for youtube-dl. AFAIK, the --exec CMD is used to only do further processing to the file being downloaded, but I want to do a command outside of that to play a sound file instead.

I chose to use an alias on the sound file through ~/.bashrc.

~/.bashrc

alias sample1='mpv "d:\sound\play.wav"'

USAGE

$ youtube-dl --exec 'sample1' https://www.youtube.com/watch?v=bkb1McW9w-c

ERROR

[exec] Executing command: sample1 'Magenta Welcomes Glen Fox-bkb1McW9w-c.f135.mp4'
'sample1' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Command returned error code 1

@fohrums fohrums changed the title Post-Processing | --exec CMD | can't execute anything Post-Processing | --exec CMD | can't execute aliased command May 5, 2015
@fohrums fohrums changed the title Post-Processing | --exec CMD | can't execute aliased command Post-Processing | --exec CMD | can't execute command May 5, 2015
@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented May 5, 2015

Post the output you get with the --verbose option.
Note that on UNIX it uses /bin/sh(at least on OSX), I think it doesn't load .bashrc. You should try if find . -exec sample1 '{}' \; works (that's where the inspiration for the option came).

@fohrums
Copy link
Author

@fohrums fohrums commented May 5, 2015

@jaimeMF well i'm using windows/cygwin

full output

user@local /cygdrive/d/download
$ youtube-dl --exec 'sample1' https://www.youtube.com/watch?v=bkb1McW9w-c --verbose
[debug] System config: []
[debug] User config: []
[debug] Command-line args: [u'--exec', u'sample1', u'https://www.youtube.com/watch?v=bkb1McW9w-c', u'--verbose']
[debug] Encodings: locale cp1252, fs mbcs, out None, pref cp1252
[debug] youtube-dl version 2015.05.04
[debug] Python version 2.7.9 - Windows-7-6.1.7601-SP1
[debug] exe versions: ffmpeg N-71727-g46778ab, ffprobe N-71727-g46778ab
[debug] Proxy map: {}
[youtube] bkb1McW9w-c: Downloading webpage
[youtube] bkb1McW9w-c: Extracting video information
[youtube] bkb1McW9w-c: Downloading DASH manifest
[debug] Invoking downloader on 'https://r3---sn-pu5oqx-b0he.googlevideo.com/videoplayback?id=6e46f531c5bdc3e7&itag=135&source=youtube&requiressl=yes&pl=19&mm=31&mv=m&ms=au&ratebypass=yes&mime=video/mp4&gir=yes&clen=17251679&lmt=1428687150779621&dur=133.867&sver=3&signature=016E3358B9885E3C33C6F52C78DAAA01A3A6F16A.87DA9894467F6754BFD3DD2D9B52385CF2EE4737&mt=1430825744&key=dg_yt0&upn=2-Wfro-n0qA&fexp=900720,907263,924637,934954,936117,938028,9406007,9406631,9406848,9407016,9408142,9408228,9408704,9408788,9408940,9408978,9412526,943611,948124,952612,952636,952637,952642,957201,960626&ip=202.88.76.55&ipbits=0&expire=1430847433&sparams=ip,ipbits,expire,id,itag,source,requiressl,pl,mm,mv,ms,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Magenta Welcomes Glen Fox-bkb1McW9w-c.f135.mp4
[download] 100% of 16.45MiB in 00:07
[debug] Invoking downloader on 'https://r3---sn-pu5oqx-b0he.googlevideo.com/videoplayback?id=6e46f531c5bdc3e7&itag=141&source=youtube&requiressl=yes&pl=19&mm=31&mv=m&ms=au&ratebypass=yes&mime=audio/mp4&gir=yes&clen=4270734&lmt=1428687134293848&dur=133.932&sver=3&signature=079017140FD72D2774C1BF15724220D9D9D2819D.972807AE6ABE32C5CEB72CADBFC8D71AFBB3E1AC&mt=1430825744&key=dg_yt0&upn=2-Wfro-n0qA&fexp=900720,907263,924637,934954,936117,938028,9406007,9406631,9406848,9407016,9408142,9408228,9408704,9408788,9408940,9408978,9412526,943611,948124,952612,952636,952637,952642,957201,960626&ip=202.88.76.55&ipbits=0&expire=1430847433&sparams=ip,ipbits,expire,id,itag,source,requiressl,pl,mm,mv,ms,ratebypass,mime,gir,clen,lmt,dur'
[download] Destination: Magenta Welcomes Glen Fox-bkb1McW9w-c.f141.m4a
[download] 100% of 4.07MiB in 00:02
[ffmpeg] Merging formats into "Magenta Welcomes Glen Fox-bkb1McW9w-c.mp4"
[debug] ffmpeg command line: ffmpeg -y -i 'Magenta Welcomes Glen Fox-bkb1McW9w-c.f135.mp4' -i 'Magenta Welcomes Glen Fox-bkb1McW9w-c.f141.m4a' -c copy -map 0:v:0 -map 1:a:0 'Magenta Welcomes Glen Fox-bkb1McW9w-c.temp.mp4'
Deleting original file Magenta Welcomes Glen Fox-bkb1McW9w-c.f135.mp4 (pass -k to keep)
Deleting original file Magenta Welcomes Glen Fox-bkb1McW9w-c.f141.m4a (pass -k to keep)
[exec] Executing command: sample1 'Magenta Welcomes Glen Fox-bkb1McW9w-c.mp4'
'sample1' is not recognized as an internal or external command,
operable program or batch file.
ERROR: Command returned error code 1
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\youtube_dl\YoutubeDL.py", line 1527, in post_process
    files_to_delete, info = pp.run(info)
  File "C:\Python27\lib\site-packages\youtube_dl\postprocessor\execafterdownload.py", line 26, in run
    'Command returned error code %d' % retCode)
PostProcessingError
@jaimeMF
Copy link
Collaborator

@jaimeMF jaimeMF commented May 5, 2015

First of all, you are using Windows. It doesn't seem like it uses sh as the shell (from the message is not recognized as an internal or external command, operable program or batch file, I guess it's using the same interpreter as the windows prompt.

On UNIX, if sh is actually bash, it doesn't load any configuration file. From the man page:

If  bash  is invoked with the name sh, it tries to mimic the startup behavior
of historical versions of sh as closely as possible, while conforming to  the
POSIX  standard  as  well.   When invoked as an interactive login shell, or a
non-interactive shell with the --login option, it first attempts to read  and
execute  commands  from  /etc/profile  and  ~/.profile,  in  that order.  The
--noprofile option may be used to inhibit this behavior.  When invoked as  an
interactive  shell with the name sh, bash looks for the variable ENV, expands
its value if it is defined, and uses the expanded value as the name of a file
to  read  and  execute.  Since a shell invoked as sh does not attempt to read
and execute commands from any other startup files, the --rcfile option has no
effect.  A non-interactive shell invoked with the name sh does not attempt to
read any other startup files.  When invoked as sh,  bash  enters  posix  mode
after the startup files are read.

You have to manually source the configuration file: --exec 'source ~/.bashrc; foo {}'.

@jaimeMF jaimeMF closed this May 5, 2015
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.