Add rewatch feature to episode NextUp widget

This commit is contained in:
Björn Wachtendorf
2023-03-03 16:41:51 +01:00
parent ad7fbeb31b
commit 4bbeeba20e
3 changed files with 35 additions and 0 deletions

View File

@@ -1132,3 +1132,15 @@ msgstr "Shuffle"
msgctxt "#30449"
msgid "Instant Mix"
msgstr "Instant Mix"
msgctxt "#30450"
msgid "Next Up Rewatching"
msgstr "Next Up Rewatching"
msgctxt "#30451"
msgid "Rewatch Days (0 = Disabled)"
msgstr "Rewatch Days (0 = Disabled)"
msgctxt "#30452"
msgid "Combine instead of replace (might cause slow-down)"
msgstr "Combine instead of replace (might cause slow-down)"

View File

@@ -5,6 +5,7 @@ from __future__ import (
import hashlib
import random
import time
import datetime
import xbmcaddon
import xbmcplugin
@@ -378,6 +379,12 @@ def get_widget_content(handle, params):
url_params["userid"] = user_id
url_params["Recursive"] = True
url_params["ImageTypeLimit"] = 1
# check if rewatching is enabled and combine is disabled
rewatch_days = int(settings.getSetting("rewatch_days"))
if rewatch_days > 0 and settings.getSetting("rewatch_combine") != "true":
rewatch_since = datetime.datetime.today() - datetime.timedelta(days=rewatch_days)
url_params["nextUpDateCutoff"] = rewatch_since.strftime("%Y-%m-%d")
url_params["enableRewatching"] = True
# Collect InProgress items to be combined with NextUp
inprogress_url_verb = "/Users/{}/Items".format(user_id)
inprogress_url_params = url_params.copy()
@@ -448,6 +455,17 @@ def get_widget_content(handle, params):
list_items = inprogress + list_items
# add rewatch combine is enabled
if rewatch_days > 0 and settings.getSetting("rewatch_combine") == "true":
rewatch_since = datetime.datetime.today() - datetime.timedelta(days=rewatch_days)
url_params["nextUpDateCutoff"] = rewatch_since.strftime("%Y-%m-%d")
url_params["enableRewatching"] = True
rewatch_items_url = get_jellyfin_url(url_verb, url_params)
rewatch_items, detected_type, total_records = process_directory(rewatch_items_url, None, params, use_cached_widget_data)
for ri in rewatch_items:
if not any(i[1].getProperty("id") == ri[1].getProperty("id") for i in list_items):
list_items.append(ri)
if detected_type is not None:
# if the media type is not set then try to use the detected type
log.debug("Detected content type: {0}".format(detected_type))

View File

@@ -95,6 +95,11 @@
<setting id="show_empty_folders" type="bool" label="30328" default="false" visible="true" enable="true" />
<setting id="hide_watched" type="bool" label="30432" default="true" visible="true" enable="true" />
<setting label="30450" type="lsep"/>
<setting type="sep" />
<setting id="rewatch_days" type="slider" label="30451" default="0" range="0,1,365" option="int" visible="true"/>
<setting id="rewatch_combine" type="bool" label="30452" default="false" visible="true" enable="true" />
<setting label="30223" type="lsep"/>
<setting type="sep" />
<setting id="moviePageSize" type="slider" label="30331" default="0" range="0,1,100" option="int" visible="true"/>