YouTube Video Searcher

Platform:  mIRC
Published  Feb 29, 2008
Updated  Dec 13, 2008
This here is a YouTube video searcher. It returns the first three videos of your search result.

It returns the Title, Date Added, User, Length, Views, Rating, and URL for each video.

Syntax: [!YouTube | /YouTube] [Search Criteria]

If you want to change how many videos it returns, you can change "if (%n. [ $+ [ $sockname ] ] >= 3) {" to whatever number of videos you want it to return.

Here's some screens:





Enjoy ;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
; YouTube Video Searcher ;
; Made by MountainDew ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;

on $*:text:/^[!@.](y(ou)?tube|yt)\b/Si:#:{
youtube $+($ticks,$chr(1),$chan,$chr(1),$2-)
}
alias youtube {
if ($numtok($1-,1) >= 2) {
tokenize 1 $1-
var %y.sock $1
var %y.chan $2
var %y.text $3-
}
else {
var %y.sock $ticks
var %y.text $1-
}
if (!%y.text) {
$iif(%y.chan,msg $v1,echo -a) Syntax: $iif(%y.chan,!,/) $+ YouTube [search criteria]
halt
}
$iif(%y.chan,describe $v1 searches,echo -a Searching) for YouTube videos matching $qt($+(,%y.text,)) $+ ...
sockopen youtube. [ $+ [ %y.sock ] ] www.youtube.com 80
sockmark youtube. [ $+ [ %y.sock ] ] $+($iif(%y.chan,msg $v1,echo -a),$chr(1),%y.text)
}
on *:SOCKOPEN:youtube.*: {
sockwrite -nt $sockname GET /results?search_query= $+ $urlencode($gsm($sockname,2,1)) HTTP/1.1
sockwrite -nt $sockname Host: www.youtube.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:youtube.*: {
if ($sockerr) {
$gsm($sockname,1,1) Error connecting to YouTube: $sock($sockname).wmsg
sockclose $sockname
}
else {
var %x. [ $+ [ $sockname ] ]
sockread %x. [ $+ [ $sockname ] ]
if (no videos found for isin %x. [ $+ [ $sockname ] ]) {
$gsm($sockname,1,1) The search for $qt($+(,$gsm($sockname,2,1),)) returned no results.
sockclose $sockname
}
if ($regex(%x. [ $+ [ $sockname ] ],/<a id="video-url-.+?" href="(\/watch\?v=.+?)".+<img title="(.+?)"/i)) {
set %yt.url $regml(1)
set %yt.title $regml(2)
}
if ($regex(%x. [ $+ [ $sockname ] ],/<span id="video-run-time-.+?">(\d+:\d+)<\/span><\/div>/i)) set %yt.length $regml(1)
if ($regex(%x. [ $+ [ $sockname ] ],/(\d+? .+? ago)/i)) set %yt.added $regml(1)
if ($regex(%x. [ $+ [ $sockname ] ],/<img class="ratingVS.+?" alt="(.+?)" src=/i)) set %yt.rating $regml(1)
if ($regex(%x. [ $+ [ $sockname ] ],/class="video-view-count">(.+) views</span>/i)) set %yt.views $regml(1)
if (video-from-username isin %x. [ $+ [ $sockname ] ]) {
inc %n. [ $+ [ $sockname ] ]
$gsm($sockname,1,1) 9 $+ $chr(149) 4Title: $hf(%yt.title) 4Added: %yt.added 4User: $hf($v2) 4Length: %yt.length 4Views: %yt.views 4Rating: $iif(%yt.rating,$v1,0) $+ /5 4URL: http://www.youtube.com $+ %yt.url
if (%n. [ $+ [ $sockname ] ] >= 3) {
sockclose $sockname
unset %n. [ $+ [ $sockname ] ] %yt.*
}
unset %yt.*
sockmark $sockname $+($gsm($sockname,1,1),$chr(1),$gsm($sockname,2,1))
}
if (<!-- end search results --> isin %x. [ $+ [ $sockname ] ]) sockclose $sockname
}
}
alias hf return $remove($replace($regsubex($1-,/^[^<]*>|<[^>]*>|<[^>]*|$|&[^;]+;/g,$null),&quot;,",&gt;,>,&lt,<,&amp;,&,&nbsp;,$chr(160)),?,$chr(9))
alias gsm return $gettok($sock($1).mark,$2,$3)
alias urlencode return $regsubex($1,/(\W)/gS,% $+ $base($asc(\1),10,16,2)))

Comments

Sign in to comment.
SnoooP   -  Feb 21, 2011
Maybe since the script was last edited youtube, has had format changes, I know this caused problems with this script once before, so maybe it isn't a version issue, but an issue with the script itself.
 Respond  
Orion   -  Feb 21, 2011
it seems not work on mirc 6.2 :(

21:00:22 :       No|Over ¦ @yt test
21:00:24 ?            * Bot ¦ searches for YouTube videos matching "test"..

no anwsers...
 Respond  
RicJames   -  Mar 26, 2010
If you need a working youtube search script FordLawnmower has made one and it works perfectly.
 Respond  
mountaindew   -  Mar 23, 2010
Yea I'm sure the source code has changed many times...

I don't have mIRC anymore, so if anyone feels like fixing it feel free.
 Respond  
VinX   -  Mar 22, 2010
same problem as the previous 5-6 posts
 Respond  
Peninje   -  Feb 09, 2010
I tried it and i got this:

09:00 T-Mod � Title: Added: 3 days ago User: cctvupload Length: Views: 5 Rating: 0/5 URL: http://www.youtube.com
09:00 T-Mod � Title: Added: 2 years ago User: aarozona Length: Views: 79,248 Rating: 0/5 URL: http://www.youtube.com
09:00 T-Mod � Title: Added: 2 years ago User: pivit66 Length: Views: 10,296 Rating: 0/5 URL: http://www.youtube.com

whats wrong?
the links are not right :/
 Respond  
kibblz   -  Nov 24, 2009
now this script is really stuffed. title and url don't show now. youtube updated again? *sigh*

[7:27:53 pm] <GreenPowerRanger> !youtube power rangers theme
[7:27:55 pm] * Tifa searches for YouTube videos matching "power rangers theme"...
[7:28:00 pm] <Tifa> • Title: Added: 1 year ago User: RetroRanger64 URL: http://www.youtube.com

 Respond  
RicJames   -  Nov 23, 2009
Needs an update :(
 Respond  
SnoooP   -  Nov 13, 2009
It may not work because youtube may have changed the site around a bit. and MountainDew hasn't been active for a while so I think your best posting in the forum asking for help.
 Respond  
kibblz   -  Nov 13, 2009
length/duration, ratings, views.. all don't work. the views works but it is never accurate. someone fix it.. love this script :(

[7:13:07 am] <harleyquinn> !youtube uncharted montage
[7:13:07 am] * Tifa searches for YouTube videos matching "uncharted montage"...
[7:13:08 am] <Tifa> • Title: ZoDiakh - Uncharted Montage Added: 9 months ago User: SiiK69SiiNz Length: Views: 26,381 Rating: 0/5 URL: http://www.youtube.com/watch?v=RFjaPva5GwM

oh and the Added by i think is set for US time or something? cause one video i searched for says Added : 1 day ago which infact was 3 days ago so that's weird.
 Respond  
papanoel   -  Aug 21, 2009
dont work :(
<O_o> !youtube papa
* Pass searches for YouTube videos matching ...
<Pass> The search for returned no results.
 Respond  
bloodskin   -  Jul 03, 2009
WARNING ::: RATING DOES NOT WORK


;~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*;
; YouTube Video Searcher ;
; Made by MountainDew ;
; Updated July 3rd 2009 by BloodSkin ;
;*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~;

on $*:text:/^[!@.](y(ou)?tube|yt)\b/Si:#:{
youtube $+($ticks,$chr(1),$chan,$chr(1),$2-)
}
alias youtube {
if ($numtok($1-,1) >= 2) {
tokenize 1 $1-
var %y.sock $1
var %y.chan $2
var %y.text $3-
}
else {
var %y.sock $ticks
var %y.text $1-
}
if (!%y.text) {
$iif(%y.chan,msg $v1,echo -a) Syntax: $iif(%y.chan,!,/) $+ YouTube [search criteria]
halt
}
$iif(%y.chan,describe $v1 searches,echo -a Searching) for YouTube videos matching $qt($+(,%y.text,)) $+ ...
sockopen youtube. [ $+ [ %y.sock ] ] www.youtube.com 80
sockmark youtube. [ $+ [ %y.sock ] ] $+($iif(%y.chan,msg $v1,echo -a),$chr(1),%y.text)
}
on *:SOCKOPEN:youtube.*: {
sockwrite -nt $sockname GET /results?search_query= $+ $urlencode($gsm($sockname,2,1)) HTTP/1.1
sockwrite -nt $sockname Host: www.youtube.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:youtube.*: {
if ($sockerr) {
$gsm($sockname,1,1) Error connecting to YouTube: $sock($sockname).wmsg
sockclose $sockname
}
else {
var %x. [ $+ [ $sockname ] ]
sockread %x. [ $+ [ $sockname ] ]
if (no videos found for isin %x. [ $+ [ $sockname ] ]) {
$gsm($sockname,1,1) The search for $qt($+(,$gsm($sockname,2,1),)) returned no results.
sockclose $sockname
}
if ($regex(%x. [ $+ [ $sockname ] ],/<a id="video-url-.+?" href="(\/watch\?v=.+?)".+<img title="(.+?)"/i)) {
set %yt.url $regml(1)
set %yt.title $regml(2)
}
if ($regex(%x. [ $+ [ $sockname ] ],/<span id="video-run-time-.+?">(\d+:\d+)<\/span><\/div>/i)) set %yt.length $regml(1)
if ($regex(%x. [ $+ [ $sockname ] ],/(\d+? .+? ago)/i)) set %yt.added $regml(1)
if ($regex(%x. [ $+ [ $sockname ] ],/<img class="ratingVS.+?" alt="(.+?)" src=/i)) set %yt.rating $regml(1)
if ($regex(%x. [ $+ [ $sockname ] ],/class="video-view-count">(.+) views</span>/i)) set %yt.views $regml(1)
if (" class="hLink" href="/user/ isin %x. [ $+ [ $sockname ] ]) {
inc %n. [ $+ [ $sockname ] ]
$gsm($sockname,1,1) 9 $+ $chr(149) 4Title: $hf(%yt.title) 4Added: %yt.added 4User: $hf($v2) 4Length: %yt.length 4Views: %yt.views 4Rating: $iif(%yt.rating,$v1,0) $+ /5 4URL: http://www.youtube.com $+ %yt.url
if (%n. [ $+ [ $sockname ] ] >= 3) {
sockclose $sockname
unset %n. [ $+ [ $sockname ] ] %yt.*
}
unset %yt.*
sockmark $sockname $+($gsm($sockname,1,1),$chr(1),$gsm($sockname,2,1))
}
if (<!-- end search results --> isin %x. [ $+ [ $sockname ] ]) sockclose $sockname
}
}
alias hf return $remove($replace($regsubex($1-,/^[^<]*>|<[^>]*>|<[^>]*|$|&[^;]+;/g,$null),&quot;,",&gt;,>,&lt,<,&amp;,&,&nbsp;,$chr(160)),?,$chr(9))
alias gsm return $gettok($sock($1).mark,$2,$3)
alias urlencode return $regsubex($1,/(\W)/gS,% $+ $base($asc(\1),10,16,2)))



 Respond  
Purcell   -  Feb 17, 2009
How i can set it in Notice? :)

Nice script!
 Respond  
satya87   -  Feb 07, 2009
rating doesnt work anymore baaah
 Respond  
greenlanter420   -  Jan 31, 2009
it looks like they changed something on youtube again
 Respond  
SuPeRFlY   -  Dec 18, 2008
This snippet works perfect. 8/10
 Respond  
uneek   -  Dec 17, 2008
Looks like they changed the page again :/

[02:15] <Grant> !youtube apple
[02:15] * uNeek searches for YouTube videos matching ...
[02:15] <uNeek> The search for returned no results.
 Respond  
jonesy44   -  Dec 14, 2008
If the video was posted in the UK, it would link to the UK subdomain :]
 Respond  
TwistedHumor   -  Dec 14, 2008
any reason why it would be sending me to uk youtube?
 Respond  
jonesy44   -  Dec 13, 2008
Student here too lol :P Good stuff, nice one md x]
 Respond  
Protech   -  Dec 13, 2008
hehe jonesy44 ;) He's not the only student ;) Just trying to remind him that people are appreciating his work :)
But it seems fixed now :D YATTA! :)
 Respond  
mountaindew   -  Dec 13, 2008
Alright, should work now.
 Respond  
mountaindew   -  Dec 13, 2008
Crap I started fixing it and forgot to finish it :/

I'll do it right now.
 Respond  
jonesy44   -  Dec 13, 2008
lol, hang in there, Protech. MD's a student so i'm not sure if he gets that much time.
 Respond  
Protech   -  Dec 13, 2008
Any progress mate? :D I've been checking this site everyday for an update now ;) Love this script :D
 Respond  
jonesy44   -  Dec 08, 2008
Gay Google :[
 Respond  
mountaindew   -  Dec 08, 2008
Damn, looks like the whole page is changed...I'll try working on it.
 Respond  
Protech   -  Dec 07, 2008
I love this script, but it seems I have the same problem as greenlanter now. It just do /me searches for "your search" and then nothing happens.
Would be great with an update moutaindew ;) I love your work. Thanks for doing this for all of us:)
 Respond  
jonesy44   -  Dec 06, 2008
I guess so.. no complaints?
 Respond  
greenlanter420   -  Dec 06, 2008
is this still working? its not working for me it just hangs on search
 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.