Updated 2015-02-24 11:30:55 by RLE

Hi. The following Tcl/Tk script is just a frontend interface for the application get_flash_videos.

get_flash_videos downloads online videos from websites like YouTube and save them as a normal file where you can watch the video directly from your computer without the need to use the Internet at all.

The problem with get_flash_videos is that it only downloads a single video and it does not download a complete playlist. This means it does not download each video belonging to this playlist. Therefore I made this interface script.

I made this script to run on Debian GNU/Linux 7.0 . It should work on other Linux systems.

You have to understand that this ONLY downloads YouTube playlists. Nothing else.

To run this script :

  1. Install get_flash_videos from Debian repository: apt-get install get-flash-videos
  2. Install ActiveTcl and update teacup using the command teacup update
  3. Copy the script to a text editor as a new empty file and save it as youtube.tcl
  4. Set it executable : chmod 775 youtube.tcl
  5. Run the script file youtube.tcl from terminal from its save location as ./youtube.tcl
  6. All you have to do now is just copy the playlist URL from your web browser, paste it in the frontend interface, and press the button and wait until the whole list is downloaded.

The script is below this line.

if { [ catch { exec which get_flash_videos } ] !=0 } {
  tk_messageBox -icon error -title "Missing Application" -detail "Please install the package get-flash-videos because it's missing. It's the download tool.\nIn debian systems as user 'root' enter on your terminal:\n\n apt-get install get-flash-videos"

package require http
package require tdom

set all_video_ids [list] ;# this is a global variable

proc explore {parent} {
    set type [$parent nodeType]
    global all_video_ids
    set name [$parent nodeName]
    set value [$parent asText]
   if { $name=="title" } {
    puts "named $name has value $value"
   .youtube_video_title configure -text "title: $value"
   if { $name=="yt:videoid" } {
    puts "named $name has value $value"
    #lappend all_video_ids $value
     exec get_flash_videos "https://www.youtube.com/watch?v=$value"
    .youtube_playlist_url_video_ids_list insert end $value
    #after 2000 ;#uncomment this pause if you want to test.
    if {$type != "ELEMENT_NODE"} then return

    foreach child [$parent childNodes] {
        explore $child

label .paste_your_playlist -text "Paste your YouTube playlist url here and click the button below"
entry .youtube_playlist_url_entry 
label .youtube_playlist_url_video_ids_label -text "Video IDs of the playlist"
listbox  .youtube_playlist_url_video_ids_list 
label .youtube_video_title -text "Each video title of the playlist is printed here while the playlist is downloaded"

button .get_youtube_playlist_url_video_ids_button -text "get videoids" -command {
    set youtube_playlist_url [ .youtube_playlist_url_entry get]

    global all_video_ids
    set playlist_id [ lindex [ split $youtube_playlist_url "=" ] 1 ]
    set http_token [ ::http::geturl "http://gdata.youtube.com/feeds/api/playlists/$playlist_id/?v=2&alt=rss" -method GET ]
    set doc [ dom parse [ ::http::data $http_token ] ]
    set root [$doc documentElement]
    .youtube_playlist_url_video_ids_list delete 0  end
    explore $root
pack .paste_your_playlist .youtube_playlist_url_entry .youtube_playlist_url_video_ids_label  .youtube_playlist_url_video_ids_list .youtube_video_title .get_youtube_playlist_url_video_ids_button 

[Category YouTube]