Example #1
0
def makeprogress():
    done = False
    while done==False:
        filenames = os.listdir(os.getcwd())
        if 'artists.db' in filenames:
            done=True #done w/ everything.
            global artists
            artists = datamgmt.load('artists.db')
        elif 'incompleteartists.db' in filenames:
            process_info()
        elif 'itunes.db' in filenames:
            get_lfm_info(datamgmt.load('itunes.db'))
        elif 'Library.xml' in filenames:
            pylistxml.parse_itunes('Library.xml')
        else:
            print 'You need to put an iTunes xml export in the same directory as lfmgather.py'
            print 'Directions:'
            print 'Within iTunes, click File -> Library -> Export Library...'
            print 'Browse to the directory where lfmgather.py is located and save as the default \'Library.xml\''
            print 'Then restart this application.'
            done = True
        if done == False:
            time.sleep(10)
Example #2
0
def process_info(fname='incompleteartists.db',v=False): #get playcount info for all artists, returns a new list of artists
    """Gets all playcount info for all artist objects. v=verbose"""
    global artists
    import random
    artists = datamgmt.load(fname)
    fname = 'artists.db'
    random.shuffle(artists)
    newartists =[]
    artist_count = len(artists)
    print 'Getting info for each track by %d artists. This could take a very long time (approximately 1 minute per hundred tracks).' % artist_count
    for i in range(artist_count):
        print '%d/%d' % (i,artist_count)
        try:
            processed_artist = process_artist(artists[i],v)
        except:
            try:
                processed_artist = process_artist(artists[i],v)
            except:
                print 'Errors processing',unicode(artists[i])
        newartists.append(processed_artist)
    artists = newartists
    print 'calculating ratios...'
    calculate_ratios()
    try:
        datamgmt.save(artists,fname)
        print 'saved successfully'
    except:
        try:
            NETWORK.disable_caching()
            datamgmt.save(artists,fname)
            print 'data saved successfully'
            NETWORK.enable_caching()
        except:
            global errors
            errors = newartists
            print 'Error during save. Artists stored as var: errors'