graphics yt-dlp Front end

If you are looking for a specific 64-bit package and you can't find it in any of the 64-bit repos, please post a request for it here
vinnie
Shogun
Shogun
Posts: 211
Joined: 13 Jun 2024, 08:25
Distribution: alpine

graphics yt-dlp Front end

Post#16 by vinnie » 01 Feb 2025, 10:58

Ed_P wrote:
31 Jan 2025, 23:22
vinnie,
4) create a .desktop file. /usr/share/applications/ or /home/guest/Desktop/
...
Thanks for the tip, it may come in handy when I decide to save the session :D
Or maybe I should make /home/guest/.local/share/applications/ a symlink to a directory on the flash memory :hmmm:


Jack wrote:
01 Feb 2025, 00:50
I guest not young anymore Feb 9 I will be 77 years old and I'm losing my memory and I can't remember too.
Image
;)

Jack
Contributor
Contributor
Posts: 1955
Joined: 09 Aug 2013, 14:25
Distribution: Nemesis Cinnamon 64
Location: USA

graphics yt-dlp Front end

Post#17 by Jack » 01 Feb 2025, 16:10

ncmprhnsbl wrote:
01 Feb 2025, 05:23
aarch64 is for ARM based hardware, that is, smartphones, tablets, raspberrypi and the like. is why the "Exec format error".
look for x86_64 packages.
I learn something new so now I know.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

vinnie
Shogun
Shogun
Posts: 211
Joined: 13 Jun 2024, 08:25
Distribution: alpine

graphics yt-dlp Front end

Post#18 by vinnie » 03 Feb 2025, 13:16

Since on nemesis and I think also on porteus “dialog” is already preinstalled (I think because of some menus created by the authors), I merged a few lines of scripts to automate the use of yt-dlp:

Code: Select all

#!/bin/bash

#PATH TO yt-dlp EXECUTABLE
YTDLP="/home/guest/Downloads/ytdlp" #absolute path
down_dir="/home/guest/Downloads"
#yt-dlp relative to script variant
#start_dir="$(pwd)"
#script_dir="$(dirname ${0})" 
#YTDLP="${script_dir}/ytdlp" #relative to script position

#INPUT LINK
dialog --inputbox "Enter link (ctrl+shift+v to paste):" 10 40 2> /tmp/input.txt
LINK="$( cat /tmp/input.txt  )" # release contents of pipe
#LINK=$(xclip -o) #directly from clipboard variant

#LOAD FORMAT LIST
reset
echo "Retrieving link info, wait..."
OUTP=$($YTDLP -F "${LINK}") || exit
OUTP=$(echo -e "${OUTP}" | grep -v '^\[' | cut -c 1-50 | tail -n +3) # || (echo "error"; exit) # | tr " " "_") 

#CHOOSE FORMAT
let i=0 # define counting variable
W=() # define working array
while read -r line; do # process line by line
    let i=$i+1
    W+=($i "$line")
done < <( echo -e "${OUTP}" )
FILE=$(dialog --title "available formats" --menu "______ID______EXT___RESOLUTION_FPS_CH_|___FILESIZE___TBR__" 24 62 17 "${W[@]}" 3>&2 2>&1 1>&3) # show dialog and store output
RESULT=$?
clear
if [ $RESULT -eq 0 ]; then # Exit with OK
     #echo "${W[$((FILE * 2 -1))]}"
     CHOS=$(echo "${W[$((FILE * 2 -1))]}")
     NUMB=$(echo "${CHOS}" | cut -d " " -f1)
else
     exit
fi

#DOWLOAD VIDEO
echo -e "Donwload: ${CHOS}"
cd "$down_dir"
$YTDLP -f "${NUMB}" "${LINK}"
To use it one must:
1)edit the variable YTDLP with the path to your yt-dlp and the download directory
2)link this script to a keyboard shortcut (in xfce for example setting manager > keyboard > application shortcuts, you probably need to prepend terminal execution to the command shorcut, for example for xfce: xfce4-terminal -e “/path/to/script”)
3)use the shorctus and paste the video link, if you wanted you could automate the insertion of the link with “LINK=$(xclip -o)” variant.

Jack
Contributor
Contributor
Posts: 1955
Joined: 09 Aug 2013, 14:25
Distribution: Nemesis Cinnamon 64
Location: USA

graphics yt-dlp Front end

Post#19 by Jack » 03 Feb 2025, 16:04

Thanks for the scripts you made for me but there a problem

1 When I enter a link I enter a youtube link
2 l added ytdlp to /home/guest/Download/ytdlp

Then I receive this.

Code: Select all

Retrieving link info, wait...
ERROR: [generic] 'ownloads/ytdlp: Is a directory' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:ownloads/ytdlp: Is a directory" ) to search YouTube
guest@porteus:~/Documents$
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

vinnie
Shogun
Shogun
Posts: 211
Joined: 13 Jun 2024, 08:25
Distribution: alpine

graphics yt-dlp Front end

Post#20 by vinnie » 03 Feb 2025, 16:32

I get a "similar" error when instead of entering the youtube link I try to enter the path where I put ytdlp, so I think it's a yt-dlp error, example:

Code: Select all

[guest@porteus Downloads]$ ./ytdlp /home/guest/Downloads/ytdlp 
[generic] Extracting URL: /home/guest/Downloads/ytdlp
ERROR: [generic] '/home/guest/Downloads/ytdlp' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:/home/guest/Downloads/ytdlp" ) to search YouTube
I tried the script exactly as I put it in the forum and it works so let's try to figure out where the problem is.

With the preset settings if you put the executable “ytdlp” inside /home/guest/Downloads/ and launch the script (which you put in any other directory), the script should work.
Try using it this way from the terminal before trying to set up a keyboard shortcut to make sure it works.

Jack
Contributor
Contributor
Posts: 1955
Joined: 09 Aug 2013, 14:25
Distribution: Nemesis Cinnamon 64
Location: USA

graphics yt-dlp Front end

Post#21 by Jack » 03 Feb 2025, 16:50

Here is a few thing I did.

Code: Select all

PATH TO yt-dlp EXECUTABLE
YTDLP="yt-dlp" #absolute path
down_dir="/home/guest/Downloads/ytdlp"
#yt-dlp relative to script variant
#start_dir="$(pwd)"
#script_dir="$(dirname ${0})" 
#YTDLP="${script_dir}/ytdlp" #relative to script position


I try to fix it here the output.

Code: Select all

Retrieving link info, wait...
ERROR: [generic] 'Retrieving link info, wait...' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:Retrieving link info, wait..." ) to search YouTube
guest@porteus:~/Documents$ ERROR: [generic] 'ownloads/ytdlp: Is a directory' is not a valid URL. Set --default-search "ytsearch" (or run  yt-dlp "ytsearch:ownloads/ytdlp: Is a directory" ) to search YouTube
bash: syntax error near unexpected token `('
guest@porteus:~/Documents$
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

vinnie
Shogun
Shogun
Posts: 211
Joined: 13 Jun 2024, 08:25
Distribution: alpine

graphics yt-dlp Front end

Post#22 by vinnie » 03 Feb 2025, 17:28

Okay, if the executable “yt-dlp” is in your $PATH (if you can launch it just type it into your terminal) and if “/home/guest/Downloads/ytdlp” is a directory the script should work.
I tried renaming my executable to “yt-dlp” and put it in a dir that is in $PATH and it works.

I have the impression that the script somehow has some typo in it for this reason: "bash: syntax error near unexpected token `('"

For this reason I uploaded the script with the same modifications as yours to a filehosting.
1)Download it with this command:

Code: Select all

wget https://oshi.at/bXCn/ytdialog.sh
2)then check it to see if everything is ok (it's never a good idea to start scripts without taking a look)
3)then give it execution permissions with:

Code: Select all

chmod +x ytdialog.sh
4)try to run it

Jack
Contributor
Contributor
Posts: 1955
Joined: 09 Aug 2013, 14:25
Distribution: Nemesis Cinnamon 64
Location: USA

graphics yt-dlp Front end

Post#23 by Jack » 03 Feb 2025, 19:34

Will it downloaded video but there was no sound. There something pop up to pick screen size which one should I have pick? And maybe it had to do with sound to.
I just like Slackware because I think it teach you about Linux to build packages where Ubuntu is like Windows you just install programs you want.

vinnie
Shogun
Shogun
Posts: 211
Joined: 13 Jun 2024, 08:25
Distribution: alpine

graphics yt-dlp Front end

Post#24 by vinnie » 03 Feb 2025, 23:10

yes, after you give them the link to the video a list of possible formats to download should appear, they should be in order of quality and among them are audio only formats and those without audio.
you can use the up and down arrows to scroll through the format you want to download and after press enter.

But you actually pointed out to me that I made a mistake, I cut too much output from yt-dlp and you can't tell when the video is without audio.
just change two numbers in the code to fix the problem:
The number -50 you need to make it -89 and the number 62 you need to make it 101 (basically I added 39 characters).
So you see a longer line and it says even if it's “video only” at the bottom right.

vinnie
Shogun
Shogun
Posts: 211
Joined: 13 Jun 2024, 08:25
Distribution: alpine

graphics yt-dlp Front end

Post#25 by vinnie » 09 Feb 2025, 02:23

A few changes to the script.
Now it also works by double-clicking over the script, it opens an xterm window (with xfce4-terminal I couldn't do it).
Plus it allows you to choose to paste the link from the clipboard by clicking an additional third button.
And again I put in the ability to choose either a video format or an audio format or both an berge them.
The reason is that actually in the list of files to download I was seeing only one entry with audio and video together (id: 18) and so it seemed necessary to support merging (how strange, I remember when I was using youtube-dl there were many video options with audio).
dependency (all already in nemesis):
ffmpeg
dialog
xclipper
bash
...and xterm

Code: Select all

#!/bin/bash
function myfun() {
#YT-DLP PATH
YTDLP="./ytdlp"


#INPUT LINK
#LINK=$(xclip -o) #directly from clipboard
dialog --extra-button --extra-label "clipboard" --inputbox  "Enter link (ctrl+shift+v to paste or shift+insert):" 10 40 2> /tmp/input.txt
EXIT="$?" #0 ok, 3 clipboard, 1 cancel
LINK="$( cat /tmp/input.txt  )" # release contents of pipe


#CHECK IF LINK IS POPULATED OR EXIT
if [[ "$EXIT" -eq 1 ]]; then
	exit
elif [[ "$EXIT" -eq 3 ]]; then
	LINK=$(xclip -o) #directly from clipboard	
fi
if [ -z "${LINK}" ]; then exit; fi


#LOAD FORMAT LIST
reset
echo -e "\"${LINK}\" \nRetrieving info, wait..."
#dialog --pause "Retrieving link info, wait..." 10 40 0
OUTP=$($YTDLP -F -S tbr "${LINK}") || exit #size not work prpperly
OUTP=$(echo -e "${OUTP}" | grep -v '^\[' | cut -c 1-72 | tail -n +3) # || (echo "error"; exit) # | tr " " "_") 
#OUTP=$(echo -e "${OUTP}" | tail -n +3)


#SEPARATE AUDIO AND VIDEO IN ARRAYS
#LENG=$(echo "${OUTP}" | wc -l)
#HEAD=$(echo -e ${OUTP} | head -n 1)
#HEAD="      ID      EXT   RESOLUTION FPS CH |   FILESIZE   TBR"
let ia=0 # audio index counter
let iv=0 # video index counter
A=() # audio array #A+=(0 "nothing")
V=() # video array #V+=(0 "nothing")
#separate audio line from video and remove images
while read -r line; do # process line by line
    if [[ $line == *"images"* ]]; then
        continue
    elif [[ $line == *"audio only"* ]]; then
        let ia=$ia+1
        A+=(" $ia" "$line")
    else
        let iv=$iv+1
        V+=(" $iv" "$line")
    fi
done < <( echo -e "${OUTP}" )


#CHOSE FORMATS
#"______ID______EXT___RESOLUTION_FPS_CH_|___FILESIZE___TBR__"
AFILE=$(dialog --title "Choose Audio" --menu "" 25 62 0 "${A[@]}" 3>&2 2>&1 1>&3) # show dialog and store output
ARESULT=$?
clear
VFILE=$(dialog --title "Choose Video" --menu "" 25 62 0 "${V[@]}" 3>&2 2>&1 1>&3) # show dialog and store output
VRESULT=$?
clear


#TAKE ID
if [ $ARESULT -eq 0 ] || [ $VRESULT -eq 0 ]; then # Exit with OK
     #echo "${W[$((FILE * 2 -1))]}"
     if [ $ARESULT -eq 0 ]; then
     ACHOS=$(echo "${A[$((AFILE * 2 -1))]}")
     ANUMB=$(echo "${ACHOS}" | cut -d " " -f1)
     fi
     if [ $VRESULT -eq 0 ]; then
     VCHOS=$(echo "${V[$((VFILE * 2 -1))]}")
     VNUMB=$(echo "${VCHOS}" | cut -d " " -f1)
     fi
else
     exit
fi


#DOWLOAD MEDIA
if [ $ARESULT -ne 0 ]; then #without audio
    echo -e "Donwload video: ${VNUMB}"
    $YTDLP -f "${VNUMB}" "${LINK}"
elif [ $VRESULT -ne 0 ]; then #without video
    echo -e "Donwload audio: ${ANUMB}"
    $YTDLP -f "${ANUMB}" "${LINK}"
else #have both
    echo -e "Donwload video + audio: ${ANUMB} + ${VNUMB}"
    $YTDLP -f "${ANUMB}"+"${VNUMB}" "${LINK}" --merge-output-format mp4
fi
}


#RUN SCRIPT
#in this way it's possible to run this script with double click or launch it without specify a terminal for shortcut execution
#xfce4-terminal  -e "$(typeset -f myfun) #don't work with xfce4-terminal
export -f myfun
xterm -geometry 64x26 -ls -xrm 'XTerm*selectToClipboard: true' -e "$(declare -f myfun);myfun" &

Post Reply