Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'A script to download and convert multiple YouTube videos' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to download and convert multiple YouTube videos
Authored by: chleuasme on Feb 29, '08 10:55:53PM
Some comments :

  • Wget isn't installed with OS X, but cURL does
  • seq isn't installed with OS X, but bash offers a built-in syntax for sequences (in recents versions), or you can here directly use the for C-syntax (see man bash ;-)
  • I can't download a video with the url you obtain using Wget or cURL, having to do more (see the script below)

    Based on your script, you can have a try on this one :

    #!/bin/bash
    
    if [ $# -ne 1 ]
    then
        echo "Usage: $0 file"
        echo "where the file is composed of a list of YouTube URL on each line"
        exit
    fi
    
    function _parse_url {
        echo $2 | sed "s:.*[?&]${1}=\([^&\';]*\).*:\1:"
    }
    
    BASEURL="http://youtube.com/get_video.php?"
    
    while read 
    do
        tmp=$( curl -s "$REPLY" | grep watch_fullscreen) || continue
        id=$( _parse_url video_id "$tmp" )
        t=$( _parse_url t "$tmp" )
        title=$( _parse_url title "$tmp" | cut -c 1-251 | tr / _)
    
        curl -s -L -o "${title}.flv" "${BASEURL}video_id=${id}&t=$t"
        >/dev/null 2>&1 ffmpeg -i "${title}.flv" -ar 48000 -ac 2 "${title}.avi"
        rm "${title}.flv"
    done < "$1"
    

    BUT :D

    I don't know why, the URL file seems to be closed after the first encoding with ffmpeg (nothing else to read) ; you can still use MEncoder if no solution/correction :-)

    [ Reply to This | # ]

  • A script to download and convert multiple YouTube videos
    Authored by: LukeR on Mar 01, '08 10:35:24AM
    Yes, in order to get my script to work you need to have wget and ffmpeg installed, but that's easy with Fink or MacPorts. To get better quality of the output avi file, I'd suggest using
    ffmpeg -i "${MOVNAME}"'.flv' -ar 48000 -b 500k -vcodec libxvid -acodec libmp3lame "${MOVNAME}"'.avi'
    line.

    [ Reply to This | # ]
    A script to download and convert multiple YouTube videos
    Authored by: chleuasme on Mar 01, '08 12:45:46PM
    wget, ffmpeg … and seq too : therefor I suggested you alternatives built-in solutions (apart ffmpeg ofc)

    and the problem is not to install them: I can't make wget to download the flv (and so your script, to only talk about the download part, doesn't work for me), nor curl without the -L option

    [ Reply to This | # ]

    A script to download and convert multiple YouTube videos
    Authored by: S Barman on Mar 02, '08 06:56:59PM

    There is also the problem of a redirect to the "real" file if the HTTP request returns a 302. Does curl follow the redirect? If not, you have to look for the HTTP return header "Location: " to get the real destination.



    [ Reply to This | # ]
    A script to download and convert multiple YouTube videos
    Authored by: chleuasme on Mar 02, '08 10:10:42PM
    thus the -L option, no?

    And I correct what I said earlier, I can download the flv with wget without option BUT need too both the "video_id" and "t" URL's attributes. The original script still doesn't work for me as no flv is downloaded (Am I the only one here?)

    [ Reply to This | # ]