1
0
Fork 0
mirror of https://github.com/morpheus65535/bazarr synced 2024-12-23 16:23:41 +00:00

minor search engine changes

This commit is contained in:
Halali 2018-09-26 14:31:47 +02:00
parent fd7cd0a92c
commit bfdc6200b7

View file

@ -313,26 +313,29 @@ def serieseditor():
output = template('serieseditor', __file__=__file__, bazarr_version=bazarr_version, rows=data, languages=languages, missing_count=missing_count, base_url=base_url, single_language=single_language)
return output
@route(base_url + 'search_json/<query>', method='GET')
@custom_auth_basic(check_credentials)
def search_json(query):
authorize()
db = sqlite3.connect(os.path.join(config_dir, 'db/bazarr.db'), timeout=30)
c = db.cursor()
c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title", ('%'+query+'%',))
series = c.fetchall()
c.execute("SELECT title, radarrId FROM table_movies WHERE title LIKE ? ORDER BY title", ('%' + query + '%',))
movies = c.fetchall()
search_list = []
for serie in series:
search_list.append(dict([('name', serie[0]), ('url', base_url + 'episodes/' + str(serie[1]))]))
for movie in movies:
search_list.append(dict([('name', movie[0]), ('url', base_url + 'movie/' + str(movie[1]))]))
if get_general_settings()[12] is True:
c.execute("SELECT title, sonarrSeriesId FROM table_shows WHERE title LIKE ? ORDER BY title",
('%' + query + '%',))
series = c.fetchall()
for serie in series:
search_list.append(dict([('name', serie[0]), ('url', base_url + 'episodes/' + str(serie[1]))]))
if get_general_settings()[13] is True:
c.execute("SELECT title, radarrId FROM table_movies WHERE title LIKE ? ORDER BY title", ('%' + query + '%',))
movies = c.fetchall()
for movie in movies:
search_list.append(dict([('name', movie[0]), ('url', base_url + 'movie/' + str(movie[1]))]))
c.close()
response.content_type = 'application/json'
return dict(items=search_list)