mIRC Home    About    Download    Register    News    Help

Print Thread
Blending Youtube Title Search, with !SongRequest #247060 20/07/14 12:25 PM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
Posts: 65
Alright, so I recently added a !SongRequest to my Twitch Channel, and people seem to like it. But I would like to add it so I could have them know what song was added, and even have it written in the file.

So, if I do
!songrequest https://www.youtube.com/watch?v=uuwfgXD8qV8

The Bot would reply with

The Song Katy Perry - Part Of Me has been added to my playlist

or

The Song, Katy Perry - Part of me is already in my playlist.

Then in the file it would look like this

$nick: Katy Perry - Part of me: https://www.youtube.com/watch?v=uuwfgXD8qV8

Here is my first script

Code:

on *:TEXT:!songrequest *:#ifstudios: {
  if ($read(songrequest.txt,nw,https://www.youtube.com/watch?v= $+ $2)) { 
    msg # $nick --> That song is already on my list :)
  }
  elseif (youtube isin $2-) {
    msg # $nick --> Please request the letters and numbers after the "Watch?v=" so "!songrequest 0KSOMA3QBU0"
  }
  else {
    msg # $nick --> I have added your song to my list.
    write songrequest.txt $nick $+ : https://www.youtube.com/watch?v= $+ $2
  }
}



and here is the code that I am trying to blend into the script

Code:
alias -l sockopenmark { sockopen $1-3 | sockmark $1 $4- }
on $*:text:/(youtube\.com)\/.*v=([^&]+)|(youtu\.be)\/(.+)/Si:*: {
  sockopenmark $+(yt.,$calc($ticks + $rand(1,99)))  www.youtube.com 80 $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 ($regex(%v,/"name" content="(.+)"/)) { 
    tokenize 32 $sock($sockname).mark
    $2-4 $replace($regml(1),&,$chr(38),',$chr(39),',$chr(39),",$chr(34),",$chr(34),&,$chr(38)) $5-
    sockclose $sockname
  }
}



I do things with stuff that makes other things do stuff.
Re: Blending Youtube Title Search, with !SongRequest [Re: Exuviax] #247071 20/07/14 04:47 PM
Joined: Apr 2014
Posts: 191
B
blessing Offline
Vogon poet
Offline
Vogon poet
B
Joined: Apr 2014
Posts: 191
!songrequest <valid-youtube-url>

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),&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: Blending Youtube Title Search, with !SongRequest [Re: blessing] #247100 21/07/14 03:39 AM
Joined: Jul 2014
Posts: 48
A
AeonPsych Offline
Ameglian cow
Offline
Ameglian cow
A
Joined: Jul 2014
Posts: 48
tested that, and it works

Re: Blending Youtube Title Search, with !SongRequest [Re: AeonPsych] #247114 21/07/14 03:54 PM
Joined: Mar 2014
Posts: 65
E
Exuviax Offline OP
Babel fish
OP Offline
Babel fish
E
Joined: Mar 2014
Posts: 65
Thank you soo much!!!


I do things with stuff that makes other things do stuff.
Re: Blending Youtube Title Search, with !SongRequest [Re: Exuviax] #250658 25/01/15 02:36 PM
Joined: Nov 2014
Posts: 13
A
AcidzDesigns Offline
Pikka bird
Offline
Pikka bird
A
Joined: Nov 2014
Posts: 13
Dosent work, i want it aswell, but i dont know why it wont work

Re: Blending Youtube Title Search, with !SongRequest [Re: AcidzDesigns] #250669 26/01/15 07:45 PM
Joined: Apr 2014
Posts: 170
Bramzee Offline
Vogon poet
Offline
Vogon poet
Joined: Apr 2014
Posts: 170

Last edited by Bramzee; 26/01/15 07:46 PM.