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

Passing names to exec post-processing #28642

Open
3 tasks done
ScribbleGhost opened this issue Apr 2, 2021 · 4 comments
Open
3 tasks done

Passing names to exec post-processing #28642

ScribbleGhost opened this issue Apr 2, 2021 · 4 comments
Labels

Comments

@ScribbleGhost
Copy link

Checklist

  • I'm asking a question
  • I've looked through the README and FAQ for similar questions
  • I've searched the bugtracker for similar questions including closed ones

Question

-exec CMD

Execute a command on the file after downloading and post-processing, similar to find's -exec syntax. Example: --exec 'adb push {}/sdcard/Music/ && rm {}'                                     

What else can be passed to the command except {}? For example. if I want to post-process a subtitle, is it possible to pass the subtitle name instead of the video file name?

@ScribbleGhost
Copy link
Author

Sorry, I am Windows so I don't know of any way to write this with PowerShell or CMD.

@pukkandan
Copy link
Contributor

Only the filename {} can be passed

"$(a='{}'; printf '%s' "${a%.*}.srt")"

This cannot be done in a single line in windows (without additional tools), but you can write a batch script to do this. Eg: put echo.%~dpn1.srt in a batch file and point --exec to that file

@dirkf
Copy link
Contributor

dirkf commented Apr 10, 2021

PowerShell should allow a functional equivalent of the one-liner above.

Eg use $Args[0] -replace '\.[^.]+$', '.srt' in a script block on the PS command line where the subtitle filename is needed, passing '{}' as the 0th argument to the script.

For more advanced needs, one could try --write-info-json and get any metadata extracted by yt-dl from outfile.info.json in the --exec command, perhaps using the ConvertFrom-Json PS cmdlet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants
@dirkf @pukkandan @ScribbleGhost and others