Ejemplo n.º 1
0
def getNewSongs(lfmID, loc):
    # jimmytheleaf
    # deuterium64
    # ELCatch22
    # dagdunnit
    #lfmID = 'dagdunnit'      # last FM id
    numArtists = 5            # number of top artists to track
    #numArtists = 100            # number of top artists to track
    #loc = 'sk:18842'            # boston
    min = '2010-10-20'          # sets date range for upcoming concerts
    max = '2011-10-20'          # sets date range for upcoming concerts
    
    # extract top artists from last.fm
    topArtists = getTopArtistsFromID(lfmID, numArtists)
    
    #print topArtists
    
    # pull upcoming concerts from songkick
    
    upConcerts = {}

    for band in topArtists:
        upConcerts.update(getConcertsByID(topArtists[band]['mbid'], loc, min, max))

    # todo: extract concert URLS here. 
    #print upConcerts
    upBands = []
    
    # compress upConcerts to a list of bands playing in Boston in the future
    for band in upConcerts:
        upBands.append(upConcerts[band]['mbid'])
    
    # deduplicate the list
    upBands = list(set(upBands))
    
    # cross-reference against all concerts in the songkick database
    
    bandSetlists = {}
    
    for band in upBands:
        bandSetlists[band] = []
        cids = getConcertsByID(band, None, '2009-10-20', '2010-10-20')
        for cid in cids.keys():
            songList = getSetLists(cid, cids[cid]['mbid'])
            if songList:
                bandSetlists[band].extend(songList)
    
    unplayed_tracks = getUnplayedTracks(bandSetlists)

    #print unplayed_tracks
    full_data = getFullData(unplayed_tracks)
    #print full_data

    # todo: take full_data and manipulate this around.
    # structure it so a table may be generated elegantly and iterated out. 

    return writeWebsite(full_data, upConcerts)    
Ejemplo n.º 2
0
    def POST(self):
        user = myUser


        if user.validates():

            lfmID = user['LFMID'].value
            loc = user['Location'].value
            numBands = 10
            
            logging.info("requesting response for LFM:%s loc:%s"%( str(lfmID), str(loc)))
            
            # extract list of top artists based on LFM ID. 
            logging.info("entering getTopArtists. numBands = %s" %(str(numBands)))
            topArtists = getTopArtistsFromID(lfmID, numBands)
            logging.info("exiting getTopArtists.")

            # create a ref table for MBID and band name:
            artistByID = {}
            
            for band in topArtists:
                artistByID[topArtists[band]['mbid']] = band
            
            # look for upcoming concerts in area based on top artists
            min = '2010-10-20'
            max = '2011-10-20'

            logging.info("entering getConcertsByID loop for local shows")
            upConcerts = {}
            for band in topArtists:
                upConcerts.update(getConcertsByID(topArtists[band]['mbid'], loc, min, max))
                logging.info("Looked up concerts for %s"%(band))
            logging.info("exiting getConcertsByID local loop")

            # pull out the list of bands
            upBands = []
            for band in upConcerts:
                upBands.append(upConcerts[band]['mbid'])
            # deduplicate list
            upBands = list(set(upBands))
            logging.info("list of bands prepared")

            # cross-reference against all concerts in the DB from past year.
            bandSetlists = {}
            for band in upBands:
                logging.info("getting past concerts for %s" % (band))
                bandSetlists[band] = []
                cids = getConcertsByID(band, None, '2009-10-20', '2010-10-20')
                for cid in cids.keys():
                    logging.info("searching setlist for %s" % (cid))
                    songList = getSetLists(cid, cids[cid]['mbid'])
                    if songList:
                        logging.info("setlist found for %s" %(band))
                        bandSetlists[band].extend(songList)
            
            unplayed_tracks = getUnplayedTracks(bandSetlists)
            full_data = getFullData(unplayed_tracks)

            pull_data = {}
            
            for items in full_data:
                if "preview_url" in items:
                    pull_data[items["7digital_id"]] = { 
                        'trackname':items['trackname'],
                        'preview_url':items['preview_url'],
                        'release_image':items['release_image'],
                        'artistname':items['artistname']
                        }
            
                
            
            #print full_data
            #f = open("pull_data.json", "w")
            #bandList = json.dump(pull_data, f, indent=4)
            #f.close()


            return render.response(upConcerts, pull_data)
Ejemplo n.º 3
0
    f = open("concertlist.json", "r")
    concerts = json.load(f)
    f.close()
    
    bands = []
    
    for band in concerts:
        bands.append(concerts[band]['mbid'])
    
    # deduplicate the list
    bands = list(set(bands))
    
    bandSetlists = {}
    
    for band in bands:
        bandSetlists[band] = []
        cids = getConcertsByID(band, None, '2009-10-20', '2010-10-20')
        for cid in cids.keys():
            songList = getSetLists(cid, cids[cid]['mbid'])
            if songList:
                bandSetlists[band].extend(songList)
    
    f = open('setlists3.json', 'w')
    json.dump(bandSetlists, f, indent=4)
    f.close()