Writing an executable script [SOLVED]

Moderator: Forum moderators

Post Reply
User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Writing an executable script [SOLVED]

Post by Jasper »

HI there

I am hoping someone can help me write a simple script to save me from having to copy and paste this command into terminal each time I wish to use it.

I have tried this in pRun and Gexec but it fails to run correctly.

More than likely I do not know how to enter it correctly :oops:

This is it:

Code: Select all


yt-dlp -f wa --downloader aria2c --embed-thumbnail --batch-file /root/download.txt --path /root/Downloads/Podcasts

Thank you in advance!

**EDIT**
Updated the command 13 Nov 2022

Last edited by Jasper on Sun Nov 13, 2022 7:52 pm, edited 3 times in total.
User avatar
rockedge
Site Admin
Posts: 6571
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2779 times
Been thanked: 2650 times
Contact:

Re: Writing an executable script

Post by rockedge »

Try:
do_yt-dlp.sh

Code: Select all

#!/bin/sh
yt-dlp  -f wa --downloader aria2c --progress --embed-thumbnail --batch-file /root/download.txt --path /root/Downloads/Podcasts
User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Writing an executable script [SOLVED]

Post by Jasper »

Thank you so much rockedge for taking some time out to help me.

It's appreciated :thumbup2:

I did see an option in when I opened up Rox there was an option for "New - Script". I was unsure, so I had to ask before I messed it up.

Works perfectly!!

User avatar
fredx181
Posts: 3110
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Writing an executable script

Post by fredx181 »

rockedge wrote: Sat Nov 12, 2022 3:19 pm

Try:
do_yt-dlp.sh

Code: Select all

#!/bin/sh
yt-dlp  -f wa --downloader aria2c --progress --embed-thumbnail --batch-file /root/download.txt --path /root/Downloads/Podcasts

If you want to see the progress to run it from urxvt terminal: (may show some error if thumbnail not found):

Code: Select all

#!/bin/sh
urxvt -e yt-dlp -f wa --downloader aria2c --progress --embed-thumbnail --batch-file /root/download.txt --path /root/Downloads/Podcasts

EDIT: Removed the single quotes in code above after urxvt -e, perhaps won't always work to encapsulate the command with quotes.

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Writing an executable script [SOLVED]

Post by Jasper »

@fredx181

Thanks for that handy hint :thumbup:

Rockedge's script works and does open up terminal and conveniently tells me when the action has been completed, prompting me to press <enter>.

I will add your addition and try it out as well.

User avatar
fredx181
Posts: 3110
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Writing an executable script [SOLVED]

Post by fredx181 »

Jasper wrote: Sat Nov 12, 2022 5:53 pm

@fredx181

Rockedge's script works and does open up terminal and conveniently tells me when the action has been completed, prompting me to press <enter>.
...

So you mean when you click on Rockedge's script from file-manager it shows the terminal ? I doubt that , but may stand corrected.
EDIT: the script needs to be made executable; e.g. chmod +x do_yt-dlp.sh

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Writing an executable script [SOLVED]

Post by Jasper »

I have made a small gif to demonstrate that it works. Sorry only set it for 4 seconds as I hoped I could upload here as an attachment but even that was 900kb+.

Terminal opens up and runs the script.

https://gifyu.com/image/SEDFJ

The text box shows the code provided by rockedge.

All I did was save it with the filename provided. Then right clicked on the file and choose the option below.

Last edited by Jasper on Sat Nov 12, 2022 7:03 pm, edited 1 time in total.
User avatar
fredx181
Posts: 3110
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Writing an executable script [SOLVED]

Post by fredx181 »

@Jasper Ah yes, you select 'run in terminal' that's ok, the script I suggested has the purpose to be able to just "click" on the script and it should open a terminal, but fine how you do it, of course.

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Writing an executable script [SOLVED]

Post by Jasper »

@fredx181

I have added your tips and I can confirm simply clicking on the file does run the script automatically.

Is there a way to keep the terminal visible?

It's fine for a single file, but it might be handy to have open when I have several links for eg for a drama series.

BTW I always the "Worst Audio" option as it's go enough for the phone and headphones to listen to. They always seem to improve the audio playback.

Also, I use yt-dlp as some programmes only allow you to download podcasts in high quality only.

It's not that important, I can trust the PC to do the job :lol:

**EDIT** just given it an icon to itself :roll: :lol:

User avatar
rockedge
Site Admin
Posts: 6571
Joined: Mon Dec 02, 2019 1:38 am
Location: Connecticut,U.S.A.
Has thanked: 2779 times
Been thanked: 2650 times
Contact:

Re: Writing an executable script [SOLVED]

Post by rockedge »

@fredx181 I could have added the code to open up a terminal on a click I suppose. Haven't tried it.

I am trying to figure out why the menu's in F96-CE are missing so many applications. Like Menu->Internet is almost completely empty.
(I need to consult @dimkr)

@Jasper If it ran in a terminal invoked in the script it would remain.

User avatar
fredx181
Posts: 3110
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Writing an executable script [SOLVED]

Post by fredx181 »

Jasper wrote:

Is there a way to keep the terminal visible?

Yes, try the -hold option, so then e.g : urxvt -hold -e <yourcommandline>
EDIT: Can't test urxvt at the moment . but think -hold should work (or should it be --hold perhaps :?: , not sure).

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Writing an executable script [SOLVED]

Post by Jasper »

Thank you again :thumbup:

I am not 100% sure it does work, simply as I am only grabbing a single file at the moment.

I will have to add multiple url's to verify also the downloads are tiny at only 10mb or less each. So on a fast connection it completes the task quickly.

User avatar
fredx181
Posts: 3110
Joined: Tue Dec 03, 2019 1:49 pm
Location: holland
Has thanked: 378 times
Been thanked: 1329 times
Contact:

Re: Writing an executable script [SOLVED]

Post by fredx181 »

Jasper wrote: Sat Nov 12, 2022 7:48 pm

I will have to add multiple url's to verify also the downloads are tiny at only 10mb or less each. So on a fast connection it completes the task quickly.

Your yt-dlp command line works well for me to get very small size audio files, despite the error that sometimes I see about "thumbnail not found" (or something) the image shows for me when playing the audio with VLC.

User avatar
Jasper
Posts: 2097
Joined: Wed Sep 07, 2022 1:20 pm
Has thanked: 858 times
Been thanked: 490 times

Re: Writing an executable script [SOLVED]

Post by Jasper »

Apologies, I didn't read your earlier message re:thumbnail.

There are two options to include the embedding of thumbnails.

Mutagen or Atomic Parsley.

Both I believe work in conjunction with FFMpeg.

Personally, I think Mutagen works best.

Yt-dlp will look for Mutagen first, if not found then will use Atomic Parsley.

Attached to my message.

You only need Mutagen. I just added Atomic Parsley as a backup.

Post Reply

Return to “REQUESTS”