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.

Parse metal-archives

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Parse metal-archives

Post by kathorga »

Does anyone has/or can make script reading from metal-archives.com?
I can post old script if anyone interested, they changed their page couple months ago and old one doesn't work anymore
i
iRoc

Post by iRoc »

post old version
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

Code: Select all

#nd script                                                 #
# Let your users search for artist and reply with genre and origin  #
# Gets the data from metal-archives.com                             #
# Requirements: wget, iconv                                         #
# Date: 2008-08-12                                                  #
#####################################################################
 
bind pub - !band pub:band
 
proc pub:band {nick uhost hand chan arg} {
 
if {$arg == ""} {
  putserv "PRIVMSG $chan :Usage : !band <name> | metal-archives.com"
  return
}
 
#Take out the first letter
set letter [string range $arg 0 0]
set letter [string toupper $letter]
 
if {[string is digit $letter]} {
  set letter "n"
}
 
 
#Get list of bands starting with that letter
if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/browseL.php?l=$letter} result]} {
 
  putserv "PRIVMSG $chan :Error. couldn't reach metal-archives.com"
  return
}
 
regsub -all -nocase {<br>} $result "\n" result2
set numberofartists 0
 
#Try to find the requested band
foreach line [split $result2 \n] {
    if {[string match -nocase *\>$arg\<* $line]} {
      set singleband $line
      set numberofartists 1
    } elseif {[string match -nocase *\>$arg\ \(*\<* $line]} {
        regexp -nocase {<a(.*)>(.*)</a>} $line - donotcare line
        lappend list $line
        incr numberofartists
    }
} 
 
if {$numberofartists == 0} {
  putserv "PRIVMSG $chan :Couldn't find that band"
} elseif {$numberofartists > 1} {
  putserv "PRIVMSG $chan :There are several bands with that name. Type origin too."
  set index 0
    while {$index < $numberofartists} {
      putserv "PRIVMSG $chan :[lindex $list $index]"
      incr index
    }
} elseif {$numberofartists == 1} { #Exactly one hit
    regexp -nocase {<a href='(.*)'} $singleband - bandurl
    if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/$bandurl} result]} {
 
        putserv "PRIVMSG $chan :Error. couldn't reach metal-archives.com"
        return
}
    set list ""
    regsub -all -nocase {<br>} $result "\n" result2
    #Parse and extract the info we want
    foreach line [split $result2 \n] {
        if {[string match -nocase *</td* $line]} {
          regsub -all {<([^<])*>} $line {} line
          set line [string trim $line]
          if {[string match (*) $line]} {
             regexp -nocase {\((.*)\)} $line - town
             set country "$country, $town"
             set list [lreplace $list end end]
             lappend list $country
          } else {
              if {[string match "" $line] != 1} {
               lappend list $line
              }
          }
      } elseif {[string match -nocase *browseC* $line]} {
          regsub -all {<([^<])*>} $line {} line
          set country [string trim $line]
          lappend list $country
      }
    } 
 
    set endofinfo [lsearch $list Status*]
    putserv "PRIVMSG $chan :\002[lindex $list 0]"
    putserv "PRIVMSG $chan :[lindex $list 1]: [lindex $list 2]"
    if {[string match -nocase *lyric* [lindex $list 3]]} {
      putserv "PRIVMSG $chan :[lindex $list 3]: [lindex $list 4]"
      set index 5
    } else { #There's no info about lyrics. Skip it
      set index 3
    }
    while {$index <= $endofinfo} {
      putserv "PRIVMSG $chan :[lindex $list $index]: [lindex $list [expr $index+4]]"
      incr index
    }
 
    #Find number of studio albums
    set albums 0
    foreach line [split $result2 \n] {
        if {[string match -nocase *full-length* $line]} {
          incr albums
        }
    }
    if {$albums > 0} {
        putserv "PRIVMSG $chan :Albums: $albums"
    }
 
    putserv "PRIVMSG $chan :URL: http://metal-archives.com/$bandurl"
}
 
}
 
putlog "Metal band script v1.0 loaded"
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

Any luck iRoc?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/browseL.php?l=$letter} result]} { 

Code: Select all

if {[catch {exec wget -q -T 60 -t 1 -O - http://metal-archives.com/$bandurl} result]} { 
lollerskates :lol:

two words. http package.
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

not really working, i have done it before i posted first post
G
Gordon
Voice
Posts: 35
Joined: Wed Apr 04, 2007 11:45 am

Post by Gordon »

can anyone look at it again?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

# Metal v1.0 2013-04-07

# metal-archives.com script
# (cl)2013 speechles
#
# TO ENABLE IN YOUR CHANNEL:
# .chanset #yourchan +metal
#
# TO SEARCH:
# ( use -search )
# !metal *band -search
# !metal -search *band*
# !metal band* -search
# !metal -search band
#
# TO DISPLAY RESULTS:
# ( don't use -search )
# !metal *band
# !metal *band*
# !metal band*
# !metal band
#
# speechles was here :P

package require http
setudef flag metal

namespace eval metal {
   variable metal
   # ---> start config

   # trigger character
   set metal(pref) "!"

   # command used to reply to user
   # this can be a list of space delimited commands
   set metal(commands) "metal m"

   # amount user can issue before throttle
   set metal(throttle) 2

   # throttle time
   set metal(throttle_time) 30

   # how many max results to display in search
   set metal(amount) 3

   # how many max albums to show in results pages
   set metal(albums) 3

   # url to metal page
   set metal(page) http://www.metal-archives.com/search/ajax-band-search/?field=name&query=

   # display line for many results
   set metal(many) "\002%total\002 bands (showing first %amount)"

   # display line for a few results
   set metal(few) "\002%total\002 bands"

   # display line for search
   set metal(search) "\002%name\002 - %genre (%location) @ %url"
   
   # display for no results found in search
   set metal(no_results) "Sorry %nick, there are no results for %search."

   # display character for splitting things
   set metal(split) " | "

   # script version
   set metal(version) "1.0"

   # In the future, maybe more of the display will be customizable
   # through the config, until then... dance like an robot ;)

   # <--- config ends
}
from irc wrote:<speechles> !metal zoebea*
<bot> Zoebeast | Country of origin: Russia, Location: Saint Petersburg, Status: Active, Formed in: 2001, Genre: Death Metal/Grindcore, Lyrical themes: N/A, Current label: Coyote Records, Years active: 2001-present
<bot> Zoebeast | Members: ZDRCSD: Bass, Vocals; Professor: Drums; Enot: Guitars; Gorgonus: Guitars; Torden: Bass; Nik: Drums; Metallist: Drums; Kreator: Guitars (lead); Black Messiah: Guitars (lead); Dr. Death: Guitars (rhythm); Zaika: Vocals
<bot> Zoebeast | Albums: Incarnated Dreams; Full of Life; Unexpected Youth Pathology (...and 3 more)
<bot> Zoebeast | http://www.metal-archives.com/bands/Zoebeast/47781

<speechles> !metal zoebea* -search
<bot> 1 bands | Zoebeast - Death Metal/Grindcore (Russia) @ http://www.metal-archives.com/bands/Zoebeast/47781

<speechles> !metal zoebea*
<bot> 500 Ok ( http://www.metal-archives.com/search/aj ... =zoebea%2a )

<speechles> !metal zoebea* -search
<bot> speechles, you have been Throttled! You're going too fast and making my head spin!
Here's a replacement for that script. That one was clumsy, using exec and wget??!!. It isn't exactly portable that way, user friendly, nor is it economical. This one is platform independent. It also mixes ajax calls with html calls to be more efficient.

I wasn't sure what exactly that other script output from the site. Never having seen what it did. This is my feeling of what should be output. If you need something more, let me know. :)

metal.tcl v1.0
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

Hmm It was announcing albums name something like:
<bot> band name | album name (year)
<bot> band name | album2 name (year)
etc
line by line
Would be you do it too? Your(i mean albums name) is listed in one line.
Rest is awesome. Thanks for reply :)

Also would be great to lookup any band if search result to f. ex. 10 same bands name.
G
Gordon
Voice
Posts: 35
Joined: Wed Apr 04, 2007 11:45 am

Post by Gordon »

# In the future, maybe more of the display will be customizable
# through the config, until then... dance like an robot ;)
Id like to be able to set what bot should display, for example when i only want to see URL part..

Great job speechles.
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

Hey
I get weird error on some other bot:
<me>!metal iron maiden
<bot> Illegal characters in url path ( http://www.metal-archives.com/bands/Iron_Maiden/25\ )

On other bot it works fine, on this it adds "\". Normally should output http://www.metal-archives.com/bands/Iron_Maiden/25
d
disorder
Voice
Posts: 1
Joined: Sun Jun 16, 2013 9:27 pm

metal.tcl

Post by disorder »

i got the same error, can this be fixed?
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

I tested it on some linux distros, but only works on debian. All rest shows info like:
<@Bot> Illegal characters in url path ( http://www.metal-archives.com/bands/Iron_Maiden/25\ )

Speechles can you try fix it?
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Speechles can you try fix it?
I can't replicate that error. It works for me.
<speechles> !metal iron maiden
Iron Maiden | Country of origin: United Kingdom; Location: London, England; Status: Active; Formed in: 1975; Genre: Heavy Metal/NWOBHM; Lyrical themes: History, Literature, War, Mythology, Space; Current label: EMI Records; Years active: 1975-present
Iron Maiden | Members: Steve Harris: Bass, Keyboards (1975-present); Dave Murray: Guitars (1976-1977, 1977-present); Adrian Smith: Guitars (1980-1990, 1999-present); Bruce Dickinson: Vocals (1981-1993, 1999-present); Nicko McBrain: Drums (1982-present); Janick Gers: Guitars (1990-present); Ron "Rebel" Matthews: Drums (1975-1977); Dave Sullivan: Guitars (1975-1976); Terry Rance: Guitars (1975-1976); Paul Mario
Iron Maiden | Albums: The Soundhouse Tapes; Running Free; Iron Maiden (...and 107 more)
Iron Maiden | http://www.metal-archives.com/bands/Iron_Maiden/25
http://ereader.kiczek.com/metal.tcl

If this _still_ isn't working. Please paste the "detail" line given to you when you sourced the script. Check your partyline for this line. If you just started the bot, get on partyline and .rehash and look for this line.

Code: Select all

Metal announcer.tcl v1.0 :: Http: 2.5.3;BotIsPatched: 0;EncodingSystem: iso8859-1;Tcl: 8.4;Eggdrop: 1.6.17;Suzi: NO
What does yours say?
k
kathorga
Voice
Posts: 14
Joined: Mon Sep 05, 2011 11:53 am

Post by kathorga »

If this _still_ isn't working. Please paste the "detail" line given to you when you sourced the script. Check your partyline for this line. If you just started the bot, get on partyline and .rehash and look for this line.
I did .rehash and i got this:

Code: Select all

metal announcer.tcl v1.0 loaded.
I even installed same version of eggdrop (running eggdrop v1.6.17+SSL). Changed http.tcl to 2.7.5. Also same error.
Post Reply