Ejemplo n.º 1
0
def index(request, dates=None):
    if request.method == 'POST':
        data = request.POST
        
        location = data['location']
        artists = data['artists']
        
        artists = [artist.strip() for artist in artists.split(",")]
        
        if dates:
            dates = dates.split("/")
            start_date = dates[0]
            end_date = dates[1]
            events = itour.get_concerts(artists, location, start_date, end_date)
        else:
            events = itour.get_concerts(artists, location)
        
        concerts = []
        [concerts.append(event.json_data) for event in events]
        
        return HttpResponse(json.dumps(concerts), mimetype='application/json')
Ejemplo n.º 2
0
 def POST(self, dates):
     data = web.input()
     
     location = data.location
     artists = data.artists
     
     artists = [artist.strip() for artist in artists.split(",")]
     
     if dates:
         dates = dates.split("/")
         start_date = dates[0]
         end_date = dates[1]
         events = itour.get_concerts(artists, location, start_date, end_date)
     else:
         events = itour.get_concerts(artists, location)
     
     concerts = []
     [concerts.append(event.json_data) for event in events]
     
     web.header('Content-Type', 'application/json')
     return json.dumps(concerts)
Ejemplo n.º 3
0
def main():
    parser = OptionParser()
    parser.add_option("-a", "--artists", dest="artists", help="comma separated list of artists")
    parser.add_option("-f", "--file", dest="filename", help="read data from FILENAME")
    parser.add_option(
        "-t",
        "--test",
        action="store_true",
        dest="test_mode",
        help="Use test data set instead of parsing iTunes XML file",
    )
    (options, args) = parser.parse_args()
    if len(args) > 0:
        parser.error("incorrect number of arguments")

    if options.test_mode:
        artists = test.artists
    elif options.artists:
        artists = [artist.strip() for artist in options.artists.split(",")]
    elif options.filename:
        if os.path.exists(options.filename):
            artists = itour.get_artists(options.filename)
        else:
            error = "File: %s does not exist" % options.filename
            parser.error(error)
    else:
        parser.error("You must specify iTunes XML file (-f)")

    if artists:
        print "\n%d Artists\n" % len(artists)

        concerts = itour.get_concerts(artists)

        if concerts:
            print concerts
            print "\n\n %d Concerts" % len(concerts)
        else:
            print "::: NO CONCERTS :::"