Tag Archive for YouTube

EzTube: Playing YouTube Videos without Flash

#! /usr/bin/env bash
#
#    eztube2.sh
#    Playing Youtube Videos without flash, using mplayer.
#    Revised and $(hopefully) better version.
#    ksaver (at identi.ca), Sep 2010.
#    Public Domain Code.
#    Dependences:  (Unix-like OS, python, bash implicit).
#                  Youtube-dl: <a href="http://bitbucket.org/rg3/youtube-dl/" >http://bitbucket.org/rg3/youtube-dl/</a>
#                  Zenity:     <a href="http://freshmeat.net/projects/zenity" >http://freshmeat.net/projects/zenity</a>
#                  MPlayer:    <a href="http://www.mplayerhq.hu/" >http://www.mplayerhq.hu/</a>
#
#    More Info: <a href="http://ur1.ca/0g3gu" >http://ur1.ca/0g3gu</a>

scriptname=$(basename $0)
version='0.2.1'
dependences='zenity mplayer youtube-dl'

#Edit this as needed/
workdir="$HOME/Video"
wait_sec=60
##/

function check_dep()
    {
        for DEPEND in "$@"
        do
            /usr/bin/which $DEPEND &> /dev/null ||
            (echo "[ERR]: Dependence '$DEPEND' Not found in your path!" &&
            return 1)
            
        done
    }

function dl_video()
    {
        /usr/bin/env youtube-dl -q --continue "$1" -o "$2" &
        DLPID="$!"
    }
    
function get_url()
    {
        YTURL=$(zdialog --entry --text='Youtube Video URL:')
    }

function kill_dl()
    {
        PID=$1
        SEC=$2
        /bin/ps   -p  $PID &> /dev/null && waitload $SEC
        /bin/kill -15 $PID &> /dev/null
    }

function play_video()
    {
        /usr/bin/env mplayer -zoom "$1"
    }
    
function saveordrop()
    {
        zdialog --question --text="Save downloaded video?"
    }

function waitload()
    {
     #Not actually checking progress video size, just waits.
        CNT=0
        SEC=$1
        while [[ $CNT -lt $SEC ]]
        do
            echo  $(($CNT*100/$SEC)) #%percent%
            let   CNT=$CNT+1
            sleep 1
            
        done | zdialog --progress --auto-close 
               --text="Loading video...
Please wait about $wait_sec secs."
    }
        
function zdialog()
    {
        /usr/bin/env zenity --title="$scriptname $version" "$@"
    }
    
function _main_()
    {
        check_dep $dependences || exit
        
        YTURL=''
        while [[ ! $YTURL ]]
        do
            get_url || exit
        done         

        VIDNAME="$workdir/$(echo $YTURL |cut -d '&' -f 1 |cut -d '=' -f 2).flv"
        dl_video "$YTURL" "$VIDNAME"

        # If file already exists play it
        if [[ -f $VIDNAME ]]
        then
            play_video "$VIDNAME"
            
        else
            waitload $wait_sec
            play_video "$VIDNAME"
            
        fi
                
        #Save or delete file
        saveordrop
        if [ $? -eq 0 ]
        then
            FILENAME=$(zdialog --file-selection --filename="$VIDNAME")
            
            #wait to download...
            kill_dl $DLPID $wait_sec
            
            #and move downloaded video to new destiny
            /bin/mv "$VIDNAME" "$FILENAME"
            
        else
            #kill download and delete file
            kill_dl $DLPID 0
            if [ -f "$VIDNAME" ]
            then
                /bin/rm "$VIDNAME"
            fi
            
        fi        
    }

#Run script...
while true
do
    _main_
done

source

Link to specific part of YouTube file

<a href="http://www.youtube.com/watch?v=UkTQwP2gFxU#t=3m14s

" >http://www.youtube.com/watch?v=UkTQwP2gFxU#t=3m14s
source

Youtube with SWF object

//Swfobject Youtube Embedded video
var youTubeEmbed = function(){
	var atts = {};
	atts.id = "vid";
	swfobject.embedSWF('<a href="http://www.youtube.com/v/'+ytVideoID+"&hl=en&fs=1&rel=0&color1=0x000000&color2=0x2d2d2d&enablejsapi=1&playerapiid=ytplayer"," >http://www.youtube.com/v/'+ytVideoID+"&hl=en&fs=1&rel=0&color1=0x000000&color2=0x2d2d2d&enablejsapi=1&playerapiid=ytplayer",</a> 
			   "vid", "640px", "385px", "8", null, null, atts);
};

if(ytVideoID != ''){
	youTubeEmbed();
}





<script>
var ytVideoID = "fzzjgBAaWZw";
</script>

source

Youtube series episode searcher

// Today's date
javascript:(function(){var d=new Date();var month=new Array(12);month[0]="january";month[1]="february";month[2]="march";month[3]="april";month[4]="may";month[5]="june";month[6]="july";month[7]="august";month[8]="september";month[9]="october";month[10]="november";month[11]="december";var day=d.getDate().toString();var last=day.substring(day.length,1);var post='';if(last=='1'){post='st';}else if(last=='2'){post='nd';}else if(last=='3'){post='rd';}else{post='th';}location.href='<a href="http://www.youtube.com/results?search_query=uttran+'+day+post+'+'+month[d.getMonth()]+'+09&search_type=&aq=f';})()" >http://www.youtube.com/results?search_query=uttran+'+day+post+'+'+month[d.getMonth()]+'+09&search_type=&aq=f';})()</a>

// Yesterday's date
javascript:(function(){var d=new Date();d.setDate(d.getDate()-1);var month=new Array(12);month[0]="january";month[1]="february";month[2]="march";month[3]="april";month[4]="may";month[5]="june";month[6]="july";month[7]="august";month[8]="september";month[9]="october";month[10]="november";month[11]="december";var day=d.getDate().toString();var last=day.substring(day.length,1);var post='';if(last=='1'){post='st';}else if(last=='2'){post='nd';}else if(last=='3'){post='rd';}else{post='th';}location.href='<a href="http://www.youtube.com/results?search_query=uttran+'+day+post+'+'+month[d.getMonth()]+'+09&search_type=&aq=f';})()

" >http://www.youtube.com/results?search_query=uttran+'+day+post+'+'+month[d.getMonth()]+'+09&search_type=&aq=f';})()
source

youtube call 5 – Get videoFeed(video_id)

http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y

<entry>
−
<id>
<a href="http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y" >http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y</a>
</id>
<published>2009-07-31T09:45:17.000Z</published>
<updated>2009-08-06T13:07:11.000Z</updated>
−
<app:control>
−
<yt:state name="restricted" reasonCode="limitedSyndication">
Syndication of this video was restricted by its owner.
</yt:state>
</app:control>
<category scheme="http://schemas.google.com/g/2005#kind" term="http://gdata.youtube.com/schemas/2007#video"/>
<category scheme="http://gdata.youtube.com/schemas/2007/categories.cat" term="Sports" label="Sports"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="After+the+Flag"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="MotoGP"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Jorge+Lorenzo"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Valentino+Rossi"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Colin+Edwards"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Andrea+Dovizioso"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Randy+de+Puniet"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Repsol+Honda"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Fiat+Yamaha"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Casey+Stoner"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Ducati+Marlboro"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Donington+Park"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="Great+Britain"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="motorcycle"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="road+racing"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="motograndprix"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="motorcycles"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="bike"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="speed"/>
<category scheme="http://gdata.youtube.com/schemas/2007/keywords.cat" term="crash"/>
<title type="text">After the Flag at the British Grand Prix</title>
−
<content type="text">
The seventh edition of After the Flag for 2009, the official MotoGP Video Podcast is brought to you by host Gavin Emmett from Donington Park after the British Grand Prix was held at the East Midlands circuit for the last time.
</content>
<link rel="alternate" type="text/html" href="http://www.youtube.com/watch?v=qPznjRKcM7Y"/>
<link rel="http://gdata.youtube.com/schemas/2007#video.responses" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y/responses"/>
<link rel="http://gdata.youtube.com/schemas/2007#video.related" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y/related"/>
<link rel="self" type="application/atom+xml" href="http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y"/>
−
<author>
<name>MotoGP</name>
<uri>http://gdata.youtube.com/feeds/api/users/motogp</uri>
</author>
−
<gd:comments>
<gd:feedLink href="http://gdata.youtube.com/feeds/api/videos/qPznjRKcM7Y/comments" countHint="24"/>
</gd:comments>
−
<media:group>
<media:category label="Sports" scheme="http://gdata.youtube.com/schemas/2007/categories.cat">Sports</media:category>
−
<media:description type="plain">
The seventh edition of After the Flag for 2009, the official MotoGP Video Podcast is brought to you by host Gavin Emmett from Donington Park after the British Grand Prix was held at the East Midlands circuit for the last time.
</media:description>
−
<media:keywords>
After+the+Flag, MotoGP, Jorge+Lorenzo, Valentino+Rossi, Colin+Edwards, Andrea+Dovizioso, Randy+de+Puniet, Repsol+Honda, Fiat+Yamaha, Casey+Stoner, Ducati+Marlboro, Donington+Park, Great+Britain, motorcycle, road+racing, motograndprix, motorcycles, bike, speed, crash
</media:keywords>
<media:player url="http://www.youtube.com/watch?v=qPznjRKcM7Y"/>
<media:thumbnail url="http://i.ytimg.com/vi/qPznjRKcM7Y/2.jpg" height="90" width="120" time="00:11:00"/>
<media:thumbnail url="http://i.ytimg.com/vi/qPznjRKcM7Y/1.jpg" height="90" width="120" time="00:05:30"/>
<media:thumbnail url="http://i.ytimg.com/vi/qPznjRKcM7Y/3.jpg" height="90" width="120" time="00:16:30"/>
<media:thumbnail url="http://i.ytimg.com/vi/qPznjRKcM7Y/0.jpg" height="240" width="320" time="00:11:00"/>
<media:title type="plain">After the Flag at the British Grand Prix</media:title>
<yt:duration seconds="1320"/>
</media:group>
<yt:noembed/>
<gd:rating average="4.6969695" max="5" min="1" numRaters="66" rel="http://schemas.google.com/g/2005#overall"/>
<yt:statistics favoriteCount="29" viewCount="16357"/>
</entry>

source

php util log access rept – youtube video

grep 'util.net.*php' /var/log/httpd/access_log | awk  ' { print substr($4,2,6) } ' | sort | uniq -c

source

16:9 on Youtube

<object width="425" height="265">

<param name="movie" value="http://www.youtube.com/v/MCkAtS1-zG0&amp;hl=en&amp;fs=1&amp;fmt=22" />

<param name="allowFullScreen" value="true" />

<param name="allowscriptaccess" value="always" />

<embed src="http://www.youtube.com/v/MCkAtS1-zG0&amp;hl=en&amp;fs=1&amp;fmt=22" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="265" />

</object>

source

Get YouTube video thumbnails URL with jQuery

function getScreen( url, size )
{
if(url === null){ return ""; }

size = (size === null) ? "big" : size;
var vid;
var results;

results = url.match("[?&]v=([^&#]*)");

vid = ( results === null ) ? url : results[1];

if(size == "small"){
return "http://img.youtube.com/vi/"+vid+"/2.jpg";
}else {
return "http://img.youtube.com/vi/"+vid+"/0.jpg";
}
}

source

Youtube/Google video into valid XHTML

********** YOUTUBE VIDEO **********

<object type="application/x-shockwave-flash" width="425" height="355" data="http://www.youtube.com/v/qdeMqqghXRI&amp;rel=0">
<param name="movie" value="http://www.youtube.com/v/qdeMqqghXRI&amp;rel=0"></param>
<param name="wmode" value="transparent"></param>
</object>

********** GOOGLE VIDEO **********
<object width="400" height="326" type="application/x-shockwave-flash" data="http://video.google.com/googleplayer.swf?docId=xxxxxxxxxx" ><param name="wmode" value="transparent" /></object>

source

Download Links for Youtube in WordPress Single Post

function str_between($string, $start, $end){ $string = " ".$string;
$ini = strpos($string,$start); if ($ini == 0) return ""; $ini +=
strlen($start); $len = strpos($string,$end,$ini) - $ini; return
substr($string,$ini,$len); }
function get_youtube_download_link($url){
if( $url !== "")
{
$youtube_link = $url;
//$url = get_post_meta($post->ID, 'url', true);
if ( file_get_contents($youtube_link) !== "")
{
$youtube_page = file_get_contents($youtube_link);
$v_id = str_between($youtube_page, "&video_id=", "&");
$t_id = str_between($youtube_page, "&t=", "&");
$flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id";
$hq_flv_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=6";
$mp4_link = "http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=18";
$threegp_link =
"http://www.youtube.com/get_video?video_id=$v_id&t=$t_id&fmt=17";
echo "		Download (right-click &gt; save as)&#58;
";
echo "<a href="$flv_link">FLV</a>
";
echo "<a href="$hq_flv_link">HQ FLV (if available)</a>
";
echo "<a href="$mp4_link">MP4</a>
";
echo "<a href="$threegp_link">3GP</a><br><br>
";
}
}
}

source