mIRC Homepage

!songrequest not working?

Posted By: Bramzee

!songrequest not working? - 09/01/15 12:21 PM

So, this used to work. Now, not so much...


Code:
on *:TEXT:!songrequest &:#ifstudios:{
  noop $regex($2,/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si)
  if $read(songrequest.txt,nw,$+(*,$2)) { 
    msg # The Song $gettok($v1,2-,32) is already on my list :)
  }
  elseif !$regml(2) {
    msg # $nick --> You typed invalid youtube url.
  }
  else {
    youtube $2 $chan $nick
  }
}

alias -l sockopenmark { sockopen $1-3 | sockmark $1 $4- }
alias -l youtube {
  noop $regex($1,/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si)
  sockopenmark $+(yt.,$calc($ticks + $rand(1,99))) www.youtube.com 80 $regml(2) msg $2- 
}
on *:sockopen:yt.*:{
  tokenize 32 $sock($sockname).mark
  sockwrite -n $sockname GET /watch?v= $+ $1 HTTP/1.0 
  sockwrite -n $sockname HOST: www.youtube.com $+ $str($crlf,2)
}
on *:sockread:yt.*:{
  tokenize 32 $sock($sockname).mark
  var %v | sockread %v
  if ($regex(%v,/"name" content="(.+)"/)) { 
    var %song $replace($regml(1),&,$chr(38),',$chr(39),',$chr(39),",$chr(34),",$chr(34),&,$chr(38)) $5-
    $2-3 The Song %song has been added to my playlist 
    write songrequest.txt $4 $+ : %song $+ : https://www.youtube.com/watch?v= $+ $1
    sockclose $sockname
  }
  elseif *</html> iswm %v { $2-3 The Song ( https://www.youtube.com/watch?v= $+ $1 ) is not exists. }
}





For example...



Me:!songrequest www.youtube.com/watch?v=XbGs_qK2PQA
(nothing returned. At all.)

----

Me:!songrequest watch?v=XbGs_qK2PQA
Bot: username --> You typed an invalid youtube url




Any clues as to why it's not working correctly?
Posted By: Loki12583

Re: !songrequest not working? - 09/01/15 12:26 PM

http://forums.mirc.com/ubbthreads.php/topics/250302/Re:_YoutubeTitle_+_sock_script#Post250302
Posted By: Bramzee

Re: !songrequest not working? - 09/01/15 09:31 PM

still nothing. Here's what I have:

Code:
on *:TEXT:!req &:#:{
  noop $regex($2,/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si)
  if $read(songrequest.txt,nw,$+(*,$2)) { 
    msg # The Song $gettok($v1,2-,32) is already on my list :)
  }
  elseif !$regml(2) {
    msg # $nick --> You typed invalid youtube url.
  }
  else {
    youtube $2 $chan $nick
  }
}

alias -l sockopenmark { sockopen $1-3 | sockmark $1 $4- }
alias -l youtube {
  noop $regex($1,/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si)
  sockopenmark $+(yt.,$ticks,$rand(1,99)) www.youtube.com 443 $regml(2) msg $iif($chan,$v1,$nick))
}
on *:sockopen:yt.*:{
  tokenize 32 $sock($sockname).mark
  sockwrite -n $sockname GET /watch?v= $+ $1 HTTP/1.0 
  sockwrite -n $sockname HOST: www.youtube.com $+ $str($crlf,2)
}
on *:sockread:yt.*:{
  var %v  |  sockread %v
  if (%v) echo -ag %v
  if ($regex(%v,/"name" content="(.+)"/)) { 
    tokenize 32 $sock($sockname).mark
    $2-4 $replace($regml(1),&amp;amp;,$chr(38),&amp;#39;,$chr(39),&#39;,$chr(39),&amp;quot;,$chr(34),&quot;,$chr(34),&amp;,$chr(38)) $5-
    sockclose $sockname
  }
}
Posted By: Grim3212

Re: !songrequest not working? - 09/01/15 09:51 PM

Here this seems to work for me.

Code:
on *:TEXT:!req &:#:{
  echo Trying stuff!
  noop $regex($2,/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si)
  if $read(songrequest.txt,nw,$+(*,$2)) { 
    msg # The Song $gettok($v1,2-,32) is already on my list :)
  }
  elseif !$regml(2) {
    msg # $nick --> You typed invalid youtube url.
  }
  else {
    youtube $2 $chan $nick
  }
}

alias -l sockopenmark { sockopen -e $1-3 | sockmark $1 $4- }
alias -l youtube {
  noop $regex($1,/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si)
  sockopenmark $+(yt.,$calc($ticks + $rand(1,99))) www.youtube.com 443 $regml(2) msg $2- 
}
on *:sockopen:yt.*:{
  tokenize 32 $sock($sockname).mark
  sockwrite -n $sockname GET /watch?v= $+ $1 HTTP/1.0 
  sockwrite -n $sockname HOST: www.youtube.com $+ $str($crlf,2)
}
on *:sockread:yt.*:{
  tokenize 32 $sock($sockname).mark
  var %v | sockread %v
  if ($regex(%v,/"name" content="(.+)"/)) { 
    var %song $replace($regml(1),&amp;amp;,$chr(38),&amp;#39;,$chr(39),&#39;,$chr(39),&amp;quot;,$chr(34),&quot;,$chr(34),&amp;,$chr(38)) $5-
    $2-3 The Song %song has been added to my playlist 
    write songrequest.txt $4 $+ : %song $+ : https://www.youtube.com/watch?v= $+ $1
    sockclose $sockname
  }
  elseif *</html> iswm %v { $2-3 The Song ( https://www.youtube.com/watch?v= $+ $1 ) is not exists. }
}
Posted By: Bramzee

Re: !songrequest not working? - 09/01/15 11:29 PM

Thanks Grim. That worked smile
Posted By: Newbie

Re: !songrequest not working? - 10/01/15 03:23 PM

I hate to be that guy, but I guess I'll have to be. But is there any way to make it play the video within the script itself or do I need an outside program?

I was thinking, since you already have the web address can you used a $read to read the url on the text file and the open it up with /url? I know it has some issues like timing, but can you use the length of the video as a timer between it opening the first video and second video?

I wish I could say I understood half of what you typed but unfortunately I'm just a novice at this.
© 2020 mIRC Discussion Forums