|
8 | 8 | import xbmcvfs |
9 | 9 |
|
10 | 10 | # 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 |
12 | 12 | # noinspection PyPackages |
13 | 13 | from bossanova808.logger import Logger |
14 | 14 | # noinspection PyUnresolvedReferences |
@@ -391,12 +391,22 @@ def load_or_init(self) -> None: |
391 | 391 | if self.remove_watched_playbacks: |
392 | 392 | paths_to_remove = [] |
393 | 393 | for item in list(self.list): |
| 394 | + # BD item? Is it marked as watched in the DB? |
394 | 395 | if item.dbid: |
395 | | - # Is it marked as watched in the DB? |
396 | 396 | playcount = get_playcount(item.type, item.dbid) |
397 | 397 | if playcount and playcount > 0: |
398 | 398 | 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}]") |
400 | 410 | paths_to_remove.append(item.path) |
401 | 411 |
|
402 | 412 | if paths_to_remove: |
|
0 commit comments