Firefox 16, a treat for developers http://t.co/cnd27CzT
Write your own Youtube music downloader script
It’s an undeniable fact that Youtube is one of the top three most visited websites in the world. Many people upload their personal moments, funny stuff, cover songs, podcasts, screencasts etc, all globally shared over the Internet.
These videos are supposed to be public property and for personal use only. But honestly, I can’t think of how many times I’ve visited Youtube to listen my favourite song or just keep following a random channel’s playlist full of copyrighted music. So the questions is ….
Is it legal to download videos from Youtube ?
Yes and no. Technically if you take a look under temp files of Ubuntu, the video you ‘re watching is already downloaded or at least there are some bunch of hidden data related with it. But just saying it is yours is a completely another thing. In general, if you already own the material, then it is okay (e.g. like ripping music from CDs to import mp3 files into your portable player). Although, nowadays there are so many different laws depending on your country/region, Youtube’s policy, music industry, MPAA/RIAA, ACTA, civil rights … and make things even more complicated. So please, before you download anything, make sure that this video is not copyrighted before you start downloading.
This article aims to show you the power of terminal, not enabling you into illegal activities. Thus, downloading copyrighted video or using it for personal profit (i.e. selling CDs with copyrighted material) is not acceptable.
Please use this guide for educational purposes only
Gathering dependencies
To download video from Youtube we are going to use the Youtube-dl and in order to convert the video file into audio (mp3) we will use the ffmpeg. So make sure you have both of these two applications installed correctly on your system. The following instructions are based in Ubuntu Precise Pangolin 12.04 LTS / Oneiric Ocelot 11.10.
sudo apt-get install youtube-dl sudo apt-get install ffmpeg libavcodec-extra-53
Writing the script
Open your favourite text editor (VI, Emacs, Nano, Kate, whatever tastes you better). Personally, I prefer gedit. Please type the following command:
gedit myscript.sh
It’s super easy to understand the commands I used here – please do and feel free to make any customizations according to your needs. This script asks you what artist and song do you want, then it searches for it and then downloads it from Youtube. Last but not least, ffmpeg converts your video (probably *.flv type) into an mp3 file using parameters for proper naming. Finally, your mp3 now moves into your /home/yourname/Music folder.
#!/bin/bash
echo What is the artist of the song?
read ARTIST
echo What is the name of the song?
read NAME
echo "##################################"
echo "#### P L E A S E W A I T ###"
echo "##################################"
mkdir temp && cd temp
youtube-dl "ytsearch:$ARTIST $NAME album version"
ffmpeg -i *.flv -aq 2 "${ARTIST} - ${NAME}.mp3"
rm -rf *.flv
cd .. && mv temp/*.mp3 $PWD && rm -rf temp
mv *.mp3 ~/Music/
echo Your song has been downloaded successfully
Running the script
In order to run the script you have to own the execution privileges. To do so, please type the following commands to add +x (execution) and run (./) the script:
chmod +x music1.sh ./music
As you can see from the script’s commands, we used only legal means to download music from Youtube. However this doesn’t make your download activity legal. Blame the act, not the tools. We just aim to show you how much powerful the command line is ;)
Proof of Concept
Now, if you knew me better, you would know that I love Pink Floyd and rock/metal music in general. I have all of their albums and a couple of T-Shirts from the “Wish you were Here” and “The Wall”. So does this make me owner-enough in order to download Comfortably Numb? I have paid the money for purchasing the CD, but again, law can be tricky sometimes, so we don’t recommend you to fool around with any copyrighted material. Let me say it once more: Unixmen.com has no responsibility for any illegal activities using this script.

Make your own customizations
Please feel free to make any necessary changes according to your needs. Let me share some of my own alternatives here:
Create a new txt file with all Youtube links you want to download and convert into mp3 and put it in the same directory with the script file. Here goes the code:
#!/bin/bash echo "Type the filename:" read FILENAME mkdir temp && cp $FILENAME temp/ && cd temp youtube-dl -i --max-quality=FMT -o "%(stitle)s" -a $FILENAME rm $FILENAME && cd .. for file in temp/*; do ffmpeg -i $file -aq 2 $PWD/$file.mp3 ; done mv temp/*.mp3 $PWD && rm -rf temp echo "Your videos are finally converted into mp3!"
For those who love the playlist stuff here is another way ;)
#!/bin/bash echo Enter the youtube PLAYLIST url to begin download read PLAYLIST mkdir temp && cd temp youtube-dl -cit $PLAYLIST for file in *; do ffmpeg -i $file -aq 2 $file.mp3 ; done rm -rf *.flv *.mp4 cd .. && mv temp/*.mp3 $PWD && rm -rf temp echo Done! Enjoy!
Troubleshooting
The most common errors are spotted in the ffmpeg missing codec. Please google your error and fix your ffmpeg problem or compile the package manually. If ffmpeg is not a problem, then try to update yourube-dl. If non of these worked and you still have problem, take a look at the code. There are many available video formats in Youtube, but this scripts works only with flv. So if you encounter any mpeg, make your own changes in the code.
-
-
http://www.facebook.com/Daviek19
Like us on Facebook
This week Top Posts 
Top Things to do After Installing Ubuntu 13.04 ‘Raring Ringtail’ : Ubuntu 13.04 Raring Ringtail final is almost out. The final release it scheduled for release on Apri...0 comment(s) |
Install lamp with 1 command in Ubuntu 12.10, 13.04 Raring Ringtail & LinuxMint13 : Updated: 10/09/2012 :LAMP (Linux, Apache, MySQL and PHP) is an open source Web development platform ...0 comment(s) |
Howto: Upgrade to Ubuntu 13.04 Raring Ringtail from 12.04, 12,10 | Desktop & Server : Updated 05-04-2013: Ubuntu 13.04 Raring Ringtail will be released Soon, If you have ubuntu 12,10, 12...0 comment(s) |
Install and Configure Samba share in Ubuntu 13.04 Raring Ringtail , 12.10, 12.04| Howto : Updated 05-04-2013: One of the most asked features for Samba is a graphical user interface to help w...0 comment(s) |
How to Find Default Gateway in Linux : A gateway is a node or a router that acts as an access point to passes network data from local netwo...0 comment(s) |
How to use Remote Desktop in Ubuntu : Sometimes, we need to access our computer from other locations when we’re not at home and such. This...0 comment(s) |
Recent Posts
- Setup the Raspberry Pi as a NAS
- How to Monitor Filesystem Events with incron
- Useful Commands for Linux Users – Episode 6
- Deadly Linux Commands
- Determine Your Specifications from Command-Line
- Automatically Change the Desktop Wallpaper Using Variety on Ubuntu/Linux Mint
- How to Find Default Gateway in Linux
- Setup Backup Server Using rsnapshot
- How to Disable/Change Default PDF Viewer in Mozilla Firefox
- Dictionaries in Python
Recent Comments



















cave
| #
it can be used to talk or chat through the internet,
it is using strong encryption.
but for example TOR is using some obfuscation because some countrys try to block all outgoing connections which can not be scanned with DPI
And the TOR Project is facing an arms race in obfuscation and encryption detection.
cave
| #
You can friend someone if you give him your public Certificate.
both peers must friend each other.
i suggest to not enter a valid e-mail address. it is not necessary, but pgp needs a mail addy. something@something.so fits perfectly… :)
http://redd.it/18vsq5 <– faq, featurelist, todo, howto, useful links to manual wiki etc, …
you can connect to chatservers, which will give you access to chatlobby, where always some people are lurking.
#1 https://www.f2f-fr.net/w2c/en/
#2 http://retrosharechatserver.no-ip.org/w2c/en/
and in this rooms, you can find other people to talk and friend.
cave
| #
http://redd.it/18vsq5
please have a look at this link. it is a FAQ, QuickTip, HowTo, etc etc etc …
If you want to make friends, please use the Chatservers.
#1 https://www.f2f-fr.net/w2c/en/
#2 http://retrosharechatserver.no-ip.org/w2c/en/
if you enter your certificate, the chatserver adds you as his friend and shows his certificate too add him to your friends.
After the connection to the chatservers is established, you can join a few chatrooms where the chatserver is lurking.
in this rooms are other people too help you and make first friends and get into the network.
add friends only with wisdom. if you friend some policeman, it will be problematic like in real life.
best is to add only people you trust in real life or trust from other communitys too. and not to add random unkown strangers.
If you have questions, ask them in the chatlobbys, there is always someone to answer them.
please read http://redd.it/18vsq5
or question me here :)
Ladi Oyekanmi
| #
Could you please assist in step by step on how to install nagios on solaris
Adhraa
| #
Greate tutorial :)