Skip to content

Commit 2831f41

Browse files
committed
Also filter out watched non db items
1 parent bee210f commit 2831f41

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

resources/lib/playback.py

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import xbmcvfs
99

1010
# noinspection PyPackages
11-
from bossanova808.utilities import clean_art_url, send_kodi_json, get_resume_point, get_playcount
11+
from bossanova808.utilities import clean_art_url, send_kodi_json, get_resume_point, get_playcount, get_advancedsetting
1212
# noinspection PyPackages
1313
from bossanova808.logger import Logger
1414
# noinspection PyUnresolvedReferences
@@ -391,12 +391,22 @@ def load_or_init(self) -> None:
391391
if self.remove_watched_playbacks:
392392
paths_to_remove = []
393393
for item in list(self.list):
394+
# BD item? Is it marked as watched in the DB?
394395
if item.dbid:
395-
# Is it marked as watched in the DB?
396396
playcount = get_playcount(item.type, item.dbid)
397397
if playcount and playcount > 0:
398398
list_needs_save = True
399-
Logger.debug(f"Filtering watched playback from the list: [{item.pluginlabel}]")
399+
Logger.debug(f"Filtering watched playback from the list (as playcount > 0 in Kodi DB): [{item.pluginlabel}]")
400+
paths_to_remove.append(item.path)
401+
402+
# Not a DB item, use a calculation instead and compare to the playcount_minium_percent
403+
elif item.resumetime and item.totaltime:
404+
percent_played = (item.resumetime / item.totaltime) * 100
405+
# Use the user set playcount_minium_percent if there is one, or fallback to Kodi default 90 percent
406+
playcount_minium_percent = float(get_advancedsetting('video/playcountminimumpercent')) or 90.0
407+
if percent_played >= playcount_minium_percent:
408+
list_needs_save = True
409+
Logger.debug(f"Filtering watched playback from the list (as {percent_played:.1f}% played is over playcount_minium_percent {playcount_minium_percent}%: [{item.pluginlabel}]")
400410
paths_to_remove.append(item.path)
401411

402412
if paths_to_remove:

resources/lib/store.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from bossanova808.constants import HOME_WINDOW, PROFILE, ADDON
66
from bossanova808.logger import Logger
7-
from bossanova808.utilities import get_kodi_setting, set_property, clear_property
7+
from bossanova808.utilities import get_kodi_setting, set_property, clear_property, get_advancedsetting
88
from resources.lib.playback import PlaybackList
99

1010

0 commit comments

Comments
 (0)