def check_presence(cinema_json, json_actor_dir):
    change = False
    cinema_file = open_json(cinema_json)
    attori_file = open_json_data(
        json_actor_dir
    )  #Occorre creare una funzione apposita per aprire il File. OPEN_JSOn non va bene!

    cinema_data = cinema_file.values()

    for z in attori_file.values():
        for w in z:
            #print(w['Name'])
            for y, (key, value) in enumerate(w['Filmography'].items()):
                for x in value:
                    for a in cinema_data:
                        for b in a:
                            if x['Id'] == b['Movie Id'] and x[
                                    'Present'] == False:
                                print(x['Title'])
                                x['Present'] = True
                                change = True

    if change == True:
        print('Updated')
        with open(json_actor_dir, 'w') as outfile:
            json.dump(attori_file, outfile, indent=4, ensure_ascii=False)
    else:
        print("Non ci sono cambiamenti")
        return
예제 #2
0
def show_all_people():
    form = ActorForm()
    if os.path.exists(json_actor_dir):
        check_presence(json_dir, json_actor_dir)
        actor_data_collection = open_json_data(json_actor_dir)
        actor_data = actor_data_collection.values()
    else:
        actor_data = {}
    return render_template('attori_amati.html', data=actor_data, form=form)
예제 #3
0
def new():
    form = ActorForm()
    if form.validate_on_submit():
        flash('Ricerca per {} effettuata'.format(form.actor_name.data))
        attori_amati(json_dir, json_actor_dir, form.actor_name.data)

        if os.path.exists(json_actor_dir):
            check_presence(json_dir, json_actor_dir)
            actor_data_collection = open_json_data(json_actor_dir)
            actor_data = actor_data_collection.values()
        else:
            actor_data = {}

    return render_template('attori_amati.html', title='Cerca', form=form, data=actor_data)