|
|
|
|
@ -98,17 +98,30 @@ class result_encoder(json.JSONEncoder):
|
|
|
|
|
# flask routes |
|
|
|
|
|
|
|
|
|
@bp.route('/list_movie_test') |
|
|
|
|
def list_movie_test(): |
|
|
|
|
@bp.route('/list_movie_test/<string:sorting>') |
|
|
|
|
def list_movie_test(sorting = 'title'): |
|
|
|
|
if sorting == 'add-date': |
|
|
|
|
orderby = 'mp.add_date' |
|
|
|
|
elif sorting == 'add-date-desc': |
|
|
|
|
orderby = 'mp.add_date DESC' |
|
|
|
|
elif sorting == 'release-date': |
|
|
|
|
orderby = 'md.release_date' |
|
|
|
|
elif sorting == 'release-date-desc': |
|
|
|
|
orderby = 'md.release_date DESC' |
|
|
|
|
else: |
|
|
|
|
orderby = 'md.title' |
|
|
|
|
# TODO: order by genres, unwatched folder... |
|
|
|
|
|
|
|
|
|
conn = db.get_db() |
|
|
|
|
cur = conn.cursor() |
|
|
|
|
view_results = [] |
|
|
|
|
query = '''SELECT |
|
|
|
|
movie_details.*, movie_paths.movie_path |
|
|
|
|
query = f'''SELECT |
|
|
|
|
md.*, mp.movie_path |
|
|
|
|
FROM |
|
|
|
|
movie_details |
|
|
|
|
JOIN movie_paths ON movie_paths.movie_id=movie_details.movie_id |
|
|
|
|
movie_details md |
|
|
|
|
JOIN movie_paths mp ON mp.movie_id=md.movie_id |
|
|
|
|
ORDER BY |
|
|
|
|
movie_details.title''' |
|
|
|
|
{orderby}''' |
|
|
|
|
|
|
|
|
|
# TODO: should probably loop on movie_id, and add a list of movie_paths because |
|
|
|
|
# there can be multiple paths associated with a movie_id |
|
|
|
|
@ -190,7 +203,7 @@ def create_mapping():
|
|
|
|
|
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(?, ?)', |
|
|
|
|
cur.execute('INSERT INTO movie_paths(movie_id, movie_path, add_date) VALUES(?, ?, datetime())', |
|
|
|
|
(movie_id, rel_path )) |
|
|
|
|
except DatabaseError as e: |
|
|
|
|
errors.append(str(e)) |
|
|
|
|
@ -209,7 +222,7 @@ def create_mapping():
|
|
|
|
|
################### |
|
|
|
|
# helpers |
|
|
|
|
|
|
|
|
|
def doQueryAlgorithm(query:query_data) -> list: |
|
|
|
|
def doQueryAlgorithm(query:query_data) -> dict: |
|
|
|
|
errors, view_results = [], [] |
|
|
|
|
response = response_data() |
|
|
|
|
|
|
|
|
|
@ -400,7 +413,6 @@ def storeTMDBQueryResults(query_obj, result_list):
|
|
|
|
|
|
|
|
|
|
current_app.logger.debug(f'{util.getFunctionName()}, adding query string ' |
|
|
|
|
f'"{query_obj.parsed_query_str}" into local cache') |
|
|
|
|
#current_app.logger.debug(f'{util.getFunctionName()}, result_list:\n{result_list} ') |
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
cur.execute('BEGIN TRANSACTION') |
|
|
|
|
|