Skip to content

Instantly share code, notes, and snippets.

@jonath92
Last active March 1, 2024 11:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonath92/0f6bf4606bc8a34be1bb0826c99b73d1 to your computer and use it in GitHub Desktop.
Save jonath92/0f6bf4606bc8a34be1bb0826c99b73d1 to your computer and use it in GitHub Desktop.
Install-Update-Youtube-dl Linux Mint
# This is a simple script for install youtube-dl and creating a script in /etc/cron.daily
# to automatically update youtube-dl on a daily basis.
# can be executed with:
# sudo su -c "bash <(wget -qO- https://gist.githubusercontent.com/jonath92/0f6bf4606bc8a34be1bb0826c99b73d1/raw/914aabe6c4b15dc614f18c8816f5ad2828755c22/install-Update-Youtube-dl.sh)" root
# Remove apt version to prevent conflicts
apt purge -y youtube-dl
# Fix python not found error https://askubuntu.com/a/1149489/1013434
ln -s /usr/bin/python3 /usr/local/bin/python
# Install youtube-dl
# https://github.com/ytdl-org/youtube-dl#installation
curl -L https://yt-dl.org/downloads/latest/youtube-dl -o /usr/local/bin/youtube-dl
chmod a+rx /usr/local/bin/youtube-dl
# create script for daily update
UPDATE_PATH="/etc/cron.daily/update_youtube_dl"
touch ${UPDATE_PATH}
echo "#! /bin/sh" > ${UPDATE_PATH}
echo "youtube-dl --update" >> ${UPDATE_PATH}
chmod +x ${UPDATE_PATH}
# To uninstall youtube-dl run:
# sudo rm /usr/local/bin/youtube-dl /etc/cron.daily/update_youtube_dl
@vdbhb59
Copy link

vdbhb59 commented Sep 4, 2021

Does this still work? I keep getting update not found daily. :(

@jonath92
Copy link
Author

jonath92 commented Sep 4, 2021

It still works for me. All it does is to run youtube-dl --update every day (as root). These are the official installation instructions. So when there is something not working than it is something on your system I guess. Maybe reinstalling helps .... And obviously you need to be connected to the internet and not being behind some stupid blockade of a internet service provider or a ridiculous government (as in china).

@utilop
Copy link

utilop commented Nov 26, 2021

I don’t know, I couldn’t get it to work, everything is complicated.
How about replacing this with yt-dlp
https://github.com/yt-dlp/yt-dlp

@jonath92
Copy link
Author

jonath92 commented Nov 26, 2021

@bamper45 thanks for reporting and sorry for that. Youtube-dl is not deprecated and it is working on my machine. I think your Problem might be caused by someting else. Can you provide more information what is not working? I.e what is the output when running youtube-dl on your machine?

@utilop
Copy link

utilop commented Nov 26, 2021

@jonath92
Cjs-Message: 00:45:44.108: JS LOG: [LookingGlass/error] The following error occured at youtube download attempt: Error: /usr/bin/env: «python»: Нет такого файла или каталога
. The used download Command was: youtube-dl --output "/home/noob/%D0%97%D0%B0%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B8/%(title)s.%(ext)s" --extract-audio --audio-format mp3 ytsearch1:"Oasis - Some Might Say" --add-metadata --embed-thumbnail
Cjs-Message: 00:45:44.293: JS LOG: [LookingGlass/warning] Invalid or null source id used when attempting to run Mainloop.source_remove()
overrideDumpStack/global.dump_gjs_stack@/usr/share/cinnamon/js/ui/overrides.js:99:42
overrideMainloop/Mainloop.source_remove@/usr/share/cinnamon/js/ui/overrides.js:133:20
_updateNotificationTimeout@/usr/share/cinnamon/js/ui/messageTray.js:1106:22
_showNotificationCompleted@/usr/share/cinnamon/js/ui/messageTray.js:1095:14
_tweenComplete@/usr/share/cinnamon/js/ui/messageTray.js:1007:24
_addHandler/params[name]@/usr/share/cinnamon/js/ui/tweener.js:256:24
_callOnFunction@resource:///org/gnome/gjs/modules/script/tweener/tweener.js:208:16
_updateTweenByIndex@resource:///org/gnome/gjs/modules/script/tweener/tweener.js:339:24
_updateTweens@resource:///org/gnome/gjs/modules/script/tweener/tweener.js:352:18
_onEnterFrame@resource:///org/gnome/gjs/modules/script/tweener/tweener.js:367:10
_emit@resource:///org/gnome/gjs/modules/core/_signals.js:133:47
_onNewFrame@/usr/share/cinnamon/js/ui/tweener.js:413:14
_init/<@/usr/share/cinnamon/js/ui/tweener.js:389:22

Cinnamon warning: Buggy client sent a _NET_ACTIVE_WINDOW message with a timestamp of 0 for 0x72000f8 (.xsession-)

@utilop
Copy link

utilop commented Nov 26, 2021

@jonath92
Yutoube-dl has not been updated for many months, it works for me through the terminal, but the speed is not more than 50 / kb, like most. This development seems to have been abandoned. Now yt-dlp is working as it should.

@utilop
Copy link

utilop commented Nov 26, 2021

@jonath92
Снимок экрана от 2021-11-27 00-59-14
yt-dlp speed

@jonath92
Copy link
Author

@bamper45 You are right youtube-dl has indeed not been uploaded since month. I will consider switching to the fork you mention in the Radio applet tomorrow but I think there is also a Bug in the applet which is indepent of youtube-dl. Can you tell me which folder you have set in the applet settings for the music download directory?

@jonath92
Copy link
Author

@bamper45 the youtube-dl is not working in the radio applet due to a Bug in Cinnamon when using non UTF-8 characters in folder names. See: linuxmint/cinnamon#10487. I think the download should work when you use a different download folder.

@utilop
Copy link

utilop commented Nov 27, 2021

@jonath92 Yes, I used the downloads folder (name in Russian) maybe because of this. And yes, I also found a folder in my home directory like this "% D1% 82% D0% B0% D0% BA% D0% BE% D0% B3% D0% BE" and it contained 2 tracks (similar to this program )
Now I cannot change and double-check, but then I will write.
Thanks for the answer!

@jonath92
Copy link
Author

@bamper45 You are welcome. Feel free to click the like Button on https://cinnamon-spices.linuxmint.com/applets/view/297 as this helps me to increase my Reputation as a Software developer ;-)

@jimalex71
Copy link

jimalex71 commented Sep 28, 2022

Downloading with youtube-dl works but the log says the file can't be copied from tmp.

Gjs-Message: 15:05:36.113: JS LOG: [LookingGlass/error] Failed to copy download from tmp dir. The following error occurred: Error moving file /tmp/.123AB1/abcdefghi.mp3: No such file or directory

@jonath92
Copy link
Author

What do you mean with "youtube-dl" works? Is the Song in the end downloaded to the directory you selected in the settings? Does the directory you selected in the settings exist? Because this is the only thing I can imagine throwing such Kind of error..

@FoulerTripod
Copy link

FoulerTripod commented Aug 14, 2023

downloading once worked but i got a .webp instead of .mp4 or .mp3 when i tried to update and reload the radio it would give me this error:
JS LOG: [LookingGlass/error] Failed to copy download from tmp dir. The following error occurred: Error: filename couldn't be determined.
And yes the file exists as it is in the download and i tried to create a new file changed the dir and it didnt work

@jonath92
Copy link
Author

Does it happens in some cases or always?

@FoulerTripod
Copy link

it always happened i first suspected it bcs of python i tried to re install everything it would get be the same error would i provide something that will be more useful? I am using Linux Mint

@jonath92
Copy link
Author

yeah no you are right I can reproduce it. This needs to be fixed. As a workaround you can use yt-dlp which you can select in the radio applet settings. and install by sudo su -c "bash <(wget -qO- https://gist.githubusercontent.com/jonath92/039e998b3d3f6ba4afd5d5c671eaedf1/raw/23542a3aadadf5ba181fb8aff723c27610551abd/install-update-yt-dlp.sh)" root

@jimalex71
Copy link

jimalex71 commented Aug 15, 2023

What do you mean with "youtube-dl" works? Is the Song in the end downloaded to the directory you selected in the settings? Does the directory you selected in the settings exist? Because this is the only thing I can imagine throwing such Kind of error..

I mean the MP3 is being created in a temp directory.

It's just not being moved to the destination directory.

Have not fired up the Linux machine in a while but will give it a go again asap.

@FoulerTripod
Copy link

Thank you Jonath92! I love how dedicated you are to the project and I hope one day i can do my own project. Thanks again!

@jonath92
Copy link
Author

You are more than welcome to contribute to the Code. When you have question, I am absolutely willed to help.

@FoulerTripod
Copy link

unfortunately my coding expertise is still minimal at this moment with the only languages i know are java and c++ but if you are interested in translating your applet to Arabic I am proficient in Arabic

@luckyshot
Copy link

For those having problems with youtube-dl, there's already a script to use yt-dlp here:

https://gist.github.com/jonath92/039e998b3d3f6ba4afd5d5c671eaedf1

Then right click Radio++ icon > Configure, go to Preferences tab and choose yt-dlp as the CLI tool.

Make sure the Download directory exists, I had to create the folder Radio or else it would fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment