All pastes #901815 Raw Edit

Stuff

public text v1 · immutable
·published 2008-02-12 23:15 UTC
rendered paste body
YOUTUBE SCRIPT IN sBot:

--- AT COMMANDS ---
  if (http://*youtube*/*watch* iswm %sbot.sock.cmd) {
    smsg %sbot.sock.target [YouTube]: Checking video " $+ $gettok($gettok(%sbot.sock.cmd,1,38),2,61) $+ ".
    set %yt.vid $gettok($gettok(%sbot.sock.cmd,1,38),2,61)
    sockopen youtube- $+ %sbot.sock.target $+ - $+ $rand(100,999) youtube.com 80
    halt
  }



--- AT BOTTOM ---
on *:sockopen:youtube-*:{ 
  sockwrite -n $sockname GET /watch?v= $+ %yt.vid HTTP/1.1 
  sockwrite -n $sockname Host: youtube.com $+ $str($crlf ,2) 
} 
on *:sockread:youtube-*:{ 
  sockread %yt
  if (%yt.s.title == on) { set %yt.s.title $gettok($gettok(%yt,2,60),2,62) | halt }
  if (%yt == <div id="vidTitle">) { set %yt.s.title on | halt }
  if (<span class="viewCount"> isin %yt) { set %yt.s.views $gettok($gettok(%yt,2,62),1,60) | halt }
  if (%yt.s.date == on) { set %yt.s.date $gettok($gettok(%yt,2,60),2,62) | halt }
  if (<span class="smallLabel">Added:</span> isin %yt) && (%yt.s.date == $null) { set %yt.s.date on | halt }
  if (var watchUsername isin %yt) { set %yt.s.user $gettok(%yt,2,39) | halt }
  if (%yt == HTTP/1.1 303 See Other) { smsg $gettok($sockname,2,45) [YouTube]: Video not found. | sockclose youtube | halt } 
  if (<!-- end baseDiv --> isin %yt) {
    smsg $gettok($sockname,2,45) [YouTube]: %yt.s.title -> User: %yt.s.user - Views: %yt.s.views - Added on: %yt.s.date
    sockclose youtube
    halt
  }
  halt
}