|
|
|
@ -9,6 +9,7 @@ import ssl |
|
|
|
from urllib.error import URLError, HTTPError |
|
|
|
from urllib.error import URLError, HTTPError |
|
|
|
import urllib.parse |
|
|
|
import urllib.parse |
|
|
|
import urllib.request |
|
|
|
import urllib.request |
|
|
|
|
|
|
|
import yaml |
|
|
|
|
|
|
|
|
|
|
|
from flask import Blueprint, current_app, flash, Flask, request, render_template |
|
|
|
from flask import Blueprint, current_app, flash, Flask, request, render_template |
|
|
|
|
|
|
|
|
|
|
|
@ -95,10 +96,6 @@ class view_result(object): |
|
|
|
|
|
|
|
|
|
|
|
@bp.route('/query_movie') |
|
|
|
@bp.route('/query_movie') |
|
|
|
def query_movie(): |
|
|
|
def query_movie(): |
|
|
|
|
|
|
|
|
|
|
|
logger.debug('Flask(__name__): {}'.format(Flask(__name__))) |
|
|
|
|
|
|
|
logger.debug('debug: {}'.format(Flask(__name__).config['DEBUG'])) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
errors = [] |
|
|
|
errors = [] |
|
|
|
query = query_data() |
|
|
|
query = query_data() |
|
|
|
response = response_data() |
|
|
|
response = response_data() |
|
|
|
@ -143,9 +140,11 @@ def query_movie(): |
|
|
|
return render_template( |
|
|
|
return render_template( |
|
|
|
'tmdb/query.html', |
|
|
|
'tmdb/query.html', |
|
|
|
view_data = view_results, |
|
|
|
view_data = view_results, |
|
|
|
debug_str = str(util.dumpObjAttr(query) + '\n' |
|
|
|
debug_str = '{} \n {} \n {} \n'.format( |
|
|
|
+ util.dumpObjAttr(response)) + '\n' |
|
|
|
yaml.dump(query, indent=4), |
|
|
|
+ util.dumpList(view_results, 0) + '\n' |
|
|
|
yaml.dump(response, indent=4), |
|
|
|
|
|
|
|
yaml.dump(view_results, indent=4) |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -156,6 +155,7 @@ def query_movie(): |
|
|
|
# with legitimate dates in the title |
|
|
|
# with legitimate dates in the title |
|
|
|
def parseQueryStr(query_obj): |
|
|
|
def parseQueryStr(query_obj): |
|
|
|
s = query_obj.raw_query_str.replace('.', ' ').strip() |
|
|
|
s = query_obj.raw_query_str.replace('.', ' ').strip() |
|
|
|
|
|
|
|
s = re.sub('[(){}\[\]]', '', s).strip() # NOTE: remove some common characters |
|
|
|
current_year = date.today().year |
|
|
|
current_year = date.today().year |
|
|
|
|
|
|
|
|
|
|
|
# NOTE: find all 4 digit numbers to match the year of queries with 4 digit numbers in the title |
|
|
|
# NOTE: find all 4 digit numbers to match the year of queries with 4 digit numbers in the title |
|
|
|
@ -199,16 +199,17 @@ def makeLocalQuery(query_obj): |
|
|
|
elif query_obj.query_type == query_type.TV_SHOW: |
|
|
|
elif query_obj.query_type == query_type.TV_SHOW: |
|
|
|
pass |
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
logger.debug('number of rows matched: "{}"'.format(len(cur.fetchall()))) |
|
|
|
rows = cur.fetchall() |
|
|
|
|
|
|
|
logger.debug('number of rows matched: "{}"'.format(len(rows))) |
|
|
|
|
|
|
|
|
|
|
|
if len(cur.fetchall()) > 0: |
|
|
|
if len(rows) > 0: |
|
|
|
logger.debug('query string "{}", match found in local db'.format( |
|
|
|
logger.debug('query string "{}", match found in local db'.format( |
|
|
|
query_obj.parsed_query_str) |
|
|
|
query_obj.parsed_query_str) |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
for row in cur: |
|
|
|
for row in rows: |
|
|
|
vr = view_result() |
|
|
|
vr = view_result() |
|
|
|
vr.title = row["title"] |
|
|
|
vr.title = row["query"] |
|
|
|
results.append(vr) |
|
|
|
results.append(vr) |
|
|
|
else: |
|
|
|
else: |
|
|
|
logger.debug('query string "{}", no matches found in local db'.format( |
|
|
|
logger.debug('query string "{}", no matches found in local db'.format( |
|
|
|
|