Autor Tema: socket youtube  (Leído 604 veces)

0 Usuarios y 1 Visitante están viendo este tema.

Desconectado sac

  • Novato
  • *
  • Mensajes: 2
  • Karma: +0/-0
socket youtube
« en: Febrero 03, 2011, 08:52:33 am »
Despues de una larga busqueda por google me dado cuenta que los script de youtube para leer los links en un canal.. y mostrar el titulo,artista etc etc.. no funciona ninguno.. espero que si alguien tiene uno echo y que funcione lo comparta conmigo..  y si no que me indique una buena manera de hacerlo a mano :X..

Desconectado Glaxu

  • Novato
  • *
  • Mensajes: 14
  • Karma: +0/-0
Re: socket youtube
« Respuesta #1 en: Abril 02, 2011, 05:17:20 pm »
pues aqui tengo uno funciona a la perfeccion jeje aca te lo paso!

Citar
alias -l GetYoutube {
  var %MaxResults 3
  var %TitleColor $+($chr(3),$chr(2))
  var %TextColor $+($chr(2),$chr(3),04)
  var %LinkColor $+($chr(3),$chr(31))
  var %logo $+($chr(3),14,Y,$chr(3),04,outube) $chr(7)
  $1-2 %logo %TitleColor Searching Youtube........ 
  var %sockname $+(YoutubeAdvancedSearch,$network,$2,$ticks), %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,&hl=en) %MaxResults %TitleColor %TextColor %LinkColor %logo
}
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 on
On $*:Text:/^(\+|-|!|@)Youtube.*/Si:#: {
  var %action $regml(1)
  if (%action isin +-) && ($regex($nick($chan,$nick).pnick,/(!|~|&|@)/)) {
    if (%action == +) {
      if ($istok(%YoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is already running the Youtube script }
      else {
        .enable #Youtube
        Set %YoutubeChanList $addtok(%YoutubeChanList,$+($network,$chan),32)
        .msg $chan $nick has activated the Youtube script for $chan .
      }
    }
    else {
      if (!$istok(%YoutubeChanList,$+($network,$chan),32)) { .msg $chan $nick $chan is not running the Youtube script }
      else {
        Set %YoutubeChanList $remtok(%YoutubeChanList,$+($network,$chan),1,32)
        .msg $chan $nick has deactivated the Youtube script for $chan .
      }
    }
  }
  elseif (!$timer($+(Youtube,$network,$nick))) && ($istok(%YoutubeChanList,$+($network,$chan),32)) {
    .timer $+ $+(Youtube,$network,$nick) 1 6 noop
    var %method $iif(%action == !,.notice $nick,$iif($regex($nick($chan,$nick).pnick,/(!|~|&|@|%)/),.msg $chan,.notice $nick))
    GetYoutube %method $strip($2-)
  }
}
#Youtube end
On *:sockopen:YoutubeAdvancedSearch*: {
  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) | youtube.cleanup }
}
On *:sockread:YoutubeAdvancedSearch*: {
  if ($sockerr) { echo -st Socket Error $nopath($script) | youtube.cleanup }
  else {
    var %Youtube | sockread %Youtube
    if (No video results isin %Youtube) {
      $gettok($sock($sockname).mark,1-2,32) No results were found for your search!
      youtube.cleanup
    }
    elseif ($regex(%Youtube,/<h3><a href="\/watch\?v=([^"]*)" title="([^"]*)"/i)) {
      hadd -m $sockname id $regml(1)     
      hadd -m $sockname title $fix($regml(2))
    }
    elseif ($regex(%Youtube,/<a href="\/watch\?v=([^"]*)".*title="([^"]*)"/i)) {
      hadd -m $sockname id $regml(1)   
      hadd -m $sockname title $fix($regml(2))
    }
    elseif ($regex(%Youtube,/"video-long-title-([^"]*)".*title="([^"]*)"/i)) {
      hadd -m $sockname id $regml(1)   
      hadd -m $sockname title $fix($regml(2))
    }
    elseif ($regex(%Youtube,/<span class="username-prepend">.*<a href="\/user\/([^"]*)">/i)) hadd -m $sockname user $regml(1)
    elseif ($regex(%Youtube,/<span class="date-added">([^<]*)<\/span>/i)) hadd -m $sockname date $regml(1)
    elseif ($regex(%Youtube,/<span class="viewcount">([^<]*) views<\/span>/i)) {
      hinc $sockname count     
      var %s $sockname
      tokenize 32 $sock(%s).mark
      $1-2 $8- $+($5,Title:,$6) $hget(%s,title) $+($5,User:,$6) $hget(%s,user) $+($5,Added:,$6) $hget(%s,date) $+($5,Views:,$6) $regml(1) $+($7,http://www.youtube.com/watch?v=,$hget(%s,id))
      if ($hget(%s,count) >= $4) youtube.cleanup     
    }
  }
}
On *:sockclose:YoutubeAdvancedSearch*: youtube.cleanup
alias -l youtube.cleanup {
  if ($hget($sockname)) hfree $v1
  sockclose $sockname
  return
}
alias Youtube { GetYoutube echo -a $1- }
alias -l fix { return $regsubex($remove($replace($1-,&amp;,&,&quot;,"),amp;,<b>,</b>),/&#([0-9]{2});/gi,$chr(\t)) }

es eso lo que buscas?! ... bueno creo que si jeje .. bueno @youtube song/text .... o !youtube song/tex ... cualquiera de esas 2 formas sirve yaa xD

 

anything