Top

Youtube advanced search


mIRC Code
+ 2 likes
Please Register to submit score.
Bookmark and Share
Average Score  10.0 (of 1 scores)
Date Added  Nov 15, 2009
Last Updated  Jan 29, 2010
Tags  fordlawnmower  youtube 

Description

Youtube search script for mIRC.
Script was requested by kibblz
Syntax : !youtube -novr search words here. The -switches are optional.
Switch explaination : -n (newest) -o (oldest) -v (view count) -r (rating)
!youtube -h for help
Examples : !youtube -n mad dog
Examples: !youtube mad dog
Examples: @youtube mad dog

The ! trigger will notice the user and the @ trigger will message the channel if the user has halfops or higher.

Demo:
02:08:36 <Ford_Lawnmower> @youtube whiskey
02:08:37 <MyMulez> Searching Youtube........
02:08:39 <MyMulez> Title: Brad Paisley and Alison Kraus - Whiskey Lullaby.wmv Length: 5:28 Type: Music User: bubenceto033 Rating: 5.0 Views: 354 237 Added: 2 years ago Link: http://www.youtube.com/watch?v=G0nA74_0K30
02:08:39 <MyMulez> Title: whiskey lullaby Length: 4:20 Type: Music User: mofradan Rating: 5.0 Views: 1 248 088 Added: 2 years ago Link: http://www.youtube.com/watch?v=7gV3g9LCvPc
02:08:42 <MyMulez> Title: Metallica - Whiskey In The Jar: Video Length: 5:00 Type: Music User: universalmusicgroup Rating: 5.0 Views: 1 885 454 Added: 1 year ago Link: http://www.youtube.com/watch?v=7oKLq1JD3vU

Grab the Code

;Youtube advanced search by Ford_Lawmower irc.mindforge.org #USA-Chat
menu Channel,Status {
  .$iif($group(#Youtube) == On,$style(1)) Youtube Trigger
  ..$iif($group(#Youtube) == On,$style(2)) On: .enable #Youtube
  ..$iif($group(#Youtube) == Off,$style(2)) Off: .disable #Youtube
}
#Youtube OFF
On $*:Text:/^(!|@)Youtube.*/Si:#: {
  if (!$timer($+(Youtube,$network,$nick))) {
    .timer $+ $+(Youtube,$network,$nick) 1 6 noop
    var %method $iif($regml(1) == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
    GetYoutube %method $strip($2-)
  }
}
#Youtube END
alias Youtube { GetYoutube echo -a $1- }
alias -l GetYoutube {
  $1-2 07» Searching Youtube........
  var %sockname $+(Youtube,$network,$2,$ticks)
  var %yt.url $replace($3-,$chr(32),+)
  if ($left($3,1) == -) {
    if ($3 == -h || !$4) {
      $1-2 Syntax is !Youtube search words here. Optionally, you can change the search type by adding a search flag directly after !youtube and before The search word(s)
      $1-2 Valid search flags are -n (newest) -o (oldest) -v (view count) -r (rating) . Ex. !Youtube -n jimi hendrix  <<-- Will show the 3 newest posts with jimi hendrix in them.
      $1-2 You can also use the @ trigger to message the channel if you have halfops or higher. Ex. @Youtube jimi hendrix
      return
    }  
    elseif ($3 == -n) { var %SearchType &search_sort=video_date_uploaded }
    elseif ($3 == -o) { var %SearchType &search_sort=video_date_uploaded_reverse }
    elseif ($3 == -v) { var %SearchType &search_sort=video_view_count }
    elseif ($3 == -r) { var %SearchType &search_sort=video_avg_rating }
    %yt.url = $replace($4-,$chr(32),+) $+ %SearchType
  }
  var %yt.url $replace($iif(- isin $3,$4-,$3-),$chr(32),+) $+ %SearchType
  sockopen %sockname www.youtube.com 80
  sockmark %sockname $1-2 $+(/results?search_type=&aq=f&search_query=,%yt.url) 0 title duration category user 04Rating08:0 views uploader link
}
On *:sockopen:Youtube*: {
  if (!$sockerr) {
    sockwrite -nt $sockname GET $gettok($sock($sockname).mark,3,32) HTTP/1.0
    sockwrite -n $sockname Host: www.youtube.com
    sockwrite -n $sockname $crlf
  }
  else { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
}
On *:sockread:Youtube*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | sockclose $sockname | return }
  else {
    var %Youtube | sockread %Youtube
    if (No videos found for isin %youtube) { $gettok($sock($sockname).mark,1-2,32) Sorry No Results! | sockclose $sockname | return }
    if ($regex(%Youtube,/<strong class="hovercard-title" >(.*)</strong><br>/)) sockmark $sockname $puttok($sock($sockname).mark,$+(04Title08: ,$sp($+($chr(32),$regml(1)))),5,32)
    if ($regex(%youtube,/<span class="hovercard-duration">(.*)</span> &nbsp;/)) sockmark $sockname $puttok($sock($sockname).mark,$+(04Length08: ,$sp($+($chr(32),$regml(1)))),6,32)
    if ($regex(%youtube,/<p class="hovercard-category">(.*)</p>/)) sockmark $sockname $puttok($sock($sockname).mark,$+(04Type08: ,$sp($+($chr(32),$regml(1)))),7,32)
    if ($regex(%youtube,/<p class="hovercard-username">(.*)</p>/)) sockmark $sockname $puttok($sock($sockname).mark,$+(04User08: ,$sp($+($chr(32),$regml(1)))),8,32)
    if ($regex(%youtube,/ratingL ratingL-(.*)" title="/)) sockmark $sockname $puttok($sock($sockname).mark,$sp($+(04Rating08: ,$+($chr(32),$regml(1)))),9,32)
    if ($regex(%youtube,/<span class="hovercard-views">(.*)views</span>/)) sockmark $sockname $puttok($sock($sockname).mark,$+(04Views08: ,$sp($+($chr(32),$regml(1)))),10,32)
    if ($regex(%youtube,/class="video-date-added">(.*)</span>/)) sockmark $sockname $puttok($sock($sockname).mark,$+(04Added08: ,$sp($+($chr(32),$regml(1)))),11,32)
    if ($regex(%youtube,/<a id="video-long-title-(.*)" href="/)) { sockmark $sockname $puttok($sock($sockname).mark,$sp($+(04Link08:,$chr(32),http://www.youtube.com/watch?v=,$regml(1))),12,32) }
    if (<div class="video-clear-list-left"></div> isin %youtube) {
      sockmark $sockname $puttok($sock($sockname).mark,$calc($gettok($sock($sockname).mark,4,32) + 1),4,32)
      $gettok($sock($sockname).mark,1-2,32) 07» $sp($gettok($sock($sockname).mark,5-12,32))
    }
    if ($gettok($sock($sockname).mark,4,32) >= 3) { sockclose $sockname | return }
  }
}
alias -l Sp { return $iif($chr(7) isin $1-,$replace($1-,$chr(7),$chr(32)),$replace($1-,$chr(32),$chr(7))) }
 

Comments

  (19)  RSS
Grant-
Comments: 94
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 15, 2009 1:17 pm
Very nice, very sexy.
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 15, 2009 1:23 pm
Thank You Grant- :)
Cracker200
Comments: 272
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 16, 2009 10:46 am
Exelent! :D
Cracker200
Comments: 272
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 16, 2009 10:49 am
Code:
 
***
[16:48:41:pm] * Connecting to irc.mindforge.org (6667)
***
[16:48:55:pm] * Unable to connect to server (Socket operation on non-socket)
***
[16:48:58:pm] 

WTF!? ...
I was on there a Few days ago and now this O.o
Shinybot
Comments: 41
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 16, 2009 10:50 am
Nice Very Usful
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 16, 2009 11:36 am
Thanks Cracker200. Thanks Shinybot.
Strange connection error Cracker200. Never seen that one before.
surrenderNdie
Comments: 4
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 23, 2009 1:59 pm
I must just be dumb, because it keeps telling me that /sockopen insufficient parameters.
Can someone please help me?
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 23, 2009 2:55 pm
@surrenderNdie Nah, I'm sure you're not dumb. Perhaps you have another script running that is causing a conflict.
Are you using some kind of full script like NNS?

This has to be a script conflict because the script will always provide enough parameters for sockopen.

Here is the sockopen -->> sockopen %sockname www.youtube.com 80

Here %sockname is set -->> var %sockname $+(Youtube,$network,$2,$ticks)

Do you have another script that may be responding to !youtube?

I would suggest loading this into a blank mIRC if you can't find the conflict.
Then you might try unloading all your scripts and reloading them one at a time till you find the one that is causing the trouble.

Chances are there is a poorly written script in there that is causing the problem.
surrenderNdie
Comments: 4
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 24, 2009 3:23 am
I unloaded all of them and it still gives this as the problem when I type @Youtube Boston:

* /sockopen: insufficient parameters (line 35, script1.ini)
-
-L Unknown command
-
BOSTON Unknown command
-
-L Unknown command
-
-L Unknown command
-
-L Unknown command
-
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 24, 2009 11:11 am
I cannot reproduce that error surrenderNdie, but I have a theory.
What is the network name?? What is the channel name??
My theory is that the sockname -- this -->> $+(Youtube,$network,$2,$ticks)
Has something in it that is being over evaluated and causing a line break before all the parameters are sent in the sockopen statement.
If this is somehow happening, I will need the network name and the channel name to sort it.
surrenderNdie
Comments: 4
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 24, 2009 3:14 pm
irc.everywherechat.com -> network & #AboutGerman_Chat is the channel. Thanks for your help!!
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Nov 24, 2009 6:45 pm
Well I don't see any issue with those names. I tried them on another server with no issues. The problem must be something to do with the network you are on. I tried to join there so I could figure it out, but they are running some crazy N00b scripts That won't let mIRC connect.
[18:26:05] * Ford_Lawnmower sets mode: +x
-
[18:26:05] ERROR Closing link (Yoda@cpe-xxx-xxx-xxx-xxx.cinci.res.rr.com) [Sorry, IRC client users must register first.]
-
[18:26:05] * NickServ sets mode: +U
-
[18:26:05] * Disconnected

I tried connecting there from 2 different computers with 4 different clients. Same result for all of them. Proxy, no Proxy it didn't seem to matter. It's some kind of flashchat network or something.

The only thing I can suggest is try this version -->> http://pastebin.com/m53b7de66

$network,$chan or $nick must just be reporting something crazy on that network. A $crlf attached to the end or something.
Spanky
Comments: 232
 
mIRC Snippet:  Youtube advanced search
Posted on Jan 29, 2010 8:15 pm
atm when i use this i get


unknown command o

then unknown command youtube. it was working last night <.<
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Jan 29, 2010 9:14 pm
What command is giving you the error Spanky?
As far as I know, I currently have no issues with this script.

I just posted an update, but it was to address a minor issue with the ratings. I also changed the alias from ECHOYoutube to Youtube but this was just to make it more practical.

If you are still having trouble try using the new code.
Also you might want to review the youtube scripts that you have loaded recently and make sure that none of them use the socket name Youtube*.
Spanky
Comments: 232
 
mIRC Snippet:  Youtube advanced search
Posted on Jan 31, 2010 10:51 am
Okay i feel like a total idiot.
I.. Somehow had a script misplaced in aliases, although i swear the day before alias was empty Sorry FordLawnmower 10/10 sorry for my stupidness.
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Jan 31, 2010 11:08 am
No worries Spanky, I wouldn't have found the bug in the ratings results without your post :)
DiRtDoG
Comments: 3
 
mIRC Snippet:  Youtube advanced search
Posted on Feb 7, 2010 9:35 pm
Great script but for some reason if I type @youtube blue monday it won't display on the channel but if I /youtube blue monday it display only for me
FordLawnmower
Comments: 612
 
mIRC Snippet:  Youtube advanced search
Posted on Feb 7, 2010 10:16 pm
@DiRtDoG This script is made to be loaded into a Second mIRC client. You can't trigger the script from the client that it is loaded into. Also when others trigger the script, it will display to the channel but it won't echo back to it's own screen.
The easiest way to use a bot script like this is to copy everything in your mIRC Directory to a new directory(like mIRC2) and then run the mIRC in the new directory.
Set then new mIRC up with new nick names, etc. and then you can start loading and using bot scripts like this one.
DiRtDoG
Comments: 3
 
mIRC Snippet:  Youtube advanced search
Posted on Feb 7, 2010 11:30 pm
okay thanks for the explanation I will look into doing that.

Commenting Options

Register or Login to Hawkee.com or use your Facebook or Twitter account by clicking the corresponding button below.

  

Bottom