View Single Post
Old Jan 26th, 2006, 10:44 PM   #12
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Location: Waterloo, Ontario
Posts: 1,886
Rep Power: 5 Sane will become famous soon enough
Send a message via MSN to Sane
I'd have to say I've had a great deal of success thanks to your guidance andros! Thank-you!

I've got it so it can extract and save the loading art as a png, as well as extract some usefull attributes from the song.

import Image

def load_ojn(sid):
    dat = open("Music/o2ma%s.ojn"%sid,"rb").read()

    def get(i):
        r = ''
        while ord(dat[i]) > 0:
            r += dat[i]
            i += 1
        return r

    # INFO
    song = get(108)
    comp = get(172)
    manu = get(204)
    #confirm with , sid  = get(236).split('.')[0][4:]

    # RATINGS
    easy = str(ord(dat[20]))
    norm = str(ord(dat[22]))
    hard = str(ord(dat[24]))

    # THUMB
    ascii = ''.join(map(chr, [255, 216, 255, 224]))
    if "BM6K" in dat:
        thumb = "BM6K"+dat.split("BM6K")[-1]
        ext = 'bmp'
    elif "BM8K" in dat:
        thumb = "BM8K"+dat.split("BM8K")[-1]
        ext = 'bmp'
    elif ascii in dat:
        thumb = ascii+dat.split(ascii)[-1]
        ext = 'jpg'

    file = open("thumbs/temp.%s"%ext, "wb")
    file.write(thumb)
    file.close()

    im = Image.open("thumbs/temp.%s"%ext)

    name = ''.join(['',x][(ord(x)>64 and ord(x)<91) or (ord(x)>47 and ord(x)<58)] for x in song.upper())
    im.save("thumbs/%s.png"%name, "PNG")

    # return [sid, song, comp, manu, easy, norm, hard]

At least it was able to do this to the site for me: http://jammersbase.ath.cx/notices

=)

Now all that's left is to extract the notes.
Sane is offline   Reply With Quote