|
iamdegenatron
|
iamdegenatron
|
Hi, I managed to make this after a week's worth of insanity (I am a scripting noob)... It matches on *youtube.com/watch* and it looks up the video's title and description, and says it in the channel asked. The part I'm having trouble with is that, sometimes the title and description is flat out wrong. It either a) returns a previous matches' title/desc b) returns "http" as title and desc (I don't know why) c) returns null for both title and desc If someone can take a look at this, I would be much obliged ^_^ ; you need this module: http://www.xise.nl/mirc/url.mrc
; you need this module: http://www.xise.nl/mirc/url.mrc
; you need this module: http://www.xise.nl/mirc/url.mrc
on *:text:*youtube.com/watch*:*: {
set %titles $remove($regml(1),<h1 id="video_title">,</h1>)
set %descs $remove($regml(1), ,<span id="vidDescRemain">,<br/>,</span>)
%url = $*
%youtubepathurl = $urlparse(%url).path
if ($sock(111111)) .sockclose 111111
sockopen 111111 youtube.com 80
msg $chan %youtubepathurl Title: %titles Description: %descs
; unset %titles
; unset %descs
; unset %url
; unset %youtubepathurl
}
on *:SOCKOPEN:111111: {
sockwrite -nt $sockname GET %youtubepathurl HTTP/1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf
}
on *:SOCKREAD:111111: {
if ($sockerr) {
msg %chan Socket Error: $sockname $+ . Error code: $sockerr Please inform $me of this error message.
halt
}
else {
var %sockreader
sockread %sockreader
if (*"video_title"* iswm %sockreader ) {
noop $regex(%sockreader,/<h1 id="video_title">(.*?)</h1>/Si)
}
if (*"vidDescRemain"* iswm %sockreader ) {
noop $regex(%sockreader,/<span id="vidDescRemain">(.*?)</span>/Si)
sockclose 111111
}
}
}
|
|
|
|
iamdegenatron
|
iamdegenatron
|
In case you guys were wondering if I pulled it off or not... I did. I spent days belaboring over this with another friend and here is the product: It catches on *youtube.com/watch?v=* . It activates a @window to paste results into and writes to a youtube.txt file for future reference in case you close the @window. The results include the title of the video, the description (be it long or short, and by that i mean the fundamental difference in html on youtube videos for long/short descriptions), and how many stars its got, as well as the original comment that the url was mentioned in, in addition to network basics like : what time/day, what network it came from, what channel, and which nick said it. You can change the disgusting colors I have (they only apply to my mIRC's look, sorry) in order to accomodate yourself PLEASE leave your comments and let me know how it is! And if you have any additions to recommend, please let me know! on *:text:*youtube.com/watch?v=*:*:{
%rating = 0
%entry = $1-
if %tube != on {
window @YouTube
set %tube on
echo @YouTube •›› Info: YouTube window opened $day $+ , $date $+ , $time
}
if (http:// isin $1-) %ytpath = / $+ $gettok($gettok($1-,3,47),1,38)
else %ytpath = / $+ $gettok($gettok($1-,2,47),1,38)
%ytnick = $nick
%ytchan = $chan
sockclose yt
sockopen yt youtube.com 80
}
on *:close:@YouTube:{
set %tube off
}
on *:sockopen:yt:{
if ($sockerr) {
echo -a $chr(91) $+ $time $+ $chr(93) YouTube: socket error
if (%ytchan) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube ERROR: < $+ $date $+ > < $+ $time $+ > < $+ $network %ytchan $+ > < $+ %ytnick $+ > %entry
write yterror.txt < $+ $date $+ > < $+ $time $+ > < $+ $network %ytchan $+ > < $+ %ytnick $+ > %entry
}
if (%ytchan == $null && %ytnick != $null) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube ERROR: < $+ $date $+ > < $+ $time $+ > < $+ $network PM $+ > < $+ %ytnick $+ > %entry
write yterror.txt < $+ $date $+ > < $+ $time $+ > < $+ $network PM $+ > < $+ %ytnick $+ > %entry
}
halt
}
sockwrite -n $sockname GET %ytpath HTTP/1.1
sockwrite -n $sockname Host: youtube.com
sockwrite -n $sockname $crlf
}
on *:sockread:yt: {
:read
sockread -f %ytread
if (<img class="rating" src="/img/star.gif" isin %ytread) {
inc %rating
}
if (<title> isin %ytread) %title = $remove(%ytread, ,<title>YouTube - ,</title>)
if (%found) { unset %found | %desc_be = $remove(%ytread, ) }
if (<span id="vidDescBegin"> isin %ytread) %found = k
if (<span id="vidDescRemain"> isin %ytread) %desc_re = $replace($remove(%ytread, ,<span id="vidDescRemain">,</span>),<br/>,$chr(32))
if (<span class="smallLabel">Category </span> isin %ytread) %done = k
if (%done) {
sockclose yt
unset %done
:title
if (%ytchan) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube 4-----> 4< $asctime(mm:dd:yyyy-HH:nn:ss) $+ 4> 4< $network %ytchan $+ 4> 4< $+ %ytnick $+ 4>
echo @YouTube %entry
echo @YouTube Title: %title Rating: %rating stars
write youtube.txt .....................................................................................................................................................................................................................................................................
write youtube.txt < $+ $date $+ > < $+ $time $+ > < $+ $network %ytchan $+ > < $+ %ytnick $+ > %entry
write youtube.txt Title: %title Rating: %rating stars
}
if (%ytchan == $null && %ytnick != $null) {
echo @YouTube ...................................................................................................................................................................................................................................................................................................
echo @YouTube 4-----> 4< $asctime(mm:dd:yyyy-HH:nn:ss) $+ 4> 4< $network PM $+ 4> 4< $+ %ytnick $+ 4>
echo @YouTube %entry
echo @YouTube Title: %title Rating: %rating stars
write youtube.txt .....................................................................................................................................................................................................................................................................
write youtube.txt < $+ $date $+ > < $+ $time $+ > < $+ $network PM $+ > < $+ %ytnick $+ > %entry
write youtube.txt Title: %title Rating: %rating stars
}
:desc
if (%desc_re) {
echo @YouTube Description: %desc_re
write youtube.txt Description: %desc_re
}
else {
echo @YouTube Description: %desc_be
write youtube.txt Description: %desc_be
}
unset %entry
unset %ytpath
unset %ytnick
unset %ytchan
unset %title
unset %ytread
unset %desc_be
unset %desc_re
unset %rating
}
if ($sockbr) goto read
}
|
|
|
|
Joined: Apr 2006
Posts: 399
Fjord artisan
|
Fjord artisan
Joined: Apr 2006
Posts: 399 |
I haven't tried it yet, but, it seems like it would be nice, I also want to let you know that it would probably be much better if you combine your script with one I found that goes: !tube <keyword> and it gives you the most popular video link. I think it would be nice if you could do something like that instead of just getting a link.
|
|
|
|
iamdegenatron
|
iamdegenatron
|
Yes that's a good idea. It shouldn't be too hard, I'll get to it 
|
|
|
|
iamdegenatron
|
iamdegenatron
|
Here's a very crude version of the search feature you requested that can be added into your remotes. Personally I was just looking for a passive youtube url catcher instead of something that actively responds to requests. Anyhow, it is triggered by !youtube @youtube !tube or @tube. It is based off the script as seen in http://www.hawkee.com/snippet.php?snippet_id=2197syntax example : !youtube <search terms> This will return the most related video to your search terms. If you want the script to return the video with the highest view count (which may or may not be related to your search terms at all), then you can replace the following line sockwrite -nt $sockname GET /results?search_query= $+ %tube.search HTTP//1.1 with this line sockwrite -nt $sockname GET /results?search_query= $+ %tube.search $+ &search_sort=video_view_count HTTP//1.1
Anyways, here is the full code  on $*:TEXT:/^[!@](youtube|tube) */Si:#: {
%linenumber = 0
set %chan.tube $chan
set %tube.style /msg %chan.tube
set %tube.search $replace($2-,$chr(32),+)
if ($2 == $null) { %tube.style Search could not be completed | halt }
sockopen ytsearch www.youtube.com 80
}
on *:sockopen:ytsearch:{
sockwrite -nt $sockname GET /results?search_query= $+ %tube.search HTTP//1.1
; if you want to sort search by VIEW COUNT, use this instead of the line above
; sockwrite -nt $sockname GET /results?search_query= $+ %tube.search $+ &search_sort=video_view_count HTTP//1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:ytsearch:{
var %temp
sockread %temp
if (%searchres == 1) {
%searchtitle = $remove($regsubex(%temp,/<a [^>]+>(.+?)</a>/,\1),<br/>, )
set %tube.url $remove($gettok(%temp,2,32),href=",")
if (/watch?v= isin %tube.url) {
%tube.style %searchtitle $+ : http://www.youtube.com $+ %tube.url
unset %linenumber
unset %tube.search
unset %searchtitle
unset %chan.tube
unset %tube.style
unset %searchres
unset %tube.url
sockclose ytsearch
halt
}
}
if ( *start search results* iswm %temp) { set %searchres 0 }
if (*<a href="/watch?v=* iswm %temp) { inc %searchres }
inc %linenumber
}
Last edited by iamdegenatron; 17/02/07 06:28 AM.
|
|
|
|
Joined: Apr 2006
Posts: 399
Fjord artisan
|
Fjord artisan
Joined: Apr 2006
Posts: 399 |
yea, that's what I was looking for, I tried looking on Hawkee, but, i couldn't find it, nice job 
|
|
|
|
daTerminehtor
|
daTerminehtor
|
This looks to be very useful...
However, after pasting/saving a new remote... it isn't loading. The syntax doesn't even produce an error.
I'm sure then, it's on my end. :P
Idea's?
mirc 6.21
|
|
|
|
iamdegenatron
|
iamdegenatron
|
Hmm, yeah. I did say it was a crude version (Meaning I didn't test it for searches that have no search results... whoops. stupid me) try this instead: ; youtube video search
; returns the first search result for your search terms
;
; triggers: !youtube @youtube !tube @tube
; syntax: @youtube <search terms.
; example: !tube charleston daft punk
; if you want to sort search by VIEW COUNT, use this line below
; sockwrite -nt $sockname GET /results?search_query=
;
; if you want the regular search, use this line below
; sockwrite -nt $sockname GET /results?search_query= $+ %tube.search HTTP//1.1
;
; you'd put either one of those on line 32 of this script
; that line number may be different when this script is put into a bigger script
; so the place im referring to is: under the heading on *:sockopen:ytsearch:{
on $*:TEXT:/^[!@](youtube|tube) */Si:#: {
%linenumber = 0
set %chan.tube $chan
set %tube.style /msg %chan.tube
set %tube.search $replace($2-,$chr(32),+)
if ($2 == $null) { %tube.style Search could not be completed | halt }
sockopen ytsearch www.youtube.com 80
}
on *:sockopen:ytsearch:{
sockwrite -nt $sockname GET /results?search_query= $+ %tube.search HTTP//1.1
;
; if you want to sort search by VIEW COUNT, use this instead of the line above
; sockwrite -nt $sockname GET /results?search_query= $+ %tube.search $+ &search_sort=video_view_count HTTP//1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:ytsearch:{
var %temp
sockread %temp
if (%searchres == 1) {
%searchtitle = $remove($regsubex(%temp,/<a [^>]+>(.+?)</a>/,\1),<br/>, )
set %tube.url $remove($gettok(%temp,2,32),href=",")
if (/watch?v= isin %tube.url) {
%tube.style %searchtitle $+ : http://www.youtube.com $+ %tube.url
unset %linenumber
unset %tube.search
unset %searchtitle
unset %chan.tube
unset %tube.style
unset %searchres
unset %tube.url
sockclose ytsearch
halt
}
}
if ( *start search results* iswm %temp) { set %searchres 0 }
if (*<a href="/watch?v=* iswm %temp) { inc %searchres }
if (*No Videos found* iswm %temp) {
%tube.style No videos found for %tube.search
unset %linenumber
unset %tube.search
unset %searchtitle
unset %chan.tube
unset %tube.style
unset %searchres
unset %tube.url
sockclose ytsearch
halt
}
inc %linenumber
}
|
|
|
|
daTerminehtor
|
daTerminehtor
|
Sorry, nope. Not even an error, nothing.  Thanks for trying though.
|
|
|
|
iamdegenatron
|
iamdegenatron
|
I added an alias for your personal use so it triggers with /yt for you, and it triggers with !yt @yt !youtube @youtube !tube @tube for others I'm having trouble with retrieving descriptions of the video, so if you see anything unusual, let me know. ; youtube video search
; returns the first search result for your search terms
; usage for you
;
; trigger: /yt
; syntax: /yt <search terms>
; example: /yt charleston daft punk
; usage for other people
;
; triggers: !youtube @youtube !tube @tube
; syntax: @youtube <search terms>
; example: !tube charleston daft punk
; if you want to sort search by VIEW COUNT, use this line below
; sockwrite -nt $sockname GET /results?search_query=
;
; if you want the regular search, use this line below
; sockwrite -nt $sockname GET /results?search_query= $+ %tube.search HTTP//1.1
;
; the place im referring to is: under the heading on *:sockopen:ytsearch:{
alias yt {
%channel = $chan
if (%channel) { %saystyle = echo -t %channel }
else { %saystyle = echo -at }
%searchstring = $replace($1-,$chr(32),+)
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on $*:TEXT:/^[!@](yt|youtube|tube) */Si:#: {
%channel = $chan
%saystyle = /msg %channel
%searchstring = $replace($2-,$chr(32),+)
if ($2 == $null) { %saystyle Search could not be completed | halt }
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on *:sockopen:ytsearch:{
sockwrite -nt $sockname GET /results?search_query= $+ %searchstring HTTP//1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:ytsearch:{
; sockread -f %temp
; sockread -n %temp
sockread -n %temp
; replace all <br/> with a space
if (%founddesc_be) { unset %founddesc_be | %desc_be = $remove(%temp, ) }
if (<span id="BeginvidDesc isin %temp) %founddesc_be = k
if (/watch?v= isin %temp) { %resulturl = $remove($gettok(%temp,2,32),href=",") }
if (%foundtitle) { inc %titlecounter }
if (%titlecounter = 1) { %searchtitle = $remove($regsubex(%temp,/<a [^>]+>(.+?)</a>/,\1),<br/>, ) }
if (<div class="vtitle"> isin %temp) { %foundtitle = k | %titlecounter = 0 }
if (<img class="rating" src="/img/star_sm.gif" isin %temp) { %done = k }
; if (<span id="BeginvidDesc isin %temp) { %founddesc_re = k | %desccounter = 0 }
; if (%founddesc_re) { inc %desccounter }
; if (%%desccounter = 4) { %searchtitle = %desc_re = $remove(%temp, ) }
; %desc_re = $remove(%temp, )
if (%done) {
sockclose ytsearch
unset %done
; %saystyle .........................................
%saystyle Link: http://www.youtube.com $+ %resulturl
%saystyle Title: %searchtitle
%saystyle Description: %desc_be
; %saystyle desc_re: %desc_re
; %saystyle the result %searchtitle $+ : http://www.youtube.com $+ %resulturl
unset %searchstring
unset %channel
unset %saystyle
unset %searchres
unset %searchtitle
unset %resulturl
unset %desc_be
unset %titlecounter
unset %temp
unset %foundtitle
halt
}
if (*No Videos found* iswm %temp) {
sockclose ytsearch
%saystyle No videos found for %searchstring
unset %searchstring
unset %channel
unset %saystyle
unset %searchres
unset %searchtitle
unset %resulturl
unset %desc_be
unset %titlecounter
unset %temp
unset %foundtitle
halt
}
if (*start search results* iswm %temp) { %searchres = 0 }
if (*<a href="/watch?v=* iswm %temp) { inc %searchres }
}
|
|
|
|
daTerminehtor
|
daTerminehtor
|
Got it... and with the description... WELL DONE!
|
|
|
|
iamdegenatron
|
iamdegenatron
|
You may have noticed the search isnot working properly anymore. This is because Youtube recently underwent some changes. Of the the change that matters, they replaced the image they use for ratings. This image is a big signal for my script to stop and then to print search results. so now ive merely updated what the image is to now and it works the same way heres what you do to make it work: delete this line if (<img class="rating" src="/img/star_sm.gif" isin %temp) { %done = k } and put this one in its place: if (<img class="rating" src="/img/icn_star_full_19x20 isin %temp) { %done = k }
|
|
|
|
Joined: Oct 2004
Posts: 8,061
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,061 |
Lol. I hate when websites do that. I had to fix my weather script numerous times for that reason. Thankfully, I tend to catch it quickly and can get a new version out before people start complaining (and most of my released scripts have the ability to check for updates right from the script).
|
|
|
|
daTerminehtor
|
daTerminehtor
|
Replaced that line and still no-go.
|
|
|
|
iamdegenatron
|
iamdegenatron
|
not sure why its not working for you... but heres my code as of now:
; youtube video search
; returns the first search result for your search terms
; usage for you
;
; trigger: /yt
; syntax: /yt <search terms>
; example: /yt charleston daft punk
; usage for other people
;
; triggers: !youtube @youtube !tube @tube
; syntax: @youtube <search terms>
; example: !tube charleston daft punk
; if you want to sort search by VIEW COUNT, use this line below
; sockwrite -nt $sockname GET /results?search_sort=video_view_count&search_query= $+ %searchstring
;
; if you want the regular search, use this line below
; sockwrite -nt $sockname GET /results?search_query= $+ %searchstring HTTP//1.1
;
; the place im referring to is: under the heading on *:sockopen:ytsearch:{
alias yt {
%channel = $chan
if (%channel) { %saystyle = echo -t %channel }
else { %saystyle = echo -at }
%searchstring = $replace($1-,$chr(32),+)
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on $*:TEXT:/^[!@](yt|youtube|tube) */Si:#: {
%channel = $chan
%saystyle = /msg %channel
%searchstring = $replace($2-,$chr(32),+)
if ($2 == $null) { %saystyle Search could not be completed | halt }
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on *:sockopen:ytsearch:{
sockwrite -nt $sockname GET /results?search_query= $+ %searchstring HTTP//1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:ytsearch:{
sockread -n %temp
if (%founddesc_be) { unset %founddesc_be | %desc_be = $replace($remove(%temp, ),<br/>,$chr(32)) }
if (<span id="BeginvidDesc isin %temp) %founddesc_be = k
if (/watch?v= isin %temp) { %resulturl = $remove($gettok(%temp,2,32),href=",") }
if (%foundtitle) { inc %titlecounter }
if (%titlecounter = 1) { %searchtitle = $replace($remove($regsubex(%temp,/<a [^>]+>(.+?)</a>/,\1),<br/>, ),",$chr(34)) }
if (<div class="vtitle"> isin %temp) { %foundtitle = k | %titlecounter = 0 }
if (<img class="rating" src="/img/icn_star_full_19x20 isin %temp) { %done = k }
if (%done) {
sockclose ytsearch
unset %done
%saystyle Link: http://www.youtube.com $+ %resulturl
%saystyle Title: %searchtitle
%saystyle Description: %desc_be
unset %searchstring
unset %channel
unset %saystyle
unset %searchres
unset %searchtitle
unset %resulturl
unset %desc_be
unset %titlecounter
unset %temp
unset %foundtitle
halt
}
if (*No Videos found* iswm %temp) {
sockclose ytsearch
%saystyle No videos found for %searchstring
unset %searchstring
unset %channel
unset %saystyle
unset %searchres
unset %searchtitle
unset %resulturl
unset %desc_be
unset %titlecounter
unset %temp
unset %foundtitle
halt
}
if (*start search results* iswm %temp) { %searchres = 0 }
if (*<a href="/watch?v=* iswm %temp) { inc %searchres }
}
|
|
|
|
daTerminehtor
|
daTerminehtor
|
|
|
|
|
iamdegenatron
|
iamdegenatron
|
If you're interested in my other Youtube script, its at http://www.hawkee.com/snippet.php?snippet_id=2417It basically logs up any youtube video urls into a @window, making entries for each video by including its details from the youtube site. Details such as its given title, description, rating, number of ratings, number of comments, times favorited. These all make for a great way to sift through youtube videos and see which ones are decent enough to look at without actually opening up yout browser 
|
|
|
|
iamdegenatron
|
iamdegenatron
|
minor changes have been made in youtube's site, so here is an update
; youtube video search
; returns the first search result for your search terms
; usage for you
;
; trigger: /yt
; syntax: /yt <search terms>
; example: /yt charleston daft punk
; usage for other people
;
; triggers: !youtube @youtube !tube @tube
; syntax: @youtube <search terms>
; example: !tube charleston daft punk
; if you want to sort search by VIEW COUNT, use this line below
; sockwrite -nt $sockname GET /results?search_sort=video_view_count&search_query= $+ %searchstring
;
; if you want the regular search, use this line below
; sockwrite -nt $sockname GET /results?search_query= $+ %searchstring HTTP//1.1
;
; the place im referring to is: under the heading on *:sockopen:ytsearch:{
alias yt {
%channel = $chan
if (%channel) { %saystyle = echo -t %channel }
else { %saystyle = echo -at }
%searchstring = $replace($1-,$chr(32),+)
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on $*:TEXT:/^[!@](yt|youtube) */Si:#: {
%channel = $chan
%saystyle = /msg %channel
%searchstring = $replace($2-,$chr(32),+)
if ($2 == $null) { %saystyle Search could not be completed | halt }
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on *:sockopen:ytsearch:{
sockwrite -nt $sockname GET /results?search_query= $+ %searchstring HTTP//1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:ytsearch:{
sockread -n %temp
if (%founddesc_be) { unset %founddesc_be | %desc_be = $replace($remove(%temp, ),<br/>,$chr(32)) }
if (<span id="BeginvidDesc isin %temp) %founddesc_be = k
if (/watch?v= isin %temp) { %resulturl = $remove($gettok(%temp,2,32),href=",") }
if (%foundtitle) { inc %titlecounter }
if (%titlecounter = 1) { %searchtitle = $replace($remove($regsubex(%temp,/<a [^>]+>(.+?)</a>/,\1),<b>,</b>,<br/>, ),",$chr(34)) }
; if (<div class="vtitle"> isin %temp) { %foundtitle = k | %titlecounter = 0 }
if (<div class="vSnippetTitle"> isin %temp) { %foundtitle = k | %titlecounter = 0 }
if (<img class="rating" src="/img/icn_star_full_19x20 isin %temp) { %done = k }
if (%done) {
sockclose ytsearch
unset %done
%saystyle Link: http://www.youtube.com $+ %resulturl
%saystyle Title: %searchtitle
%saystyle Description: %desc_be
unset %searchstring
unset %channel
unset %saystyle
unset %searchres
unset %searchtitle
unset %resulturl
unset %desc_be
unset %titlecounter
unset %temp
unset %foundtitle
halt
}
if (*No Videos found* iswm %temp) {
sockclose ytsearch
%saystyle No videos found for %searchstring
unset %searchstring
unset %channel
unset %saystyle
unset %searchres
unset %searchtitle
unset %resulturl
unset %desc_be
unset %titlecounter
unset %temp
unset %foundtitle
halt
}
if (*start search results* iswm %temp) { %searchres = 0 }
if (*<a href="/watch?v=* iswm %temp) { inc %searchres }
}
|
|
|
|
iamdegenatron
|
iamdegenatron
|
they keep changing things on youtube! so here is another update ; youtube video search
; returns the first search result for your search terms
; usage for you
;
; trigger: /yt
; syntax: /yt <search terms>
; example: /yt charleston daft punk
; usage for other people
;
; triggers: !youtube @youtube !tube @tube
; syntax: @youtube <search terms>
; example: !tube charleston daft punk
; if you want to sort search by VIEW COUNT, use this line below
; sockwrite -nt $sockname GET /results?search_sort=video_view_count&search_query= $+ %yt.searchstring
;
; if you want the regular search, use this line below
; sockwrite -nt $sockname GET /results?search_query= $+ %yt.searchstring HTTP//1.1
;
; the place im referring to is: under the heading on *:sockopen:ytsearch:{
alias yt {
%yt.channel = $chan
if (%yt.channel) { %yt.saystyle = echo -t %yt.channel }
else { %yt.saystyle = echo -at }
%yt.searchstring = $replace($1-,$chr(32),+)
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on $*:TEXT:/^[!@](yt|youtube) */Si:#: {
%yt.channel = $chan
%yt.saystyle = /msg %yt.channel
%yt.searchstring = $replace($2-,$chr(32),+)
if ($2 == $null) { %yt.saystyle Search could not be completed | halt }
sockclose ytsearch
sockopen ytsearch www.youtube.com 80
}
on *:sockopen:ytsearch:{
sockwrite -nt $sockname GET /results?search_query= $+ %yt.searchstring HTTP//1.1
sockwrite -nt $sockname Host: youtube.com
sockwrite -nt $sockname $crlf $crlf
}
on *:sockread:ytsearch:{
sockread -n %yt.temp
if (%yt.founddesc_be) { unset %yt.founddesc_be | %yt.desc_be = $replace($replace($remove(%yt.temp,<b>,</b>, ),<br/>,$chr(32)),",$chr(34)) }
if (<span id="BeginvidDesc isin %yt.temp) %yt.founddesc_be = k
; if (/watch?v= isin %yt.temp) { %yt.resulturl = $remove($gettok(%yt.temp,2,32),href=",") }
if (*<a href="/watch?v=* iswm %yt.temp) { %yt.resulturl = $remove($gettok(%yt.temp,2,32),href=",") }
if (%yt.foundtitle) { inc %yt.titlecounter }
if (%yt.titlecounter = 1) { %yt.searchtitle = $replace($remove($regsubex(%yt.temp,/<a [^>]+>(.+?)</a>/,\1),<b>,</b>,<br/>, ),",$chr(34)) }
if (<div class="vSnippetTitle"> isin %yt.temp) { %yt.foundtitle = k | %yt.titlecounter = 0 }
if (<img class="rating" src="/img/icn_star_full_11x11 isin %yt.temp) { %yt.done = k }
if (%yt.done) {
sockclose ytsearch
unset %yt.done
%yt.saystyle Link: http://www.youtube.com $+ %yt.resulturl
%yt.saystyle Title: %yt.searchtitle
%yt.saystyle Description: %yt.desc_be
unset %yt.*
halt
}
if (*No Videos found* iswm %yt.temp) {
sockclose ytsearch
%yt.saystyle No videos found for %yt.searchstring
unset %yt.*
halt
}
if (*start search results* iswm %yt.temp) { %yt.searchres = 0 }
if (*<a href="/watch?v=* iswm %yt.temp) { inc %yt.searchres }
}
|
|
|
|
Joined: Dec 2002
Posts: 580
Fjord artisan
|
Fjord artisan
Joined: Dec 2002
Posts: 580 |
I'm sorry, why are you doing this? Can't we just search from the web page... 
|
|
|
|
|