Page 1 of 1

Escape "=>" in a script.

Posted: 16 Jun 2020 14:00
by MBplorer
Hi-

I'm trying to put together a quick script for YouTube-dl. I've seen scripts for this by others on the forum, but I'm just trying to do one with the specific options I like. I've hit a snag trying to "escape" one of my command line options. The command I'm trying to execute is the following (followed by the URL):

youtube-dl -f ("bestvideo[width>=1920]"/bestvideo)+bestaudio/best -ciw -o "%(uploader)s-%(title)s-%(upload_date)s-%(id)s.%(ext)s" -v

The issue seems to be the ">=". What is the appropriate way to escape this? I've read a number of posts regarding multiple """, but so far no luck with this particular pattern. No matter what I've tried it appears to be parsed into two commands at the ">=".

Thanks for any sage advice from the scripting mystics!

Re: Escape "=>" in a script.

Posted: 16 Jun 2020 14:17
by highend
By doubling them

Code: Select all

run """youtube_dl"" -f (""bestvideo[width>=1920]""/bestvideo)+bestaudio/best -ciw -o ""%(uploader)s-%(title)s-%(upload_date)s-%(id)s.%(ext)s"" -v https://www.youtube.com/watch?v=PTYPPnKGPPE", %TEMP%, 2, 1;
Or a heredoc syntax would work as well

Code: Select all

    $cmd = <<<>>>
"youtube-dl" -f ("bestvideo[width>=1920]"/bestvideo)+bestaudio/best -ciw -o "%(uploader)s-%(title)s-%(upload_date)s-%(id)s.%(ext)s" -v https://www.youtube.com/watch?v=PTYPPnKGPPE
>>>;
    run $cmd, %TEMP%, 2, 1;

Re: Escape "=>" in a script.

Posted: 16 Jun 2020 16:43
by MBplorer
Thanks for the speedy reply highend!

Looks like I was close, but the straightforwardness of it threw me. :-)

Thanks for the heredoc tip also- I'll investigate that for future needs.