Welcome!
Important information
-- Spectre and Meltdown vulnerabilities
-- Change in MX sources

News
-- MX Linux on social media: here
-- Mepis support still here

Current releases
-- MX-17.1 Final release info here
-- antiX-17 release info here

New users
-- Please read this first, and don't forget to add system and hardware information to posts!
-- Here are the Forum Rules

[Tutorial] Streamline the use of Youtube-dl

Message
Author
User avatar
handy
Forum Regular
Forum Regular
Posts: 112
Joined: Mon Apr 23, 2018 2:00 pm

[Tutorial] Streamline the use of Youtube-dl

#1 Post by handy » Thu Jun 07, 2018 6:36 am

Note: Please post any problems you have with this lot in this thread?

How to make Youtube-dl even easier to use.

This tutorial describes the usage of a very short & simple bash script (provided & created by unknown), which is made even quicker/easier to use via adding a simple ~/.bashrc alias (also provided). When called, the script allows the user to paste (or manually enter) the URL of the desired video into the terminal, hit enter & youtube-dl does its thing.

If that interests you, then read on?

1. Be sure that you have youtube-dl on your system (if you don't it is in the repos).

2. Open your text editor as user (NOT root) & copy the following script into it, after which save the script as yt-dl.sh (or any name you choose) to either your ~/ OR /usr/bin directories.

Code: Select all

 #!/bin/bash
#
# I run this from ~/.bashrc with the following alias:
# alias dv="sh ./yt-dl.sh"
# youtube-dl is set in its ~/.config/youtube-dl/conf file to download to
# ~/data/downloads/vid-tmp ON MY SYSTEM so if you need to modify that config file to suit you.  

echo Please, Enter a URL
read URL
/usr/bin/youtube-dl --prefer-free-formats $URL
3. Make the script executable with the following terminal command (example uses path to /home/user directory ~/ ):

Code: Select all

chmod +x ~/yt-dl.sh
4. Enter the following at the terminal prompt:

Code: Select all

sh ./yt-dl.sh
it should run the script & show the following output:

Code: Select all

Please, Enter a URL
If you see that then the script is installed & functioning. :) You can copy & paste the URL from your browser for youtube & a number "brands" of videos that you can find on the web.

5. If you haven't done so yet, now is a good time to edit your ~/.config/youtube-dl/conf file & set the path to where you want your youtube-dl downloaded videos to end up. Following is a copy of my conf file. (The youtube-dl man page has an enormous number of options available, so if you need to do something special, you probable can.):

Code: Select all

# youtube-dl config file:

# displays numeric menu to choose file type for save file:
#-F

# recode video to chosen format:
#--recode-video mp4

# Make the path what suits you - like ~/Video would be popular I think
# --output "~/Video/%(title)s.%(ext)s"
--output "~/data/downloads/vid-tmp/%(title)s.%(ext)s"
6. Now we can make a ~/.bashrc alias (as you would have read about in my comments in the script earlier in this text). I use the alias dv as it has meaning to me & the letters are close together too. You can use any alias that suits you, so edit to suit yourself.

Here is my alias to call ~/yt-dl.sh script (change the path to suit where you put yours):

Code: Select all

alias dv="sh ./yt-dl.sh"
As user (NOT root) open ~/.bashrc in your text editor & paste in the above alias (anywhere that suits you). Don't forget to be sure to modify the path if you need to. Save the file.

7. You need to start or restart your terminal to get it to reread the changed ~/.bashrc so you can test your new alias.
Once you have done that entering dv (or whatever alias you chose) will run the yt-dl.sh script.

So that's it for this how-to. Apart from one other little thing.

You can add another alias to your ~/.bashrc so that in future if you edit it, you don't have to restart the terminal to be able to use your modified ~/.bashrc

Add the following to your ~/.bashrc

Code: Select all

# reinitialises the Terminal so as to be able to use any changes made to the .bashrc

alias src="clear & source ~/.bashrc"		
After you have done that, save it. Now you can either paste the following into your terminal:

Code: Select all

clear & source ~/.bashrc
Or, just restart it. After that you'll be able to just type in src instead of restarting it.

OK, I'm done now -- enjoy
Last edited by handy on Mon Aug 06, 2018 8:37 am, edited 1 time in total.
Clevo N'book (2014): P150SM-A
CPU: i7-4810MQ (Haswell) Speed: 2800/3800 MHz
RAM: 16 GiB 1600 MHz DDR3
GPU-1: i915
GPU-2: NVIDIA GK104M [GeForce GTX 880M] vRAM: 8GB 2500 Mhz DDR5
Storage: TOSHIBA 931.51 GiB. HGST 931.51 GiB. Crucial 223.57 GiB (M.2 SSD)

User avatar
rich
Forum Regular
Forum Regular
Posts: 296
Joined: Sat Mar 31, 2018 6:39 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#2 Post by rich » Thu Jun 07, 2018 8:10 pm

Looks pretty handy! (no pun intended.) Now I won't have to rely on bash history for my youtube-dl commands. And maybe finally set up a default download location... thanks!
MX 17.1 Dell Inspiron N5110

User avatar
richb
Administrator
Posts: 17104
Joined: Wed Jul 12, 2006 2:17 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#3 Post by richb » Thu Jun 07, 2018 8:11 pm

The youtube.dl gui works fine for me.
Forum Rules
Guide - How to Ask for Help

Rich
SSD Production: MX 17.1
AMD A8 7600 FM2+ CPU R7 Graphics, 16 GIG Mem. Three Samsung EVO SSD's 250 GB, 350 GB HD

User avatar
rich
Forum Regular
Forum Regular
Posts: 296
Joined: Sat Mar 31, 2018 6:39 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#4 Post by rich » Thu Jun 07, 2018 8:13 pm

That definitely works, too
MX 17.1 Dell Inspiron N5110

User avatar
handy
Forum Regular
Forum Regular
Posts: 112
Joined: Mon Apr 23, 2018 2:00 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#5 Post by handy » Fri Jun 08, 2018 12:15 am

@richb, If I can do something efficiently in the terminal when there is a GUI alternative, I'll usually go with the terminal. That's not to say I'm really a terminal dude, just a "bit" of a terminal dude. ;) (Don't go much on windows & icons for getting around directory/file structures either really... In a small minority I know, that's OK. :) )

I just thought, there's something that I could mention that relates to the above: When my system starts (Openbox/Tint2) it automatically opens the Sakura teminal on desktop 5, & Worker - file manager, on desktop 3. So for me to use the terminal to do anything it is just a matter of scrolling my mouse in the 1 pixel wide screen border on the right hand side, OR selecting the desktop 5. with my mouse in Tint2 & I'm there. "There", being somewhere which is a part of my normal day to day computer environment.

Anyway /blah blah...
Last edited by handy on Fri Jun 08, 2018 3:29 am, edited 1 time in total.
Clevo N'book (2014): P150SM-A
CPU: i7-4810MQ (Haswell) Speed: 2800/3800 MHz
RAM: 16 GiB 1600 MHz DDR3
GPU-1: i915
GPU-2: NVIDIA GK104M [GeForce GTX 880M] vRAM: 8GB 2500 Mhz DDR5
Storage: TOSHIBA 931.51 GiB. HGST 931.51 GiB. Crucial 223.57 GiB (M.2 SSD)

skidoo
Forum Regular
Forum Regular
Posts: 867
Joined: Tue Sep 22, 2015 6:56 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#6 Post by skidoo » Fri Jun 08, 2018 1:50 am

richb wrote:
Thu Jun 07, 2018 8:11 pm
The youtube.dl gui works fine for me.
:mad:
pointless to click "Report This Post" in response to tripe posted by ADMINISTRATOR
xxx raining on the dude's parade and potentially de-motivating him?

handy, thanks for sharing your work.
Last edited by rich on Fri Jun 08, 2018 2:36 am, edited 1 time in total.

User avatar
handy
Forum Regular
Forum Regular
Posts: 112
Joined: Mon Apr 23, 2018 2:00 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#7 Post by handy » Fri Jun 08, 2018 3:35 am

@skidoo, No need to defend. I don't really care how other people use their computers, so long as nobody makes me use mine a way that I don't want to. :)

@richb, Beyond that, I've written a stack of wiki pages for the Manjaro wiki (the OP in this thread is original), many of them could be modified to suit MX. I don't know whether such is desired here or not?
Clevo N'book (2014): P150SM-A
CPU: i7-4810MQ (Haswell) Speed: 2800/3800 MHz
RAM: 16 GiB 1600 MHz DDR3
GPU-1: i915
GPU-2: NVIDIA GK104M [GeForce GTX 880M] vRAM: 8GB 2500 Mhz DDR5
Storage: TOSHIBA 931.51 GiB. HGST 931.51 GiB. Crucial 223.57 GiB (M.2 SSD)

User avatar
asqwerth
Forum Veteran
Forum Veteran
Posts: 3352
Joined: Sun May 27, 2007 5:37 am

Re: [Tutorial] Streamline the use of Youtube-dl

#8 Post by asqwerth » Fri Jun 08, 2018 4:43 am

handy wrote:
Fri Jun 08, 2018 3:35 am
...I've written a stack of wiki pages for the Manjaro wiki (the OP in this thread is original), many of them could be modified to suit MX. I don't know whether such is desired here or not?
It's always good to have more useful tutorials for MX. I remember using your simple steps posted in the old Manjaro forum to set up the bash alias for clearing the package cache of everything but the most recent 3 versions.

Which of the wiki pages were written by you and what's their subject matter?
Desktop: Intel i5-4460, 16GB RAM, Intel integrated graphics
Clevo N130WU-based Ultrabook: Intel i7-8550U (Kaby Lake R), 16GB RAM, Intel integrated graphics (UEFI)
ASUS X42D laptop: AMD Phenom II, 6GB RAM, Mobility Radeon HD 5400

User avatar
handy
Forum Regular
Forum Regular
Posts: 112
Joined: Mon Apr 23, 2018 2:00 pm

Re: [Tutorial] Streamline the use of Youtube-dl

#9 Post by handy » Fri Jun 08, 2018 5:49 am

@asqwerth, here's a list of what's in my local directory backup:

Code: Select all


Add.a.storage.partition.&.modify.your.system.to.suit.txt*
Add.Swapfile.txt*
Allserver.sh.Script.txt*
A.Rough.Guide.to.Wiki.Page.Creation.&.Formatting.txt*
Autostart.X.at.Login.OpenRC.&.SystemD.txt*
Avidemux-Cutting.out.sections.of.video.txt*
Blocklists.for.Deluge.&.qBittorrrent.txt*
Change.the.Colours.of.your.GTK.themes.txt*
Check.a.downloaded.ISO.image.for.errors.txt*
Cloning.partition.with.dd.txt
Configure.Graphics.Cards-Manjaro.txt*
Did.X.server.Recognise.Your.Monitor.txt*
Downgrading.packages.with.Pacman.&.friends.txt*
E_exFAT.File.System.txt*
ENCFS.txt*
Firefox.about-config.Edits.txt*
Firefox_clear.HSTS.Settings.txt*
Firefox.Customisation.txt*
How-to.check.MD5.checksums.txt*
How.to.turn.OFF.IPv6.txt*
How.to.use.ALSA.sound.with.applications.that.depend.on.Pulseaudio.txt*
Important.Hidden.dot.files.txt*
iPhone.2.PC_pictures.txt* (for my wife when she moved to an android phone)
MAC.address.spoofing.txt*
Maintaining.var.cache.pacman.pkg.txt*
Make.AlsaMixer.keep.its.sound.settings.txt
Make.GRUB.menu.&.boot.up-down.fonts.bigger.txt*
Management.of.the.systemd.journal.&.of.log.files.txt*
Managing.var.log.files
Mhwd.kern.sh.txt*
Mount.HFSplus.Partition.txt*
Nano.editing.keys.txt*
Ob-autostart.a.simple.GUI.txt*
Openbox.dock.with.the.Lal.Clock.&.Trayer.txt*
OpenRC.an.alternative.to.systemd.txt*
Orphan.Package.Removal.txt*
Overview.of.a.Tor.squid.server.txt*
Pacman.Tips.txt*
Pacman.troubleshooting.txt*
PIA-VPN-installation.under.varying.circumstances.txt*
PM.sh_Use.pmount.to.mount.external.media.txt
Prevent.DNS.cache.poisoning.txt*
Qt5ct.txt
Restore.the.GRUB.bootloader.txt*
Reverse.SSH.tunnels.to.forward.ports.txt*
Set.Qt.apps.to.use.GTK+.theming.txt*
Setting.the.default.sound.device.txt <<<*
Setting.up.IPCop.txt*
Setting.up.Windows.NTP.txt*
Set.up.an.NTP.cronjob.txt*
Setup.internet.DHCP.txt*
Simple.fix.for.screen.tearing-nVidia.txt*
Squid.txt*
Squid.web.object.cacher.txt*
SSH-how-to.access.my.ReadyNAS.txt*
Steam_No.Sound.txt*
Steam.without.Network.Manager.txt*
Streamline.youtube-dl.terminal.usage.txt
Synergy.Mouse.&.Keyboard.Sharing.txt*
Systemd.autostart.NFS.fstab.txt*
System.Time.Setting.txt*
Tor.anonymisation.txt*
Turn.OFF.IPv6.txt*
Use.IP.instead.of.ifconfig.txt
Users.&.Groups.txt*
Using.Downgrade.txt*
Using.HandBrakeCLI.txt*
Videofunnel.jpg*
WD-Green.HDD.fix.Linux.txt*
wiki.adding.pictures.txt*
wiki.square.brackets.txt*
Worker.an.Introduction.txt*
Youtube-dl_Audio.only.txt*
I've written all but ~15 of the above list.

Some are Manjaro specific, some would now be redundant. Most I've bought up to date fairly recently as I spent ~35 hours setting up mediawiki on my notebook & got through to the one on the above list with the <<< marker at the end of its line. All of them up to there have been bought up to date. Unfortunately the Refracta distro shat itself & took down my mediawiki. I have a backup of the directory with all AMP stuff. I just haven't felt inclined to stick my head back into that one again, yet.

Anyway, the above gives you the titles, most of which are on the Manjaro wiki (in some form). The ones in the list down to the <<< should have been de-Manjaroed on my machine's backup now too as I was on Debian based distro when I set up my wiki. :)
Clevo N'book (2014): P150SM-A
CPU: i7-4810MQ (Haswell) Speed: 2800/3800 MHz
RAM: 16 GiB 1600 MHz DDR3
GPU-1: i915
GPU-2: NVIDIA GK104M [GeForce GTX 880M] vRAM: 8GB 2500 Mhz DDR5
Storage: TOSHIBA 931.51 GiB. HGST 931.51 GiB. Crucial 223.57 GiB (M.2 SSD)

User avatar
Jerry3904
Forum Veteran
Forum Veteran
Posts: 22483
Joined: Wed Jul 19, 2006 6:13 am

Re: [Tutorial] Streamline the use of Youtube-dl

#10 Post by Jerry3904 » Fri Jun 08, 2018 5:52 am

That's a great list, thanks for the offer! I can't do it for a couple of weeks, but we will need to go through and see what would be relevant and useful to the MX context.
Production: 4.15.0-1-amd64, MX-17.1, AMD FX-4130 Quad-Core, GeForce GT 630/PCIe/SSE2, 8 GB, Kingston SSD 120 GB and WesternDigital 1TB
Testing: AAO 722: 4.15.0-1-386. MX-17.1, AMD C-60 APU, 4 GB

Post Reply

Return to “Software / Configuration”