Skip to content

Commit 048c0f1

Browse files
bossanova808bossanova808
andauthored
[script.service.checkpreviousepisode] 0.4.9 (#2771)
Co-authored-by: bossanova808 <[email protected]>
1 parent f46192c commit 048c0f1

File tree

9 files changed

+259
-218
lines changed

9 files changed

+259
-218
lines changed

script.service.checkpreviousepisode/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@ Kodi Check Previous Episode
88

99
Kodi script to prevent accidental spoilers by checking you have actually watched the previous episode (i.e. as recorded in the Kodi library).
1010

11-
You can mark shows where episode order doesn't matter as shows to be ignored (and unmark them in the addon settings if you change your mind), and if you're in the habit of e.g. deleting seasons you have watched, you can force it to only check when the prior epsiode is actually in your library.
11+
You can mark shows where episode order doesn't matter as shows to be ignored (and unmark them in the add-on settings if you change your mind), and if you're in the habit of e.g. deleting seasons you have watched, you can force it to only check when the prior episode is actually in your library.
1212

1313
If it detects you've started playback of an episode you probably shouldn't have, the video will be paused, and you'll get a pop up window with options to stop playback, carry on on this occasion, or carry on and also mark the show as one to ignore from now on.
1414

15-
Support via the forum thread: <https://forum.kodi.tv/showthread.php?tid=355464>
15+
Skinners can even skin the select dialogue by listening to a Window property `CheckPreviousEpisode` which is set to `MissingPreviousEpisode` when the select dialogue is showing (search the [Confluence repo](https://github.com/xbmc/skin.confluence) for `CheckPreviousEpisode` for an example of how this can be done).
1616

17-
Available form the main Kodi repository (legacy Python 2 version for Kodi Leia and below, Python 3 version for Kodi Matrix and the on).
17+
Support via the forum thread: <https://forum.kodi.tv/showthread.php?tid=355464>, or open an issue here.
18+
19+
Available form the main Kodi repository (legacy Python 2 version for Kodi Leia and below, Python 3 version for Kodi Matrix and on).
1820

script.service.checkpreviousepisode/addon.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
2-
<addon id="script.service.checkpreviousepisode" version="0.4.8" name="Kodi Check Previous Episode" provider-name="bossanova808, Razzeee, Lucleonhart" >
2+
<addon id="script.service.checkpreviousepisode" version="0.4.9" name="Kodi Check Previous Episode" provider-name="bossanova808, Razzeee, Lucleonhart">
33
<requires>
44
<import addon="xbmc.python" version="3.0.0" />
55
<import addon="script.module.yaml" version="3.11.0" />
@@ -17,9 +17,9 @@
1717
<forum>https://forum.kodi.tv/showthread.php?tid=355464</forum>
1818
<website>https://kodi.wiki/view/Add-on:XBMC_Check_Previous_Episode</website>
1919
<source>https://github.com/bossanova808/script.service.checkpreviousepisode</source>
20-
<news>v0.4.8
21-
- Remove old common code, use new module
22-
- Fix bug if last ignored show is removed from ignore list then that show is re-played in same Kodi session
20+
<news>v0.4.9
21+
- Prep for Piers, use new module Logger
22+
- Sundry fixes/tightening from CodeRabbit reviews
2323
</news>
2424
<assets>
2525
<icon>icon.png</icon>

script.service.checkpreviousepisode/changelog.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
v0.4.9
2+
- Prep for Piers, use new module Logger
3+
- Sundry fixes/tightening from CodeRabbit reviews
4+
15
v0.4.8
26
- Remove old common code, use new module
37
- Fix bug if last ignored show is removed from ignore list then that show is re-played in same Kodi session

script.service.checkpreviousepisode/default.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# -*- coding: utf-8 -*-
21
from resources.lib import check_previous_episode
32
import sys
43
from bossanova808 import exception_logger
Lines changed: 42 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# XBMC Media Center language file
1+
# XBMC Media Center language file - Swedish
22
# Addon Name: XBMC Version Check
33
# Addon id: script.xbmc.checkpreviousepisode
44
# Addon Provider: Lucleonhart
@@ -7,43 +7,56 @@ msgstr ""
77
"Project-Id-Version: XBMC Addons\n"
88
"Report-Msgid-Bugs-To: [email protected]\n"
99
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
10-
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
11-
"Last-Translator: JKB\n"
12-
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
10+
"PO-Revision-Date: 2025-09-10 11:32+0200\n"
11+
"Last-Translator: Daniel Nylander <[email protected]>\n"
12+
"Language-Team: Swedish\n"
13+
"Language: sv\n"
1314
"MIME-Version: 1.0\n"
1415
"Content-Type: text/plain; charset=UTF-8\n"
1516
"Content-Transfer-Encoding: 8bit\n"
16-
"Language: sv\n"
1717
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
18+
"X-Generator: Poedit 3.7\n"
19+
20+
msgctxt "#32020"
21+
msgid "Previous episode not watched! Choose to:"
22+
msgstr "Föregående avsnitt har inte visats! Välj att:"
23+
24+
msgctxt "#32021"
25+
msgid "Stop playback"
26+
msgstr "Stoppa uppspelning"
27+
28+
msgctxt "#32022"
29+
msgid "Continue playback"
30+
msgstr "Fortsätt uppspelning"
1831

19-
msgctxt "#32001"
20-
msgid "Missing Episode"
21-
msgstr "Saknat avsnitt"
32+
msgctxt "#32023"
33+
msgid "Continue playback (and from now on ignore this show)"
34+
msgstr "Fortsätt uppspelningen (och från och med nu ignorera denna serie)"
2235

23-
msgctxt "#32002"
24-
msgid "The previous episode is missing from your library!"
25-
msgstr "Föregående avsnitt saknas i ditt bibliotek!"
36+
msgctxt "#32050"
37+
msgid "Force Kodi to browse to show in library after playback prevention?"
38+
msgstr "Tvinga Kodi att bläddra för att visa i biblioteket efter uppspelningsförebyggande?"
2639

27-
msgctxt "#32003"
28-
msgid "Are you sure you want to play this one?"
29-
msgstr "Är du säker på att du vill spela upp denna?"
40+
msgctxt "#32051"
41+
msgid "Warn only if previous episode actually found in library and unwatched?"
42+
msgstr "Varning endast om föregående avsnitt faktiskt finns i biblioteket och är osett?"
3043

31-
msgctxt "#32004"
32-
msgid "Unwatched Episode"
33-
msgstr "Osett avsnitt"
44+
msgctxt "#32052"
45+
msgid "Remove a show from your ignored list..."
46+
msgstr "Ta bort en serie från din ignorerade lista..."
3447

35-
msgctxt "#32005"
36-
msgid "You have not watched the previous episode!"
37-
msgstr "Du har inte tittat på föregående avsnitt!"
48+
msgctxt "#32053"
49+
msgid "Browse to All Seasons rather than episode season"
50+
msgstr "Bläddra till Alla säsonger snarare än avsnittssäsong"
3851

39-
msgctxt "#32006"
40-
msgid "Browse show"
41-
msgstr "Bläddra i serien"
52+
msgctxt "#32060"
53+
msgid "No ignored shows to manage."
54+
msgstr "Inga ignorerade serier att hantera."
4255

43-
msgctxt "#32007"
44-
msgid "Would you like to browse the episodes of this show?"
45-
msgstr "Önskar du bläddra bland seriens avsnitt?"
56+
msgctxt "#32061"
57+
msgid "General"
58+
msgstr "Allmänt"
4659

47-
msgctxt "#32008"
48-
msgid "Show Option to browse the show"
49-
msgstr "Visa val för att bläddra i serien"
60+
msgctxt "#32062"
61+
msgid "Select show to stop ignoring"
62+
msgstr "Välj serie att inte ignorera"
Lines changed: 35 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
from bossanova808.utilities import *
2-
from bossanova808.constants import *
1+
import xbmcgui
2+
3+
from bossanova808.constants import TRANSLATE
34
from bossanova808.logger import Logger
45
from bossanova808.notify import Notify
56
# noinspection PyPackages
@@ -8,8 +9,6 @@
89
from .monitor import KodiEventMonitor
910
# noinspection PyPackages
1011
from .player import KodiPlayer
11-
import xbmc
12-
import os
1312

1413

1514
def manage_ignored():
@@ -25,26 +24,26 @@ def manage_ignored():
2524

2625
# Short circuit if no ignored shows, so nothing to manage...
2726
if len(Store.ignored_shows) < 1:
28-
Notify.info(LANGUAGE(32060), 5000)
27+
Notify.info(TRANSLATE(32060), 5000)
2928
return
3029

3130
# OK, there are ignored shows in the list...
3231

33-
# Convert our dict to a list for the dialog...
34-
ignored_list = []
35-
for key, value in list(Store.ignored_shows.items()):
36-
ignored_list.append(value)
32+
# Build a sorted (id, title) list for stable mapping and to handle duplicate titles
33+
sorted_pairs = sorted(
34+
Store.ignored_shows.items(),
35+
key=lambda kv:((kv[1] or '').casefold(), str(kv[0]))
36+
)
37+
labels = [title for (_, title) in sorted_pairs]
3738

38-
if ignored_list:
39-
selected = dialog.select(LANGUAGE(32062), ignored_list)
39+
if labels:
40+
selected = dialog.select(TRANSLATE(32062), labels)
4041
if selected != -1:
41-
show_title = ignored_list[selected]
42+
tvshow_id, show_title = sorted_pairs[selected]
4243
Logger.info("User has requested we stop ignoring: " + show_title)
4344
Logger.debug("Ignored shows before removal is: " + str(Store.ignored_shows))
44-
# find the key (new_to_ignore_tv_show_id) for this show& remove from dict
45-
key = list(Store.ignored_shows.keys())[list(Store.ignored_shows.values()).index(show_title)]
46-
Store.ignored_shows.pop(key, None)
47-
Logger.debug("Ignored shows after removal is: " + str(Store.ignored_shows))
45+
Store.ignored_shows.pop(tvshow_id, None)
46+
Logger.debug("Ignored shows after removal is: " + str(Store.ignored_shows))
4847
Store.write_ignored_shows_to_config()
4948

5049

@@ -54,27 +53,26 @@ def run(args):
5453
5554
:return:
5655
"""
57-
footprints()
58-
# Initialise the global store and load the addon settings
59-
Store()
56+
try:
57+
Logger.start()
58+
# Initialise the global store and load the addon settings
59+
Store()
6060

61-
# TWO RUN-MODES - we're either running as a service, or we're running the tool to manage ignored shows...
61+
# TWO RUN-MODES - we're either running as a service, or we're running the tool to manage ignored shows...
6262

63-
# MANAGE IGNORED SHOWS
64-
if len(args) > 1:
65-
if args[1].startswith('ManageIgnored'):
63+
# MANAGE IGNORED SHOWS
64+
if len(args) > 1 and args[1].startswith('ManageIgnored'):
6665
manage_ignored()
67-
68-
# DEFAULT - RUN AS A SERVICE & WATCH PLAYBACK EVENTS
69-
else:
70-
Logger.info("Listening to onAvStarted for episode playback.")
71-
Store.kodi_event_monitor = KodiEventMonitor(xbmc.Monitor)
72-
Store.kodi_player = KodiPlayer(xbmc.Player)
73-
74-
while not Store.kodi_event_monitor.abortRequested():
75-
# Sleep/wait for abort for 10 seconds
76-
if Store.kodi_event_monitor.waitForAbort(1):
77-
# Abort was requested while waiting. We should exit
78-
break
79-
80-
footprints(False)
66+
# DEFAULT - RUN AS A SERVICE & WATCH PLAYBACK EVENTS
67+
else:
68+
Logger.info("Listening to onAVStarted for episode playback.")
69+
kodi_event_monitor = KodiEventMonitor()
70+
# Keep instance alive to receive Kodi player events
71+
_kodi_player = KodiPlayer()
72+
73+
while not kodi_event_monitor.waitForAbort(1):
74+
pass
75+
Logger.debug('Abort Requested')
76+
77+
finally:
78+
Logger.stop()

script.service.checkpreviousepisode/resources/lib/monitor.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,10 @@
66

77
class KodiEventMonitor(xbmc.Monitor):
88

9-
def __init__(self, *args, **kwargs):
10-
xbmc.Monitor.__init__(self)
9+
def __init__(self):
10+
super().__init__()
1111
Logger.debug('KodiEventMonitor __init__')
1212

1313
def onSettingsChanged(self):
1414
Logger.info('onSettingsChanged - reload them.')
1515
Store.load_config_from_settings()
16-
17-
def onAbortRequested(self):
18-
Logger.debug('onAbortRequested')

0 commit comments

Comments
 (0)