This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.
For more information, see this announcement post . Click the X in the top right-corner of this box to dismiss this message.
Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
laikabaus
Voice
Posts: 3 Joined: Mon Aug 06, 2012 3:20 pm
Post
by laikabaus » Mon Aug 06, 2012 3:31 pm
Hi,
I've been looking for a script that would get the artist & song from Spotify URL when pasted to channel (
http://open.spotify.com/track/ ... ) and type them in text to channel by the Bot. So pretty much similar functionality that is present in Youtube script that gets the video information from Youtube URL pasted on channel. Thanks!
doggo
Halfop
Posts: 97 Joined: Tue Jan 05, 2010 7:53 am
Contact:
Post
by doggo » Tue Aug 07, 2012 7:52 pm
got an example of a url? i dont use spotify myself but ill have a look
doggo
Halfop
Posts: 97 Joined: Tue Jan 05, 2010 7:53 am
Contact:
Post
by doggo » Wed Aug 08, 2012 11:29 am
try this
Code: Select all
# spotify.tcl
# by doggo #omgwtfnzbs@EFNET
#############################
set logo "\002\00300,03 Spotify \017"
proc spotify:announce {nick uhost hand chan text} {
global logo
if {[channel get $chan spotify] != 1 } { return }
if {[regexp -nocase {http://open.spotify.com/track/([A-Za-z0-9]+)} $text match spotify]} {
set html [spotify:getdata "http://open.spotify.com/track/$spotify"]
regexp -nocase {<meta property="og:description" content="(.*?), a song by\s(.*?)\son Spotify." />} $html match title artist
if {![info exists title]} {
putlog "\[spotify\] unable to get title/artist info from: http://open.spotify.com/track/$spotify"
} else {
putlog "\[spotify\] fetching: http://open.spotify.com/track/$spotify"
puthelp "privmsg $chan :$logo $artist - $title"
}
}
}
proc spotify:getdata {data} {
::http::config -useragent "Mozilla/5.0 (X11; U; Linux i686; ru-RU; rv:1.8.1) Gecko/2006101023 Firefox/2.0"
set url [::http::geturl $data -timeout 5000]
set source_code [::http::data $url]
::http::cleanup $source_code
return $source_code
}
package require http
setudef flag spotify
bind pubm -|- "% *http://open.spotify.com/track/*" spotify:announce
putlog "spotify.tcl loaded!"
load the script on the bot, then from the partyline for the channels you want the script to work in
only tested on a few urls.. worked fine
enjoy
Last edited by
doggo on Thu Aug 09, 2012 6:31 pm, edited 1 time in total.
laikabaus
Voice
Posts: 3 Joined: Mon Aug 06, 2012 3:20 pm
Post
by laikabaus » Thu Aug 09, 2012 6:05 am
Hi,
Thank you very much... made my day. Works well!
caesar
Mint Rubber
Posts: 3778 Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory
Post
by caesar » Thu Aug 09, 2012 12:53 pm
What's the point of the regexp if you already match that url in the pubm bind?
Once the game is over, the king and the pawn go back in the same box.
doggo
Halfop
Posts: 97 Joined: Tue Jan 05, 2010 7:53 am
Contact:
Post
by doggo » Thu Aug 09, 2012 6:30 pm
my understanding was
Code: Select all
bind pubm -|- "% *http://open.spotify.com/track/*" spotify:announce
would only trigger the spotify:announce when it was needed.. and the regexp would pick out the part of the url i needed where as
Code: Select all
bind pubm -|- "% *" spotify:announce
would trigger for everything typed in the enabled channel ??