Escape "=>" in a script.

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
MBplorer
Posts: 4
Joined: 16 Jun 2020 13:35

Escape "=>" in a script.

Post 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!

highend
Posts: 13308
Joined: 06 Feb 2011 00:33

Re: Escape "=>" in a script.

Post 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;
One of my scripts helped you out? Please donate via Paypal

MBplorer
Posts: 4
Joined: 16 Jun 2020 13:35

Re: Escape "=>" in a script.

Post 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.

Post Reply