Downloading youtube videos with youtube-dl

October 4, 2014 Leave a comment

Problem:
I wanted to download lots of youtube videos, but I did not want to do so by my usual watch and download method.

Solution:
youtube-dl is a small command-line program to download videos from YouTube.com and a few more sites.

A short feature list of things you can do.

1. You can download entire playlists.

user@computer:~/lectures/discrete_maths$ youtube-dl --rate-limit 4M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx
 PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx: Downloading webpage
[download] Downloading playlist: Discrete Mathematics
 playlist Discrete Mathematics: Collected 19 video ids (downloading 19 of them)
[download] Downloading video #1 of 19
 Setting language
 Confirming age
 h_9WjWENWV8: Downloading webpage
 h_9WjWENWV8: Downloading video info webpage
 h_9WjWENWV8: Extracting video information
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 1_20-h_9WjWENWV8.mp4
[download]  42.6% of 184.48MiB at 525.55KiB/s ETA 03:26

2. You can interupt and continue from where you stopped.

user@computer:~/lectures/discrete_maths$ youtube-dl --rate-limit 1M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx
 PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx: Downloading webpage
[download] Downloading playlist: Discrete Mathematics
 playlist Discrete Mathematics: Collected 19 video ids (downloading 19 of them)
[download] Downloading video #1 of 19
 Setting language
 Confirming age
 h_9WjWENWV8: Downloading webpage
 h_9WjWENWV8: Downloading video info webpage
 h_9WjWENWV8: Extracting video information
[download] Resuming download at byte 82488037
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 1_20-h_9WjWENWV8.mp4
[download] 100% of 184.48MiB in 03:22
[download] Downloading video #2 of 19
 BrDto0heyaQ: Downloading webpage
 BrDto0heyaQ: Downloading video info webpage
 BrDto0heyaQ: Extracting video information
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 2_20-BrDto0heyaQ.mp4
[download]  20.7% of 221.93MiB at 529.26KiB/s ETA 05:40^C
ERROR: Interrupted by user

user@computer:~/lectures/discrete_maths$ youtube-dl --rate-limit 1M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx
 PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx: Downloading webpage
[download] Downloading playlist: Discrete Mathematics
 playlist Discrete Mathematics: Collected 19 video ids (downloading 19 of them)
[download] Downloading video #1 of 19
 Setting language
 Confirming age
 h_9WjWENWV8: Downloading webpage
 h_9WjWENWV8: Downloading video info webpage
 h_9WjWENWV8: Extracting video information
[download] Arsdigita 02 (Discrete Mathematics) Lecture 1_20-h_9WjWENWV8.mp4 has already been downloaded
[download] Downloading video #2 of 19
 BrDto0heyaQ: Downloading webpage
 BrDto0heyaQ: Downloading video info webpage
 BrDto0heyaQ: Extracting video information
[download] Resuming download at byte 48193596
[download] Destination: Arsdigita 02 (Discrete Mathematics) Lecture 2_20-BrDto0heyaQ.mp4
[download]  48.0% of 221.93MiB at 533.93KiB/s ETA 03:41^C
ERROR: Interrupted by user

It tracks where you reached in the play list and when you restart is skips through videos that have been downloaded and proceeds from there.

3. You can limit the amount of bandwidth that is used.

Download Options:
-r, –rate-limit LIMIT maximum download rate in bytes per second
(e.g. 50K or 4.2M)

youtube-dl --rate-limit 1M https://www.youtube.com/playlist?list=PLTdIp1DywMlUpLHEg3ADhE6rrxhW_T5Rx

Subtitle Options:
–write-sub write subtitle file
–write-auto-sub write automatic subtitle file (youtube
only)
–all-subs downloads all the available subtitles of
the video
–list-subs lists all available subtitles for the video
–sub-format FORMAT subtitle format (default=srt) ([sbv/vtt]
youtube only)
–sub-lang LANGS languages of the subtitles to download
(optional) separated by commas, use IETF
language tags like ‘en,pt’

4. You can check for available subtitles.

user@computer:~/Movies$ youtube-dl --list-subs http://www.youtube.com/watch?v=9RPWATPdImw
 Setting language
 Confirming age
 9RPWATPdImw: Downloading webpage
 9RPWATPdImw: Downloading video info webpage
 9RPWATPdImw: Extracting video information
 9RPWATPdImw: Looking for automatic captions
 9RPWATPdImw: Downloading XML
WARNING: Video doesn't have automatic captions
 9RPWATPdImw: Available subtitles for video: en
 9RPWATPdImw: Available automatic captions for video:

5. You can download movie with available subtitles.

user@computer:~/Movies$ youtube-dl --all-subs http://www.youtube.com/watch?v=9RPWATPdImw
 Setting language
 Confirming age
 9RPWATPdImw: Downloading webpage
 9RPWATPdImw: Downloading video info webpage
 9RPWATPdImw: Extracting video information
[info] Writing video subtitles to: [English Sub] Jet Li 2011 Flying.Swords.Of.Dragon.Gate [turn on caption for sub]-9RPWATPdImw.en.srt
[download] Destination: [English Sub] Jet Li 2011 Flying.Swords.Of.Dragon.Gate [turn on caption for sub]-9RPWATPdImw.mp4
[download] 100% of 431.77MiB in 12:32

Source:
http://rg3.github.io/youtube-dl/index.html

E: Internal Error, No file name for gdb:amd64

October 2, 2014 Leave a comment

Problem:

I was trying to install FLTK on 64bit debian and was installing one of the prerequisites gdb when I got the following error

E: Internal Error, No file name for gdb:amd64

Solution:
My friend google had this as a solution that worked for me. (Although it would be nice if I knew what it means.)

dpkg -i /var/cache/apt/archives/*.deb
dpkg --configure -a 

Source:
http://askubuntu.com/questions/266450/how-to-fix-e-internal-error-no-file-name-for-libc6
http://ubuntuforums.org/showthread.php?t=2185185

Categories: debian Tags: ,

From List Comprehensions to Generator Expressions

September 28, 2014 Leave a comment

From List Comprehensions to Generator Expressions
List comprehensions were added in Python 2.0. This feature originated as a set of patches by Greg Ewing with contributions by Skip Montanaro and Thomas Wouters. (IIRC Tim Peters also strongly endorsed the idea.) Essentially, they are a Pythonic interpretation of a well-known notation for sets used by mathematicians. For example, it is commonly understood that this:

{x | x > 10}

refers to the set of all x such that x > 10. In math, this form implies a universal set that is understood by the reader (for example, the set of all reals, or the set of all integers, depending on the context). In Python, there is no concept of a universal set, and in Python 2.0, there were no sets. (Sets are an interesting story, of which more in a future blog post.)

This and other considerations led to the following notation in Python:

[f(x) for x in S if P(x)]

This produces a list containing the values of the sequence S selected by the predicate P and mapped by the function f. The if-clause is optional, and multiple for-clauses may be present, each with their own optional if-clause, to represent nested loops (the latter feature is rarely used though, since it typically maps a multi-dimensional entity to a one-dimensional list).

more…

Source:
The history of python

Virtualenv

September 27, 2014 Leave a comment

Problem:

I had to work with different versions of django and having system wide installs would not work. I needed a clear demarcation between all versions.

Solution:
virtualenv is a tool to create isolated Python environments.

Source:

http://virtualenv.readthedocs.org/en/latest/virtualenv.html

PulseAudio – No sound on laptop

September 11, 2014 Leave a comment

Problem:
I was having a flaky sound problem. I could reboot my machine and not get any sound when playing videos via vlc or mplayer. Other times it would work. I eventually broke it and even with multiple reboots and prayers I was not getting any sound. Granted this all happened when I started messy around trying to install software that would allow me to convert mp4 videos to simple audio. (Dropped that project though since I now had bigger problems).

Debian Testing initially did not come installed with pulseaudio… I installed this due to skype. That is another issue explained here. So here is how I finally managed to get back my sound.


Solution:

I reinstalled pulseaudio (not sure if you need all these files but I was pretty desparate at this stage and just copying stuff of the internet. See source below.)

As root

apt-get install pulseaudio libao4 paprefs libpulse-mainloop-glib0 pulseaudio-module-jack pavucontrol pulseaudio-module-x11 gstreamer0.10-pulseaudio pulseaudio-utils libasound2-plugins paman pulseaudio-module-gconf libgconfmm-2.6-1c2 pavumeter libglademm-2.4-1c2a pulseaudio-esound-compat libpulse0 libpulse-dev pulseaudio-module-bluetooth pulseaudio-module-zeroconf

Then installed mate-volume-control using synpatic.

From the bash prompt I had a look at my sound settings

$ mate-volume-control

If you still have an issue with pulseaudio then mate-volume-controller will not open up. You will get the following window. It was here that I noticed that my volume was on mute. Once I un-muted, my sound was back.

Extra:

Since I use fluxbox I added mate-volume-control-applet to the startup script.

# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.
#
# unclutter -idle 2 &
# wmnd &
# wmsmixer -w &
# idesk &
  nm-applet &
  xscreensaver &
  mate-power-manager &
  mate-volume-control-applet &
  nitrogen --restore &

Source:
http://forums.debian.net/viewtopic.php?t=12497

Skype – No sound/audio when making a test call

September 11, 2014 Leave a comment

Problem:

So finally managed to install skype 4.3 on 64bit Debian Testing. Next hurdle was that I could not make a skype call as the other party could not hear me. Selecting Options->Sound Devices->Make a Test Call would result in nothing getting recorded.

Solution:
Install pulseaudio and mate-volume-controller.

So most noticible effect was that now every time skype starts up you get all the moans and groans, but still “Make a Test Call” does not play back my voice.

In skype go to Sound Devices

Skype Sound Devices

Skype Sound Devices

Click on “Open PulseAudio Volume Control”

Volume Control

Volume Control

Make sure that the internal microphone is not muted. Once I unmuted mine. I redid the skype test call and it played back my voice.

nitrogen – Setting wallpapers

September 7, 2014 Leave a comment

Problem:
Needed to setup a wallpaper on fluxbox and it needed to appear on one or two screens.

Solution:
Installed nitrogen. (Esetroot just did not work nicely for me. YMMV)

(as root) apt-get install nitrogen

Set up your preferred wallpaper using nitrogen.

$ nitrogen

nitrogen

nitrogen


Click “Preferences” and select the folder with the wallpapers. Then pick the wallpaper you want for a fullscreen or selective screens.

Nitrogen settings

$less ~/.config/nitrogen/bg-saved.cfg
[xin_0]
file=/home/rodnee/Pictures/wolves_wide.jpg
mode=0
bgcolor=#000000

[xin_1]
file=/home/rodnee/Pictures/wolves_wide.jpg
mode=0
bgcolor=#000000
.config/nitrogen/bg-saved.cfg (END)

Now all that was left was to configure fluxbox

Add nitrogen –restore to ~/.fluxbox/startup

# Applications you want to run with fluxbox.
# MAKE SURE THAT APPS THAT KEEP RUNNING HAVE AN ''&'' AT THE END.
#
# unclutter -idle 2 &
# wmnd &
# wmsmixer -w &
# idesk &
  xscreensaver &
  mate-power-manager &
  nitrogen --restore &

Added the following two lines to ~/.fluxbox/init

session.screen0.rootCommand:    nitrogen --restore
session.screen1.rootCommand:    nitrogen --restore

That was it.


Update (11th September 2014)

Above settings would work like a charm when I had a monitor plugged in. But the new wall paper would not take effect otherwise. To fix this I simply ran nitrogen again and picked the desired wallpaper. The nitrogen config file now looks like this

$less ~/.config/nitrogen/bg-saved.cfg
[xin_0]
file=/home/rodnee/Pictures/wolves_wide.jpg
mode=0
bgcolor=#000000

[xin_1]
file=/home/rodnee/Pictures/wolves_wide.jpg
mode=0
bgcolor=#000000

[:0.0]
file=/home/rodnee/Pictures/wolves_wide.jpg
mode=0
bgcolor=#000000
.config/nitrogen/bg-saved.cfg (END)

Now my wallpaper is set whether or not a monitor is plugged in.

Follow

Get every new post delivered to your Inbox.

Join 38 other followers