creating a music database with updates from discogs.

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

creating a music database with updates from discogs.

Post by thissideup »

hi!

so i just had the idea of creating a website where you could keep track of your music database, while having the opportunity to keep track of which records you potentially are missing out on.

i know, this may sound weird, but being a music whore who loves to collect whole discographies of the artists cherished, it may sometimes come in handy to have the ability to know which records are still to be get.

and this is how i figured it should work:
through itunes (im a mac user), theres the option to export your playlist to an xml file. with that, it should be possible to parse a script that extracts the info of what artists and records you have. these will then be written down into your mysql library.
then, it will contact the discogs database through the api-interface and compare the results with your own database.
the output should then be a list of artists, owned records and released, but not owned records.

i guess it goes without saying, but even though this sounds - imho - interesting, its imbued with a lot of work.
i may say that its been a while since i last programmed anything in php, and that even then, my skills were about mediocre. plus, my xml experiences are tending to go against zero. but hey, im in bed, trying to cure from a cold and have nothing else to do!

so, what do you think? sounds interesting/possible/insane/whatever? im open for any feedback. and maybe help.

alex.

p.s. i hope this isnt too off topic.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Re: creating a music database with updates from discogs.

Post by Benjamin »

I built one of these a few weeks ago, it's actually fairly simple. I can't get into details due to contracts but you should have no problem building this in a day or so.
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

first drawback.

Post by thissideup »

wow.

it seems that i wasnt programming php for a longer period than i expected. once i have figured out the basics again, i am probably faced with the first problem:
how am i able to upload an xml file though a form so that the site is extracting specific infos into my mysql database?

an example of what the itunes xml looks like is:

Code: Select all

<dict>
        <key>1364</key>
        <dict>
            <key>Track ID</key><integer>1364</integer>
            <key>Name</key><string>when we were younger & better</string>
            <key>Artist</key><string>65daysofstatic</string>
            <key>Album</key><string>the destruction of small ideals</string>
            <key>Grouping</key><string>alternative</string>
            <key>Genre</key><string>post rock</string>
            <key>Kind</key><string>MPEG audio file</string>
            <key>Size</key><integer>9953280</integer>
            <key>Total Time</key><integer>414354</integer>
            <key>Track Number</key><integer>1</integer>
            <key>Track Count</key><integer>12</integer>
            <key>Year</key><integer>2007</integer>
            <key>Date Modified</key><date>2009-01-28T10:39:19Z</date>
            <key>Date Added</key><date>2008-08-11T11:52:02Z</date>
            <key>Bit Rate</key><integer>190</integer>
            <key>Sample Rate</key><integer>44100</integer>
            <key>Comments</key><string>                            </string>
            <key>Play Count</key><integer>1</integer>
            <key>Play Date</key><integer>3311173824</integer>
            <key>Play Date UTC</key><date>2008-12-03T17:30:24Z</date>
            <key>Normalization</key><integer>1251</integer>
            <key>Artwork Count</key><integer>1</integer>
            <key>Sort Album</key><string>destruction of small ideals</string>
            <key>Persistent ID</key><string>0FCA212339EDB3E6</string>
            <key>Track Type</key><string>File</string>
            <key>Location</key><string>file://localhost/Users/alexanderherr/Music/iTunes/iTunes%20Music/65daysofstatic/the%20destruction%20of%20small%20ideals/01%20when%20we%20were%20younger%20&%20better.mp3</string>
            <key>File Folder Count</key><integer>4</integer>
            <key>Library Folder Count</key><integer>1</integer>
        </dict>
i pretty much just want the artist and album to be integrated seperately into a sql-table.
suggestions?

alex.

p.s. @ moderators: again, im sorry if you think that this thread is misplaced, if you think it should be moved, do so and let me know. and apologies for any inconviniences.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: creating a music database with updates from discogs.

Post by papa »

As a music whore myself it's sounds really cool. :)

There's a lot of useful xml functions in PHP, I guess you are working from that ?
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

Re: creating a music database with updates from discogs.

Post by thissideup »

papa wrote:As a music whore myself it's sounds really cool. :)

There's a lot of useful xml functions in PHP, I guess you are working from that ?
dunno. like i said, i was a mediocre programmer, and it seems like im doing now from scratch. :banghead:

im currently desperately trying to echo three arrays, which have been assigned through a while-loop with mysql-fetch. but it seems like only the third entry is written, and the first two arent assigned. im confused. i forgot how programming was all about thinking as stupid as possible. here's the code:

Code: Select all

 
while(list($itunes_id_temp,$itunes_artist_temp,$itunes_album_temp) = mysql_fetch_row($result))
{
    $itunes_id = array($count => $itunes_id_temp);
    $itunes_artist = array($count => $itunes_artist_temp);
    $itunes_album = array($count => $itunes_album_temp);
    $count++; 
}
its definitely a really stupid mistake.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: creating a music database with updates from discogs.

Post by papa »

Are you assigning $count before the loop ?

Check this out:
http://us2.php.net/manual/en/book.simplexml.php
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

Re: creating a music database with updates from discogs.

Post by thissideup »

i was. actually, im still certain the syntax is more or less right, but matters no more, since i know assigned the arrays before the while-loop globally and then just assigned them like: "$array[] = $variable" inside the loop. works like it always did.

man, this is like relearning riding a bicycle.

thanks for the link!
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

Re: creating a music database with updates from discogs.

Post by thissideup »

okay. so assigning php variables from an xml source seems to be quite easy.

but how do i upload a file, using it, and then - when its finished - deleting it? in other words, upload the file ony temporary and not saving it on the server? i remember that this was already giving me headaches from back in the past, when i was more into php.
User avatar
papa
Forum Regular
Posts: 958
Joined: Wed Aug 27, 2008 3:36 am
Location: Sweden/Sthlm

Re: creating a music database with updates from discogs.

Post by papa »

There's a couple of good tuts on google for uploading files using php. Then just read the file using the xml objects for example.

Here's file reference:
http://us2.php.net/manual/en/function.file.php
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

Re: creating a music database with updates from discogs.

Post by thissideup »

hm. this is weird. is it impossible to create a mysql-table through a php script while the name is a variable? meaning that, e.g., in that variable is the word "hi", and with

Code: Select all

CREATE TABLE $cya()
it wouldnt create the table "$cya", but the table "hi"? 'cause it didnt worked at the first try.
thissideup
Forum Newbie
Posts: 10
Joined: Thu Jan 29, 2009 5:24 am

Re: creating a music database with updates from discogs.

Post by thissideup »

okay okay.
so far so good. the fundamentals are running.
i now have the problem that discogs wants ""Accept-Encoding: gzip" header to be sent along with the GET request." tbh, im not exactly sure of how thats supposed to work, since api-created xml-files are usually obtained through a line like: "$feed_url = 'http://www.discogs.com/artist/Radiohead ... pi-key=KEY';" and i wouldnt know how to sent the gzip header along with that. all the while i already encrypted my main page using "<? ob_start("ob_gzhandler"); ?>".
however, since they want a GET request, maybe i should try to let a script insert that url into the address field, and read it out through "$GET[feed_url]". when its an encrypted forwarding site, not my usual index site, it will work eventually. will try it now.
suggestions?
Post Reply