|
|
|
@ -512,21 +512,23 @@ def storeTMDBQueryResults(query_obj, result_list): |
|
|
|
id_column = getIDColumn(r.media_type) |
|
|
|
id_column = getIDColumn(r.media_type) |
|
|
|
id_val = r.movie_id if (r.media_type == media_type.MOVIE) else r.tv_id |
|
|
|
id_val = r.movie_id if (r.media_type == media_type.MOVIE) else r.tv_id |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
# NOTE: check stored details before trying to add to local db to avoid unique key |
|
|
|
# NOTE: check stored details before trying to add to local db to avoid unique key |
|
|
|
# constraint error |
|
|
|
# constraint error |
|
|
|
cur.execute(f'SELECT * FROM query_details WHERE {id_column}=?', (id_val, )) |
|
|
|
cur.execute(f'SELECT * FROM query_details WHERE {id_column}=?', (id_val, )) |
|
|
|
match = cur.fetchone() |
|
|
|
match = cur.fetchone() |
|
|
|
|
|
|
|
|
|
|
|
if match is not None: |
|
|
|
if match is not None: |
|
|
|
|
|
|
|
r.detail_id = match['detail_id'] |
|
|
|
cur.execute(f'INSERT INTO query_mapping(query_id, detail_id)' |
|
|
|
cur.execute(f'INSERT INTO query_mapping(query_id, detail_id)' |
|
|
|
+ ' VALUES (?,?)', (query_id, match['detail_id']) |
|
|
|
+ ' VALUES (?,?)', (query_id, r.detail_id) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
current_app.logger.debug( |
|
|
|
current_app.logger.debug( |
|
|
|
f'skipping result that is already saved. {id_column}: {id_val}, title: {r.title}' |
|
|
|
f'skipping result that is already saved. {id_column}: {id_val}, title: {r.title}' |
|
|
|
) |
|
|
|
) |
|
|
|
break |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
else: |
|
|
|
current_app.logger.debug(f'adding query details for "{r.title}"') |
|
|
|
current_app.logger.debug(f'adding query details for "{r.title}"') |
|
|
|
cur.execute(f'INSERT INTO query_details({id_column}, ' |
|
|
|
cur.execute(f'INSERT INTO query_details({id_column}, ' |
|
|
|
+ 'media_type, title, overview, release_date, original_language, poster_path)' |
|
|
|
+ 'media_type, title, overview, release_date, original_language, poster_path)' |
|
|
|
|