| View previous topic :: View next topic |
| Author |
Message |
Gordon Voice
Joined: 04 Apr 2007 Posts: 34
|
Posted: Mon Mar 10, 2008 9:01 pm Post subject: Lastfm script not fully working |
|
|
Could someone look at this and eventually fix it? (Problem with 'top track')
| Quote: | (Gordon) !lastfm metallica
(b0t) [last.fm] metallica -> listeners: 839,286
(b0t) [last.fm] top track (last week): n/a
(b0t) [last.fm] top track (last six months): n/a |
| Code: | # last.fm check v1.0 by casn_
#
# checks last.fm for listeners and top track on a given
# artist name. since the listeners are higher on a serious and
# (kinda) famous musicians (on last.fm are mostly music entusiasts9
# are higher, you get a rating capability like imdb for movies.
#
# requirements:
# o lynx
#
#
# just config below and let's go ;<
#
# your trigger
set last(trig) "!lastfm"
# path to your lynx dump file
set last(dump) "/home/luser/eggdrop/lynx.dump"
# chan to use
set last(chan) "#a-lame-chan"
# actual last.fm url to use (don't touch it!)
set last(url) "http://www.last.fm/music/"
# output line start
set last(lay) "\002\[\002last\002.\002fm\002\]\002 "
#########################################################################
bind pub - $last(trig) last_get
set last(debug) 0
proc last_get {nick host hand chan arg} {
global last
putlog "last.fm script triggered"
if {$chan != $last(chan)} {return}
if {[string length $arg] < 1} {
puthelp "PRIVMSG $chan :usage: !lastfm <artist>"
}
set state 0
if {$last(debug) == 1} {putlog "state == 0"}
set listeners "n/a"
set top_week "n/a"
set top_six "n/a"
set suburl [string map {" " "%20"} $arg]
exec lynx --dump $last(url)$suburl > $last(dump)
set fp [open $last(dump) r]
while {![eof $fp]} {
gets $fp line
if {[string match *listeners* $line]} {
set listeners [lindex $line 0]
}
if {$state == 1 && [lindex $line 0] == "1"} {
regexp -indices {(?i)\]} $line location
set top_week [string range $line [expr [lindex $location 0] + 1] end]
set state 2
if {$last(debug) == 1} {putlog "state == 2"}
}
if {[string match "*Top Tracks (last week)*" $line] && $state == 0} {
set state 1
if {$last(debug) == 1} {putlog "state == 1"}
}
if {$state == 3 && [lindex $line 0] == "1"} {
regexp -indices {(?i)\]} $line location
set top_six [string range $line [expr [lindex $location 0] + 1] end]
set state 4
if {$last(debug) == 1} {putlog "state == 4"}
}
if {[string match "*Top Tracks (last six months)*" $line] && $state == 2} {
set state 3
if {$last(debug) == 1} {putlog "state == 3"}
}
}
close $fp
if {$listeners == "n/a"} {
puthelp "PRIVMSG $chan :$last(lay)[string tolower $arg] \002->\002 \0034not found\003\002.\002"
return
}
puthelp "PRIVMSG $chan :$last(lay)[string tolower $arg] \002->\002 listeners: $listeners"
puthelp "PRIVMSG $chan :$last(lay)top track \002(\002last week\002):\002 [string tolower $top_week]"
puthelp "PRIVMSG $chan :$last(lay)top track \002(\002last six months\002):\002 [string tolower $top_six]"
}
putlog "last.fm check by casn_ started." |
Last edited by Gordon on Tue Mar 11, 2008 8:48 am; edited 1 time in total |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Tue Mar 11, 2008 4:35 am Post subject: |
|
|
| Easier to re-write it (and use package http, instead of the external lynx binary) and proper regexp's. I'll put it on my todo list. If I get a spurt of ambition I might write it by the weekend. |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Tue Mar 11, 2008 10:58 am Post subject: |
|
|
| I do not know why people do not look in the archive, this script is VERY easy to find (and it includes author contact information). |
|
| Back to top |
|
 |
MellowB Voice
Joined: 23 Jan 2008 Posts: 24 Location: Germany
|
Posted: Wed Mar 12, 2008 6:46 am Post subject: |
|
|
| DragnLord wrote: | | I do not know why people do not look in the archive, this script is VERY easy to find (and it includes author contact information). |
But thats a completely different script. _________________ On the keyboard of life, always keep one finger on the ESC key. |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Wed Mar 12, 2008 9:39 am Post subject: |
|
|
| MellowB wrote: | | DragnLord wrote: | | I do not know why people do not look in the archive, this script is VERY easy to find (and it includes author contact information). |
But thats a completely different script. |
... and when someone rewrites the script you posted, you think it will still be the same script?
If the one you have does not work, try another. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Mar 12, 2008 7:19 pm Post subject: |
|
|
http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=1375 is a nicely written script, but it's for looking up users, not artists.. It also no longer works, afaict, because the url within the script is no longer valid.
I only found 1 other lastfm script for "Somafm" in the egghelp archives, so yeah I guess I'll throw this little script together, it's simple and seems somewhat useful. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
|
| Back to top |
|
 |
Gordon Voice
Joined: 04 Apr 2007 Posts: 34
|
Posted: Thu Mar 13, 2008 9:35 am Post subject: |
|
|
Very nice.
Good work! |
|
| Back to top |
|
 |
MellowB Voice
Joined: 23 Jan 2008 Posts: 24 Location: Germany
|
Posted: Sun Mar 16, 2008 5:03 pm Post subject: |
|
|
| DragnLord wrote: |
... and when someone rewrites the script you posted, you think it will still be the same script?
If the one you have does not work, try another. |
You are not making much sense there, sorry.
| rosc2112 wrote: | | http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=1375 is a nicely written script, but it's for looking up users, not artists.. It also no longer works, afaict, because the url within the script is no longer valid. |
I posted a working and updated version of that last.fm script here in the forums, just a few topics down. _________________ On the keyboard of life, always keep one finger on the ESC key. |
|
| Back to top |
|
 |
|