Add before and after parameter to get_history API command

This commit is contained in:
JonnyWong16 2021-11-29 20:00:31 -08:00
parent 98fe7d7a0f
commit eee5402c80
No known key found for this signature in database
GPG key ID: B1F1F9807184697A
2 changed files with 17 additions and 1 deletions

View file

@ -160,6 +160,9 @@ def build_custom_where(custom_where=[]):
elif str(w_).startswith('LIKE '): elif str(w_).startswith('LIKE '):
c_where += w[0] + ' LIKE ?' c_where += w[0] + ' LIKE ?'
args.append(w_[5:]) args.append(w_[5:])
elif w[0].endswith('<') or w[0].endswith('>'):
c_where += w[0] + '= ?'
args.append(w_)
else: else:
c_where += w[0] + ' = ?' c_where += w[0] + ' = ?'
args.append(w_) args.append(w_)
@ -171,6 +174,9 @@ def build_custom_where(custom_where=[]):
elif str(w[1]).startswith('LIKE '): elif str(w[1]).startswith('LIKE '):
c_where += w[0] + ' LIKE ?' c_where += w[0] + ' LIKE ?'
args.append(w[1][5:]) args.append(w[1][5:])
elif w[0].endswith('<') or w[0].endswith('>'):
c_where += w[0] + '= ?'
args.append(w[1])
else: else:
c_where += w[0] + ' = ?' c_where += w[0] + ' = ?'
args.append(w[1]) args.append(w[1])

View file

@ -1884,7 +1884,9 @@ class WebInterface(object):
rating_key (int): 4348 rating_key (int): 4348
parent_rating_key (int): 544 parent_rating_key (int): 544
grandparent_rating_key (int): 351 grandparent_rating_key (int): 351
start_date (str): "YYYY-MM-DD" start_date (str): History for the exact date, "YYYY-MM-DD"
before (str): History before and including the date, "YYYY-MM-DD"
after (str): History after and including the date, "YYYY-MM-DD"
section_id (int): 2 section_id (int): 2
media_type (str): "movie", "episode", "track", "live" media_type (str): "movie", "episode", "track", "live"
transcode_decision (str): "direct play", "copy", "transcode", transcode_decision (str): "direct play", "copy", "transcode",
@ -1995,6 +1997,14 @@ class WebInterface(object):
start_date = helpers.split_strip(kwargs.get('start_date', '')) start_date = helpers.split_strip(kwargs.get('start_date', ''))
if start_date: if start_date:
custom_where.append(['strftime("%Y-%m-%d", datetime(started, "unixepoch", "localtime"))', start_date]) custom_where.append(['strftime("%Y-%m-%d", datetime(started, "unixepoch", "localtime"))', start_date])
if 'before' in kwargs:
before = helpers.split_strip(kwargs.get('before', ''))
if before:
custom_where.append(['strftime("%Y-%m-%d", datetime(started, "unixepoch", "localtime")) <', before])
if 'after' in kwargs:
after = helpers.split_strip(kwargs.get('after', ''))
if after:
custom_where.append(['strftime("%Y-%m-%d", datetime(started, "unixepoch", "localtime")) >', after])
if 'reference_id' in kwargs: if 'reference_id' in kwargs:
reference_id = helpers.split_strip(kwargs.get('reference_id', '')) reference_id = helpers.split_strip(kwargs.get('reference_id', ''))
if reference_id: if reference_id: