Archive

Posts Tagged ‘youtube’

See YouTube Videos On Small Browser

September 18th, 2008

See YouTube Videos On Small Browser

Here is the python source code:

#!/usr/bin/python
# albertux
# see a mini youtube video on resizable window
# this script could be better
 
import sys
 
if (len(sys.argv)==1) :
    print "~$ script url_video"
    sys.exit() # exit if not url
URL = sys.argv[1]
 
import gtk
import gtkmozembed
import re
 
# id of the YouTube Video
m = re.search('(?<=v=).{11}',URL)
id = m.group(0)
 
# html code to render on the small web browser
data ='<object width="100%" height="100%" data="http://www.youtube.com/swf/l.swf?video_id='+id+'&amp;rel=1&amp;iurl=null&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;autoplay=1" type="application/x-shockwave-flash">
<param name="allowFullScreen" value="true" />
<param name="src" value="http://www.youtube.com/swf/l.swf?video_id='+id+'&amp;rel=1&amp;iurl=null&amp;color1=0x2b405b&amp;color2=0x6b8ab6&amp;autoplay=1" />
<param name="allowfullscreen" value="true" /></object>'
 
def CloseWindow(caller_widget):
    """Close the window and exit the app"""
    gtk.main_quit()
 
win = gtk.Window()
win.set_title("Small Web Browser")
win.set_position(gtk.WIN_POS_NONE) # general put the window on the top left corner
win.set_resizable(True) # resizable window
win.connect("destroy", CloseWindow)
 
gtkmozembed.set_profile_path("/tmp", "simple_browser_user")
mozbrowser = gtkmozembed.MozEmbed() # gtkmozembed
 
win.add(mozbrowser)
win.show_all()
 
mozbrowser.set_size_request(272,223) #size of the window
# show the video on the small web browser
mozbrowser.render_data(data, long(len(data)), 'file:///', 'text/html')
 
gtk.main()

Screens:

Im think write a support for wuapi, megavideo and other videosites.

unix/linux, web , , ,

YouTube++ Download and Converter

September 15th, 2008

YouTube++ Download and Converter

you need: Perl, wget, ffmpeg and this script:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/perl
use LWP::Simple;
print "YouTube++ (URL's to MP3's) By Albertux\n[http://albertux.ayalasoft.com]\n";
 
$total = @ARGV;
 
if ($total==0) {
 
	print "\nExample: ~\$ youtube\+\+ url1 url2 url3 ...\n";
 
} else {
 
	foreach(@ARGV) {
 
		$URL = $_;
		$aux = index($URL,"?v=");
		$a = substr $URL,$aux+3,11;
		$content = get($URL);
		@lines = split("\n",$content);
 
		foreach(@lines) {
			my $aux = index($_,"&t=");
			if ($aux > -1) { 
				$t = substr $_, $aux+3,32;
			}
		}
		system "wget -c -O \"$a.flv\" \"http://youtube.com/get_video?video_id=$a&t=$t\"";
		system "ffmpeg -i \"$a.flv\" -ab 128k \"$a.mp3\"";
	}
}
print "\nFeedback to: <albertoi7\@gmail.com>\n";

Example you have one file with urls of some videos (YouTubeUrls.txt):

http://www.youtube.com/watch?v=-j39ABZyzek
http://www.youtube.com/watch?v=5cGvzApDZKI
http://www.youtube.com/watch?v=w1mgEQTMVB8
...

This script download all flv files and convert to mp3.

youtube++ `cat YouTubeUrls.txt`

unix/linux, web ,

Insert Any Video Of YouTube

August 23rd, 2008

Insert Any Video Of YouTube

I made this little Javascript function, this function insert any youtube video on a <div>.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// Script: YouTubeVideo Version 1.0 (2008/07/22)
// Author: Alberto Isaac Ayala Esquivias (Albertux)
// Licence: http://creativecommons.org/licenses/by-nc-sa/3.0/
// FeedBack to: albertoi7@gmail.com
// About: Insert youtube video on a div doesn't matter if embed code is disable this script insert the video.
 
function YouTubeVideo(id,url) {
 
	var video_html ='<object width="425" height="344"><param name="movie" value="http://www.youtube.com/swf/l.swf?video_id=VIDEO&rel=1&iurl=null&autoplay=1"></param><param name="allowFullScreen" value="true"></param><embed src="http://www.youtube.com/swf/l.swf?video_id=VIDEO&rel=1&iurl=null&autoplay=1" type="application/x-shockwave-flash" allowfullscreen="true" width="425" height="344"></embed></object>';
 
	var n = url.indexOf('v=');
 
	var id_video = url.substring(n+2,n+14);
 
	document.getElementById(id).innerHTML=video_html.replace(/VIDEO/g, id_video);
 
}

Howto use:

<input type="button" onclick="YouTubeVideo('contenedor','http://www.youtube.com/watch?v=7ykWgiZVJe0');" value="Watch  Video">
 
<div id="contenedor"></div>
  

On load page:

// JavaScript onload event example:
window.onload = function() { YouTubeVideo('contenedor','http://www.youtube.com/watch?v=7ykWgiZVJe0'); }
 
// jQuery example:
$(document).ready(function() {
	YouTubeVideo('contenedor','http://www.youtube.com/watch?v=7ykWgiZVJe0');
});

develop, web ,

YouTube URL2MP3 Perl

August 4th, 2008

YouTube URL2MP3 Perl

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use LWP::Simple;
print "\nYouTube URL to MP3 Beta By Albertux [2008-08-04]\n";
print "[http://albertux.ayalasoft.com/2008/08/04/youtube-url2mp3-perl/]\n\n";
$total= @ARGV;
if ($total < 2) {
	print "Use: \$perl url2mp3.pl url_video name_video\n\n";
}
else {
	$URL=$ARGV[0];
	$VNAME=$ARGV[1];
	$aux=index($URL,"?v=");
	$a = substr $URL,$aux+3,11;
	$content = get($URL);
	@lines = split("\n",$content);
	foreach(@lines) {
		my $aux=index($_,"&t=");
		if ($aux > -1) {
			$t= substr $_, $aux+3,32;
		}
	}
	system "wget -c -O \"$VNAME.flv\" \"http://youtube.com/get_video?video_id=$a&t=$t\"";
	system "ffmpeg -i \"$VNAME.flv\" -ab 128k \"$VNAME.mp3\""; }
print "url2mp3.pl feedback to <albertoi7\@gmail.com>\n\n";

Need WGET and FFMPEG.

projects ,

YouTube to mp3

July 25th, 2008

YouTube to mp3

Aveces queremos tener las canciones de los vídeos en nuestro iPod así que solo agregue unas cuantas lineas al script que hice anteriormente para bajar videos de youtube, el resultado lo pueden apreciar en [youtube_download_mp3.py] es necesario que tengan wget y ffmpeg con lame incluido.

Nota: solo lo e probado con Ubuntu 8.04 pero estoy seguro que funciona bien en Windows.

develop ,

YouTube Download

July 13th, 2008

YouTube Download

Una de las mas extendidas actividades en el Internet es ver vídeos de YouTube y a menudo queremos salvar algunos vídeos que nos gustan bueno hoy hace un rato hice este script [youtube_download] para los que no estan usando Gnu/Linux necesitan instalar Python y copiar Wget en %WINDIR% (por lo general es C:/Windows/) para poder utilizar este script.

Nota: no maneje excepciones, pero funciona, si están en Windows no se ve que se baje el vídeo, pero si lo hace, usen F5 en la carpeta donde corrieron el script y verán un archivo video.flv que aumenta de tamaño cuando vean que sale la leyenda de que el vídeo se bajo ya pueden visualizarlo completo.

Ultima versión disponible en Google Code

develop ,