diff options
Diffstat (limited to 'youtube-viewer/youtube-viewer')
-rw-r--r-- | youtube-viewer/youtube-viewer | 866 |
1 files changed, 0 insertions, 866 deletions
diff --git a/youtube-viewer/youtube-viewer b/youtube-viewer/youtube-viewer deleted file mode 100644 index 09c93fd..0000000 --- a/youtube-viewer/youtube-viewer +++ /dev/null @@ -1,866 +0,0 @@ -#!/usr/bin/perl - -# Last edit on January 12 2011, 10:25 PM - -$appname = 'youtube-viewer'; -$version = 'v2.4.4'; - -=start -------------------------------------------------------- - (C) 2010-2011 by Trizen - WebSite: http://trizen.go.ro - Email: echo dHJpemVueEBnbWFpbC5jb20K | base64 -d -------------------------------------------------------- - -[?] What is this script for? - - This script is useful if do you hate the Flash Player and love YouTube. - - Using this script you can search and play YouTube Videos with MPlayer... - - Have fun! - -[!] Most important changes are written in the changelog! - - [CHANGELOG] - - First version with Windows support. Require SMPlayer to play videos. See MPlayer Line - NEW (v2.4.*) - - Code has been changed in a proportion of ~60% and optimized for speed // --480 became -4 - NEW (v2.4.*) - - Added mega-powers of omnibox to the STDIN :) - NEW (v2.3.*) - - Re-added the option to list and play youtube videos from a user profile. Usage: -u [user] - NEW (v2.3.*) - - Added a new option to play all video clips from a category. Usage: '-c 9' and insert 'all' - NEW (v2.3.*) - - Category area is more friendly... New options: -c [n] where 'n' is the number of category - NEW (v2.3.*) - - Added a new option to play only the audio track of a videoclip. Usage: [words] -n - NEW (v2.3.*) - - Added option for fullscreen (-f, --fullscreen). Usage: youtube-viewer [words] -f - NEW (v2.3.*) - - Added one new option '-c'. It shows available categories and will let you to choose one. - NEW (v2.3.*) - - Added one new option '-m'. It shows 3 pages of youtube video results. Usage: [words] -m - NEW (v2.3.*) - - For "-p" option has been added 3 pages of youtube video results (60 clips) - NEW (v2.3.*) - - Added "-prefer-ipv4" to the mplayer line (videoclips starts in no time now). - NEW (v2.3.*) - - Search and play videos at 480p, 720p. Ex: [words] --480, [words] -p --480 - NEW (v2.3.*) - - Search has been corrected due to some YouTube changes... - (v2.2.*) - - Added support to play a video at 480p even if it's resolution is higher. Ex: [url] --480 - (v2.2.*) - - Added a nice feature which prints some informations about the video which you watching at - (v2.2.*) - - Added support to play videos by your order. Example: after search results, insert: 3 5 2 1 - (v2.1.*) - - Added support for next pages of video results (press ENTER when ask you to insert number) - (v2.1.*) - - Bug fixed: "Numbers go crazy after more than 20 video results". - (v2.1.*) - - Added support to continue playing searched videos, usage: "youtube-viewer [words] -p" - (v2.1.*) - - Added support to print counted videos and support to insert the number of video to play it - (v2.1.*) - - Added support to search YouTube Videos in script (ex: youtube-viewer avatar trailer 2009) - (v2.0.*) - - Added support for script to choose automat quality if it is lower than 1080p - (v2.0.*) - - Added support to choose the quality only between 720p and 1080p (if it is available) - (v2.0.*) - - Added support for an YouTube video code (ex: youtube-viewer WVTWCPoUt8w) - (v1.0.*) - - Added support for 720p and 1080p YouTube Videos... - (v1.0.*) - - Special thanks to: - - Army (for bugs reports and for his great ideas) - - dhn (for adding youtube-viewer in freshports.org) - - And also many thanks to: - - everybody who use this script... -=cut - -require LWP::UserAgent; - -$os = $^O; -if ($os =~ /MSWin/) { - $MPlayerLine = '"C:\\Program Files\\SMPlayer\\mplayer\\mplayer.exe" -prefer-ipv4 -cache 10000 -cache-min 1'; -} -else { - $MPlayerLine = 'mplayer -prefer-ipv4 -cache 100000 -cache-min 1'; -} -$lwp = 'LWP::UserAgent'->new; -$lwp->agent('Mozilla/5.0 (X11; U; Linux i686; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.634.0 Safari/534.16'); -unless ($os =~ /MSWin/) { - $bred = "\e[1;31m"; - $bgreen = "\e[1;32m"; - $reset = "\e[0m"; -} -$a = $ARGV[0]; -$b = $ARGV[1]; -unless ($b) { - $b = ''; -} -unless ($a) { - $a = ''; -} -if ($a =~ /^(-v|--version)$/) { - $appname =~ s/-/ /; - $appname =~ s/(.)(.+) (.)/\U$1\E\L$2 \E\U$3\E/g; - print "$appname $version\n"; - exit; -} -my($Picks, $pickcat, $Search); -$PickBackup = ''; -$SearchBackup = ''; -$MoreResults = ''; -$FirstPage = 1; -$NextPage = 1; -$username = 0; -$pick = ''; -if ($a =~ /^(-a|--author)$/) { - @_ = ('4', '2', ')', ':', '%', '.'); - foreach $_ (@_) { - $@ = '@'; - $_ = $@ | $_; - &_; - sub _ { - $@ = $] * ($] * 3 + 1); - print '=' x $@ . "\n"; - } - print "\t" x $] . "\U$_\n\E"; - &_; - } - exit; -} -$Working = "\n[...] Working... Please wait...$reset\n"; -$app = $0; -$app =~ s[(.*)/([^/]+)$][$2]; -for ($n = 0; $n <= $#ARGV; ++$n) { - push @args, $ARGV[$n]; -} -if ($args[0]) { - foreach $arg (@args) { - next if $arg eq ''; - $arg =~ s/--novideo/-n/; - $arg =~ s/--categories/-c/; - $arg =~ s/^-([-]?)f(.*)/-f/; - if ($arg eq '-n') { - $MPlayerLine =~ s/mplayer /mplayer -novideo /; - $MPlayerLine =~ s/mplayer.exe"/mplayer.exe" -novideo/; - $SearchBackup = ' --480'; - } - if ($arg =~ /^-([-]?)([\d]+)/) { - $SearchBackup .= " $arg"; - } - if ($arg eq '-c') { - $categories = 'TRUE'; - } - if ($arg eq '-m' or $arg eq '-p') { - $MoreResults = 1; - } - else { - $MoreResults = 0; - } - if ($arg eq '-f') { - $SearchBackup .= " $arg"; - $MPlayerLine =~ s/mplayer /mplayer -fs /; - $MPlayerLine =~ s/mplayer.exe"/mplayer.exe" -fs/; - } - } -} -if ($a eq '' or $a =~ /^([-]?)-([471]+)|^-f|^-m|^-n/ and $b eq '') { - &InsertURL; -} -if ($a) { - $a =~ s[http://.*embed/][]i; - if ($a =~ m[^http://] and not $a =~ /youtube\.com/) { - $connect = $lwp->get($a); - if ($connect->content =~ m[youtube.com/v/([\w\-]{11})]) { - $youtube = "v=$1"; - &GetYouTube; - } - } -} -if ($a =~ /^-g([^\=]*)=([\w]+)/) { - $NextPage = 0; - $a = "http://www.youtube.com/music/$2"; - $Search .= ' '; -} -elsif ($a =~ /^-g$/ and $b =~ /([\w]*)/) { - $NextPage = 0; - $a = "http://www.youtube.com/music/$b"; - $Search .= ' '; -} -sub InsertURL { - print "\n$bred=>>$reset$bgreen Insert an YouTube URL or search something...\n$reset> "; - chomp($youtube = <STDIN>); - if ($youtube =~ m[^http://] and not $youtube =~ /youtube\.com/) { - $connect = $lwp->get($youtube); - if ($connect->content =~ m[youtube.com/v/([\w\-]{11})]) { - $youtube = "v=$1"; - &GetYouTube; - } - } - elsif (not $youtube =~ m[youtube.com(.+)v([\=/]+)([\w\-]{11})] and $youtube) { - $SearchBackup .= ' ' . $youtube; - $Search = $youtube; - $number = 0; - &Trizen; - } - elsif (not $youtube =~ /youtube.com(.+)([\w\-]{11})/) { - print $bred; - print "\n(x_x) Invalid URL...\n\n"; - print $reset; - exit; - } - else { - print $bgreen . ''; - &GetYouTube; - } -} -if ($categories) { - foreach $arg (@args) { - if ($arg =~ /^([\d]+)$/) { - $catnr = $1; - } - } - unless ($catnr) { - $catnr = ''; - } -} -if ($a =~ /youtube.com/ and not $a =~ m[v([=/]+)([\w\-]+)]) { - $c = 'TRUE'; - $CatURL = $a; - &CatSearch; -} -else { - $c = ''; -} -if ($a =~ /^-u/ and not $b =~ /(.+)/) { - die "\nUsage: $0 -u [username]\n\t$0 [username] -u\n\n"; -} -if ($a =~ /^-([-]*)u/ and $b =~ /(.+)/ or $b =~ /^-([-]*)u/) { - if ($b =~ /^-([-]*)u/) { - $b = $a; - } - $username = 1; - $NextPage = 0; - $ytp = "http://gdata.youtube.com/feeds/api/users/$b/uploads"; - $connect = $lwp->get($ytp); - $cc = $connect->content; - if ($cc eq 'User not found') { - die "\n(x_x) $cc...\n\n"; - } - $cc =~ s/\n//g; - $cc =~ s/<title type='text'>/\nTITLE=/g; - @content = split(?\n?, $cc, 0); - foreach $_ (@content) { - if ($_ =~ /TITLE\=/) { - $_ =~ s[TITLE\=([^\<]+)</title>(.+)v\=([\w\-]{11})(.+)duration([^\']*)'([\d\:]+)'(.+)][v=$3+title="$1">+video-time">$6]; - push @Videos, $_; - } - } - print "\n"; - &PrintResults; -} -if ($a =~ /^([-]?)-c/) { - if ($catnr =~ /(.+)/) { - print $bgreen . "$Working"; - } - if ($b =~ /([-]?)-([\d]+)/) { - $PickBackup = $b; - } - $NextPage = 0; - $connect = $lwp->get('http://www.youtube.com/videos'); - @cates = split(/\n/, $connect->content, 0); - foreach $_ (@cates) { - if ($_ =~ m[<a href=\"(.+)\">(.+)</a>([\ ]*)]) { - push @cats, "$1 -*- $2"; - } - } - $nbr = 0; - foreach $cat (@cats) { - unless ($cat =~ /\?v=|http|title=\"|style=\"|onclick=\"/) { - foreach $_ ($number = 0) { - $number = $nbr + 1; - $nbr = $number; - while ($cat =~ /\"/) { - $cat =~ s/(.+)"(.+)-\*-/$1 -*-/; - } - push @categories, "$number - $cat\n" unless $cat =~ m[/t/|class=]g; - } - } - } - print "\n"; - foreach $_ (@categories) { - next if $_ =~ m[/music|press_room]g; - if ($_ =~ /opt_out/) { - $caturl = 'http://www.youtube.com/videos'; - $catname = 'Main videos'; - $pick = '1'; - } - if ($_ =~ /([\d]+) - (.+) -\*- (.+)/ and not $_ =~ /opt_out/) { - $caturl = $2; - $catname = $3; - $pick = $1; - } - if ($catnr eq '' and $pick < 10) { - print "$bred $pick$reset - $catname\n$bred"; - } - else { - if ($catnr eq '' and not $caturl =~ /ads/) { - print "$bred$pick$reset - $catname\n$bred"; - } - } - } - if (not $catnr =~ /(.+)/) { - print $bgreen; - print "\n=>> Insert the number of a category\n> "; - print $reset; - chomp($pickcat = <STDIN>); - } - else { - $pickcat = $catnr; - } - foreach $cat (@categories) { - if ($cat =~ /^$pickcat - (.+) -\*- (.+)/) { - $catname = $1; - $youtube = "http://www.youtube.com$1"; - $catname =~ s/^(.+)\?(.+)/$2/; - $connect = $lwp->get($youtube); - @content = split(/\n/, $connect->content, 0); - } - } - &CatSearch; - sub CatSearch { - if ($c =~ /(.+)/) { - $connect = $lwp->get($CatURL); - @content = split(/\n/, $connect->content, 0); - } - foreach $_ (@content) { - $_ =~ s[\&\;feature\=([\w\-]+)|\"\ data\-thumb(.+)\.jpg|src="http://(.+)gif\"|click="" onmousedown="][]g; - if ($pickcat) { - unless ($pickcat =~ /16/) { - $_ =~ s/\="http([^\"]+)"|yt.analytics([^\;]+)\;|"src//g; - $_ =~ s/" alt\="([^\"]+)"([\ ]*)//g; - } - } - else { - $_ =~ s/" src="(.+)\.jpg//g; - } - $_ =~ s/" onload="tn_load\(\)" data-thumb alt="([^\"]+)\" |" onload="tn_load\(\)src|src=//g; - push @Videos, $_ if $_ =~ /^</; - } - print "\n"; - &PrintResults; - } - ; -} -if ($a =~ m[youtube.com(.+)v([\=/]+)([\w\-]{11})]) { - $youtube = "http://www.youtube.com/watch?v=$3"; - print $bgreen . "$Working"; - &GetYouTube; -} -if ($a =~ /^([\w\-]{11})$/) { - $youtube = 'http://www.youtube.com/watch?v=' . $a; - if ($a =~ /([\d]+)/ or $a =~ /([A-Z]+)/) { - &GetYouTube; - } -} -if ($a =~ /^-h$/ or $a =~ /^--help$/) { - $appname =~ s/(.+)/\U$1\E/g; - $app =~ s/(.*)\\([^\\]+)$/$2/; - die "\n\t" . '=' x 17 . " $appname " . '=' x 17 . qq[ -\t\t\t\t by Trizen (trizen.go.ro) - - Usage: $app || [url] || [words] || [code] - -Base Options: $app [...] - [url] : play an YouTube video by URL - [code] : play an YouTube video by code - [words] : search and play YouTube videos - -Other options: - -c, --categories : shows available YouTube categories - -n, --novideo : plays only audio track of the video - [words] -f : plays all videos in fullscreen mode - [words] -p : plays all video results in order - [words] -m : shows 3 pages of video results (60 videos) - [words] -n : plays only the audio track of video results - [words] -4, -7 : plays video results at 480p resolution (or 720p) - [ytURL] -4, -7 : plays an YouTube video by URL at 480p (or 720p) - [username] -u : lists videos from a YouTube user profile - -h, --help : outputs this message... - -Tips and tricks: - 1. Search something and press enter for the next page. - 2. Search and play all video results by adding "-p" after keywords. - 3. After search results, you can insert: 3 5 8 1 to play videos in your order - 4. Play all audio tracks of video results by adding "-p -n" after keywords. - 5. To listen music from YouTube use: "-c -n 10" and insert "all" - 6. Play videos one after one in fullscreen mode: "[words] -p -f" - 7. Play all video results at 480p: "[words] -p -4" (or 720p => "-7") - 8. Play all videos from a user at 480p: "[username] -u -4" and insert "all" - 9. Play a genre of music from YT: "-g [genre]". Example: "-g reggae -n" - -]; -} -elsif ($a =~ /^-p/) { - die "Usage: $app [words] $a\n"; -} -elsif (not $a =~ /^-([-]?)4|^-([-]?)7|^-g|^-p|^-n|^-([-]?)1|^-f|^-m/ and $a =~ /^-/) { - die "Unknown option '${a}'\n"; -} -$Search = join(' ', @args) . ' '; -&Trizen; -sub Trizen { - $PageNumber = 1; - $FirstPage = 1; - $SearchBackup .= ' ' . $Search; - $Search =~ s/\ ([-]?)-([\d]+)|\ -p|\ -m|\ ([-]?)-f([^\ ]*)|\ -n//g; - $ys = "http://www.youtube.com/results?search_query=$Search&aq=f"; - if ($MoreResults eq 1) { - $ys = "http://www.youtube.com/results?search_query=$Search&aq=f"; - $connect = $lwp->get($ys); - push @source, $connect->content . "\n"; - for ($number = 2; $number <= 3; ++$number) { - $ys = "http://www.youtube.com/results?search_query=$Search". - "&suggested_categories=10%2C24&page=$number"; - $connect = $lwp->get($ys); - push @source, $connect->content . "\n"; - } - $source = join('', @source); - @content = split(?\n?, $source, 0); - print "\n"; - } - else { - $connect = $lwp->get($ys); - @content = split(/\n/, $connect->content, 0); - if ($connect->content =~ m[class="largeText">(.+)<a href="/results\?search_query=(.+)&search=Search(.+)"(.+)</a></span></div>]) { - $spell = $4; - $research = "http://www.youtube.com/results?search_query=$2&search=Search"; - $spell =~ s[<i>|</i>|<b>|</b>|>|<][]g; - print "\n$bgreen=>> Did you mean: "; - print "$bred$spell$reset (Y/n)\n> "; - chomp($yn = <STDIN>); - if ($yn eq '' or $yn =~ /y/i) { - $connect = $lwp->get($research); - splice @content; - @content = split(/\n/, $connect->content, 0); - } - } - elsif ($connect->content =~ m[Results for: <a href="/results\?search_query=(.+)">(.+)</a>]) { - $research = "http://www.youtube.com/results?search_query=$1&search=Search"; - print "$bgreen\n=>> Did you mean: $bred$2$reset (Y/n)\n> "; - chomp($yn = <STDIN>); - if ($yn eq '' or $yn =~ /y/i) { - $connect = $lwp->get($research); - splice @content; - @content = split(/\n/, $connect->content, 0); - } - } - print "\n"; - } - &Search; -} -sub Search { - splice @Videos; - splice @codes; - foreach $_ (@content) { - if ($_ =~ m[^<a href="/watch\?v=]) { - $_ =~ s/\" data-thumb(.+)\.jpg//g; - push @Videos, $_; - } - } - &PrintResults; -} -sub PrintResults { - $number = 0; - foreach $_ (@Videos) { - chomp($line = $_); - if ($line =~ /v\=([\w\-]{11})(.*)title="([^\"]+)(.*)time\">([\d\:]*)/) { - ++$number; - $code = $1; - $title = $3; - $time = $5; - unless ($time =~ /\:/) { - $sec = $time; - $time = $sec / 3600 % 24 . ':' . $sec / 60 % 60 . ':' . $sec % 60; - $time =~ s/^0\://; - unless ($time =~ /\:/) { - $time = "0:$time"; - } - if ($time =~ /(.):(.):(.+)/) { - $time = "$1:0$2:$3"; - } - if ($time =~ /^(.+):(.)$/) { - $time = "$1:0$2"; - } - } - push @codes, "$number - $code $time"; - $title =~ s/\&\#39;/'/g; - $title =~ s/\&/&/g; - $title =~ s/\"/"/g; - $title =~ s/\&\#([\d]+);|amp;|quot;//g; - $title =~ s/src class=$|class=$//g; - print "$bred"; - if ($number < 10) { - print ' '; - } - print "$number$reset - $title ($time)\n$bred"; - } - } - if ($SearchBackup) { - if ($SearchBackup =~ /\ -p/) { - for ($i = 1; $i <= $number; ++$i) { - push @picks2, "$i "; - } - $youtube = join('', @picks2); - @picks = split(' ', $youtube, 0); - &PicksArea; - } - } - print "\n$bred=>>$reset$bgreen Insert a number or search something else\n$reset> "; - chomp($youtube = <STDIN>); - $PickBackup = $youtube; - if ($youtube =~ /^(q|quit|exit)$/) { - print "\n[*] Exiting...\n\n"; - exit; - } - if ($PickBackup =~ m[^http://] and not $PickBackup =~ /youtube\.com/) { - $connect = $lwp->get($PickBackup); - if ($connect->content =~ m[youtube.com/v/([\w\-]{11})]) { - $youtube = "v=$1"; - &GetYouTube; - } - } - if ($PickBackup =~ /([\d]+) ([-]?)-([\d]+)/) { - $youtube = $1; - } - print $bgreen . "$Working"; - if ($youtube =~ /^([\d]+)$/) { - if ($youtube > $number or $youtube eq 0) { - print "\n"; - &PrintResults; - } - } - if ($youtube =~ /^([\d]+)$/) { - $PICK = $1; - &ForeachCode; - } - if ($youtube eq '' and $NextPage eq 1) { - $PageNumber = $FirstPage; - ++$PageNumber; - print "\n[!]$bgreen Page:$reset $PageNumber\n"; - $SearchURL = "http://www.youtube.com/results?search_query=$Search". - "&suggested_categories=10%2C24&page=$PageNumber"; - $connect = $lwp->get($SearchURL); - splice @content; - @content = split(/\n/, $connect->content, 0); - print "\n"; - $FirstPage = $PageNumber; - &Search; - } - elsif ($NextPage eq 0 and $youtube eq '') { - print "\n"; - &PrintResults; - } - if ($youtube eq 'all') { - $SearchBackup .= ' --1080'; - splice @picks; - for ($i = 1; $i <= $number; ++$i) { - push @picks, "$i"; - } - &PicksArea; - } - if ($youtube =~ m[v([=/]+)([\w\-]{11})]) { - $youtube = "http://youtube.com/watch?v=$2"; - &GetYouTube; - } - if ($youtube =~ /([\d]+) ([\d]+)/) { - @picks = split(' ', $youtube, 0); - &PicksArea; - sub PicksArea { - $NrOfPicks = @picks; - $no = 0; - $lastpick = ''; - $number = 0; - &ForeachPick; - } - - sub ForeachPick { - for ($number = $no; $number <= $NrOfPicks; ++$number) { - $no = $number; - $pick = $picks[$number]; - next if $lastpick eq $pick; - &PrintResults if $number eq $NrOfPicks; - $Picks = 'TRUE'; - $lastpick = $pick; - &PlayBack; - } - } - ; - } - if ($youtube ne 'all' and $youtube =~ /(.+)/ and not $youtube =~ /^(q|quit|exit)$/) { - $Search = $youtube; - &Trizen; - } -} -sub PlayBack { - foreach $Code (@codes) { - if ($Picks eq 'TRUE' and not $Code =~ /^$pick - /) { - next; - } - elsif ($Code =~ /^$pick - ([\w\-]{11})(.*)/ and $Picks eq 'TRUE') { - $VideoCode = $1; - $duration = $2; - $youtube = "http://www.youtube.com/watch?v=$1"; - } - elsif ($Code =~ /(.+)([\w\-]{11})(.*)/ and $Picks ne 'TRUE') { - $VideoCode = $2; - $duration = $2; - $youtube = "http://www.youtube.com/watch?v=$2"; - } - &GetYouTube; - } -} -sub VideoCheck { - if (not $connect->content =~ /itag=34/ and $connect->content =~ /itag=([\d]+)([\W]+)/) { - $itag = $1; - $streaming =~ s/(.*)http(.+)itag=$itag([^\%]*)(.+)/http$2itag=$itag$3/; - unless ($SearchBackup =~ / ([-]?)-f/) { - $MPlayerLine =~ s/-fs //; - } - &Description; - &MPlayer; - } - if ($b =~ /^([-]?)-4/ or $PickBackup =~ / ([-]?)-4/ or $SearchBackup =~ / ([-]?)-4/) { - $streaming =~ s/(.*)http(.+)itag=34([^\%]*)(.+)/http$2itag=34$3/; - unless ($SearchBackup =~ / ([-]?)-f/) { - $MPlayerLine =~ s/-fs //; - } - &Description; - &MPlayer; - } - if ($b =~ /^([-]?)-7/ or $PickBackup =~ / ([-]?)-7/ or $SearchBackup =~ / ([-]?)-7/) { - if ($connect->content =~ /itag=22/) { - $streaming =~ s/(.*)http(.+)itag=22([^\%]*)(.+)/http$2itag=22$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &Description; - &MPlayer; - } - else { - unless ($SearchBackup =~ / ([-]?)-f/) { - $MPlayerLine =~ s/-fs //; - } - $streaming =~ s/(.*)http(.+)itag=34([^\%]*)(.+)/http$2itag=34$3/; - &Description; - &MPlayer; - } - } - if ($b =~ /^([-]?)-1/ or $PickBackup =~ / ([-]?)-1/ or $SearchBackup =~ / ([-]?)-1/) { - if ($connect->content =~ /fmt_list=37/) { - $streaming =~ s/(.*)http(.+)itag=37([^\%]*)(.+)/http$2itag=37$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &Description; - &MPlayer; - } - elsif ($connect->content =~ /itag=22/) { - $streaming =~ s/(.*)http(.+)itag=22([^\%]*)(.+)/http$2itag=22$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &Description; - &MPlayer; - } - else { - unless ($SearchBackup =~ / ([-]?)-f/) { - $MPlayerLine =~ s/-fs //; - } - $streaming =~ s/(.*)http(.+)itag=34([^\%]*)(.+)/http$2itag=34$3/; - &Description; - &MPlayer; - } - } - &Description; - &ResolutionSearch; -} -sub Description { - if ($connect->content =~ /likes\">([\d\.\,]+)(.+)dislikes\">([^\<]+)/) { - $like = $1; - $dislike = $3; - } - if ($connect->content =~ m[video-date" >([\ ]*)\n([\t\ ]*)(.+)\n([\ ]*)</span>]) { - $date = $3; - $date =~ s[<span>(.+)</span>][]; - } - if ($connect->content =~ /<meta name="title" content="(.+)">/) { - $title = $1; - $title =~ s/\&quot;/"/g; - $title =~ s/\&amp;/&/g; - $title =~ s/\&\#39;/'/g; - $title =~ s/\&\#([\d]+);//g; - } - print "\n$bred=>> $reset"; - print $bgreen; - print "$title\n"; - print $reset; - print '-' x 80; - if ($connect->content =~ m[description" >(.*)</p>]) { - $desc = $1; - $desc =~ s[<em>|</em>][]g; - $desc =~ s[<br\ />|<br/>][\n]g; - $desc =~ s[<a\ href\=\"\#\"\ onclick\=\"yt\.www\.watch\.player\.seekTo\((.+)\);return\ false;\">|<a\ href\=\"(.+)\"\ target\=\"\_blank\"\ title\=\"|\"\ rel\=\"nofollow\"\ dir="ltr\"\ class\=\"(.*)\">(.+)</a>|<wbr />|</a>|<wbr>\­|<wbr>][]g; - $desc =~ s/\"/"/g; - $desc =~ s/&/&/g; - $desc =~ s/\&\#39;/'/g; - $desc =~ s/\&\#([\d]+);//g; - print "\n$desc\n"; - } - print '-' x 80 . "\n"; - print "$bred=>> $reset"; - print $bgreen; - print "View & Download\n"; - print $reset; - print '-' x 80; - $get = $streaming; - $get =~ s/http:([^\%]+)(.*)/http:$1/; - $get =~ s/(.*)http/http/; - $get =~ s/\\//g; - print "\n* URL $url\n"; - print "* GET $get\n"; - print '-' x 80 . "\n"; - $count = $title =~ s/(.)/$1/gs; - if ($count <= 40) { - print "$bred\t\t=>> "; - } - elsif ($count >= 40 and $count <= 55) { - print "$bred\t=>> "; - } - elsif ($count >= 56) { - print "$bred =>> "; - } - print $bgreen; - print "$title"; - print $reset; - print "$bred <<=\n"; - print $reset; - if ($connect->content =~ m[href="/user/([\w\-]+)"><strong>]) { - print "\n* Uploaded by $1\n"; - } - if ($duration) { - print "* Duration:$duration\n"; - } - if ($connect->content =~ m[<strong>([\d\,]+)</strong>]) { - print "* Views: $1\n"; - } - if ($date =~ /(.+)/) { - print "* Date: $date\n"; - } - if ($like =~ /(.+)/) { - print "* Likes: $like+; Dislikes: $dislike-\n"; - } - print '-' x 80 . "\n\n"; -} -sub MPlayer { - $streaming =~ s/%(.+)$//; - `$MPlayerLine "$streaming"`; - print "\n"; - if ($Picks) { - if ($Picks eq 'TRUE') { - &ForeachPick; - } - } - if ($Search or $a =~ /^([-]?)-c/ or $username eq 1) { - &PrintResults; - } - exit; -} -sub ForeachCode { - foreach $code (@codes) { - if ($code =~ /^$PICK - ([\w\-]{11})(.*)/) { - $code = $1; - $duration = $2; - $youtube = 'http://www.youtube.com/watch?v=' . $code; - $url = $youtube; - } - } - &GetYouTube; -} -sub GetYouTube { - if ($youtube =~ m[v([=/]+)([\w\-]{11})]) { - $VideoCode = $2; - $youtube = 'http://www.youtube.com/watch?v=' . $2; - } - $Count = $VideoCode =~ s/(.)/$1/gs; - if ($Count ne 11) { - print "\n$bred(x_x) Invalid URL...$reset\n\n"; - exit; - } - unless ($youtube =~ /^http:/) { - $youtube = 'http://' . $youtube; - } - $connect = $lwp->get($youtube); - $url = $youtube; - if ($connect->content =~ /fmt_url_map=([^\&]+)\&/) { - $streaming = $1; - $streaming =~ s/%3A/:/gi; - $streaming =~ s[%2F][/]gi; - $streaming =~ s/%26/&/g; - $streaming =~ s/%3D/=/gi; - $streaming =~ s/%3F/?/gi; - $streaming =~ s/%252C/,/gi; - &VideoCheck; - } - else { - $unable = "$bred(x_x) Unable to play: $reset$url\n"; - print $bred; - print "\n(x_x) Something went wrong...\n\n"; - print $reset; - if (not $SearchBackup =~ / -p/ or $NrOfPicks eq '') { - print "$unable\n"; - } - if ($Search =~ /(.+)/) { - unless ($SearchBackup =~ / -p/) { - sleep 1; - &PrintResults; - } - } - else { - exit; - } - } - if ($streaming =~ /(.+)/) { - &Description; - } - else { - print $unable; - } - &ResolutionSearch; -} -sub ResolutionSearch { - if ($connect->content =~ /fmt_list=37/ and not $SearchBackup =~ / -p/) { - &pick; - } - elsif ($SearchBackup =~ /-p/) { - if ($connect->content =~ /fmt_list=37/) { - $streaming =~ s/(.*)http(.+)itag=37([^\%]*)(.+)/http$2itag=37$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &Description; - &MPlayer; - } - } - if ($connect->content =~ /itag=22/) { - $streaming =~ s/(.*)http(.+)itag=22([^\%]*)(.+)/http$2itag=22$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &MPlayer; - } - else { - $streaming =~ s/(.*)http(.+)itag=34([^\%]*)(.+)/http$2itag=34$3/; - unless ($SearchBackup =~ / ([-]?)-f/) { - $MPlayerLine =~ s/-fs //; - } - &MPlayer; - } -} -sub pick { - print "$bred=>>$reset $bgreen Please choose quality of video (default: 1)$reset\n\n"; - print " $bred 1$reset - 1280x720 (720p)\n $bred 2$reset - 1920x1080 (1080p)\n "; - print '=' x 23 . "\n"; - print $bgreen; - print "\n=>> Pick format: "; - print $reset; - chomp($pick = <STDIN>); - print '-' x 80 . "\n\n"; - if ($pick ne 2) { - $streaming =~ s/(.*)http(.+)itag=22([^\%]*)(.+)/http$2itag=22$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &MPlayer; - } - if ($pick eq 2) { - $streaming =~ s/(.*)http(.+)itag=37([^\%]*)(.+)/http$2itag=37$3/; - $MPlayerLine =~ s/mplayer -p/mplayer -fs -p/; - $MPlayerLine =~ s/mplayer.exe" -p/mplayer.exe" -fs -p/; - &MPlayer; - } -} |