mIRC Home    About    Download    Register    News    Help

Print Thread
!songrequest not working? #250327 09/01/15 12:21 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
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?

Re: !songrequest not working? [Re: Bramzee] #250328 09/01/15 12:26 PM
Joined: Jan 2004
Posts: 1,277
L
Loki12583 Offline
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,277

Re: !songrequest not working? [Re: Loki12583] #250337 09/01/15 09:31 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
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
  }
}

Last edited by Bramzee; 09/01/15 09:31 PM.
Re: !songrequest not working? [Re: Bramzee] #250338 09/01/15 09:51 PM
Joined: Jan 2015
Posts: 2
G
Grim3212 Offline
Bowl of petunias
Offline
Bowl of petunias
G
Joined: Jan 2015
Posts: 2
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. }
}

Re: !songrequest not working? [Re: Grim3212] #250341 09/01/15 11:29 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline OP
Vogon poet
OP Offline
Vogon poet
Joined: Apr 2014
Posts: 170
Thanks Grim. That worked smile

Re: !songrequest not working? [Re: Grim3212] #250352 10/01/15 03:23 PM
Joined: Nov 2014
Posts: 79
N
Newbie Offline
Babel fish
Offline
Babel fish
N
Joined: Nov 2014
Posts: 79
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.