|
|
|
|
@ -185,6 +185,7 @@ def query_movie_json():
|
|
|
|
|
def create_mapping(): |
|
|
|
|
movie_id = request.args.get('movie_id') |
|
|
|
|
rel_path = request.args.get('rel_path') |
|
|
|
|
message = '' |
|
|
|
|
errors = [] |
|
|
|
|
|
|
|
|
|
if not movie_id or not rel_path: |
|
|
|
|
@ -192,26 +193,23 @@ def create_mapping():
|
|
|
|
|
else: |
|
|
|
|
conn = db.get_db() |
|
|
|
|
cur = conn.cursor() |
|
|
|
|
current_app.logger.debug(f'{util.getFunctionName()}, mapping path "{rel_path}" for id: {movie_id}') |
|
|
|
|
try: |
|
|
|
|
cur.execute('INSERT INTO movie_paths(movie_id, movie_path) VALUES(?, ?)', |
|
|
|
|
(movie_id, rel_path)) |
|
|
|
|
except DatabaseError as e: |
|
|
|
|
errors.append(e) |
|
|
|
|
errors.append(str(e)) |
|
|
|
|
|
|
|
|
|
if len(errors) == 0: |
|
|
|
|
conn.commit() |
|
|
|
|
message = f'Successfully added mapping for path "{rel_path}"' |
|
|
|
|
|
|
|
|
|
if errors: |
|
|
|
|
for e in errors: |
|
|
|
|
current_app.logger.error(e) |
|
|
|
|
flash(errors) |
|
|
|
|
|
|
|
|
|
return render_template('tmdb/create_mapping.html', |
|
|
|
|
movie_id = movie_id, |
|
|
|
|
rel_path = rel_path, |
|
|
|
|
debug_str = util.dumpObject({'movie_id': movie_id, 'rel_path': rel_path}), |
|
|
|
|
success = (len(errors) == 0) |
|
|
|
|
) |
|
|
|
|
return jsonify({'errors':errors, 'message':message}) |
|
|
|
|
# TODO: query_movie() will no longer need rel_path argument |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
################### |
|
|
|
|
|