Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions script.service.checkpreviousepisode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ Kodi Check Previous Episode

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

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.
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.

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.

Support via the forum thread: <https://forum.kodi.tv/showthread.php?tid=355464>
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).

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

Available form the main Kodi repository (legacy Python 2 version for Kodi Leia and below, Python 3 version for Kodi Matrix and on).

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

v0.4.8
- Remove old common code, use new module
- Fix bug if last ignored show is removed from ignore list then that show is re-played in same Kodi session
Expand Down
1 change: 0 additions & 1 deletion script.service.checkpreviousepisode/default.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from resources.lib import check_previous_episode
import sys
from bossanova808 import exception_logger
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# XBMC Media Center language file
# XBMC Media Center language file - Swedish
# Addon Name: XBMC Version Check
# Addon id: script.xbmc.checkpreviousepisode
# Addon Provider: Lucleonhart
Expand All @@ -7,43 +7,56 @@ msgstr ""
"Project-Id-Version: XBMC Addons\n"
"Report-Msgid-Bugs-To: [email protected]\n"
"POT-Creation-Date: YEAR-MO-DA HO:MI+ZONE\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: JKB\n"
"Language-Team: English (http://www.transifex.com/projects/p/xbmc-addons/language/en/)\n"
"PO-Revision-Date: 2025-09-10 11:32+0200\n"
"Last-Translator: Daniel Nylander <[email protected]>\n"
"Language-Team: Swedish\n"
"Language: sv\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Language: sv\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"X-Generator: Poedit 3.7\n"

msgctxt "#32020"
msgid "Previous episode not watched! Choose to:"
msgstr "Föregående avsnitt har inte visats! Välj att:"

msgctxt "#32021"
msgid "Stop playback"
msgstr "Stoppa uppspelning"

msgctxt "#32022"
msgid "Continue playback"
msgstr "Fortsätt uppspelning"

msgctxt "#32001"
msgid "Missing Episode"
msgstr "Saknat avsnitt"
msgctxt "#32023"
msgid "Continue playback (and from now on ignore this show)"
msgstr "Fortsätt uppspelningen (och från och med nu ignorera denna serie)"

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

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

msgctxt "#32004"
msgid "Unwatched Episode"
msgstr "Osett avsnitt"
msgctxt "#32052"
msgid "Remove a show from your ignored list..."
msgstr "Ta bort en serie från din ignorerade lista..."

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

msgctxt "#32006"
msgid "Browse show"
msgstr "Bläddra i serien"
msgctxt "#32060"
msgid "No ignored shows to manage."
msgstr "Inga ignorerade serier att hantera."

msgctxt "#32007"
msgid "Would you like to browse the episodes of this show?"
msgstr "Önskar du bläddra bland seriens avsnitt?"
msgctxt "#32061"
msgid "General"
msgstr "Allmänt"

msgctxt "#32008"
msgid "Show Option to browse the show"
msgstr "Visa val för att bläddra i serien"
msgctxt "#32062"
msgid "Select show to stop ignoring"
msgstr "Välj serie att inte ignorera"
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from bossanova808.utilities import *
from bossanova808.constants import *
import xbmcgui

from bossanova808.constants import TRANSLATE
from bossanova808.logger import Logger
from bossanova808.notify import Notify
# noinspection PyPackages
Expand All @@ -8,8 +9,6 @@
from .monitor import KodiEventMonitor
# noinspection PyPackages
from .player import KodiPlayer
import xbmc
import os


def manage_ignored():
Expand All @@ -25,26 +24,26 @@ def manage_ignored():

# Short circuit if no ignored shows, so nothing to manage...
if len(Store.ignored_shows) < 1:
Notify.info(LANGUAGE(32060), 5000)
Notify.info(TRANSLATE(32060), 5000)
return

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

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

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


Expand All @@ -54,27 +53,26 @@ def run(args):

:return:
"""
footprints()
# Initialise the global store and load the addon settings
Store()
try:
Logger.start()
# Initialise the global store and load the addon settings
Store()

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

# MANAGE IGNORED SHOWS
if len(args) > 1:
if args[1].startswith('ManageIgnored'):
# MANAGE IGNORED SHOWS
if len(args) > 1 and args[1].startswith('ManageIgnored'):
manage_ignored()

# DEFAULT - RUN AS A SERVICE & WATCH PLAYBACK EVENTS
else:
Logger.info("Listening to onAvStarted for episode playback.")
Store.kodi_event_monitor = KodiEventMonitor(xbmc.Monitor)
Store.kodi_player = KodiPlayer(xbmc.Player)

while not Store.kodi_event_monitor.abortRequested():
# Sleep/wait for abort for 10 seconds
if Store.kodi_event_monitor.waitForAbort(1):
# Abort was requested while waiting. We should exit
break

footprints(False)
# DEFAULT - RUN AS A SERVICE & WATCH PLAYBACK EVENTS
else:
Logger.info("Listening to onAVStarted for episode playback.")
kodi_event_monitor = KodiEventMonitor()
# Keep instance alive to receive Kodi player events
_kodi_player = KodiPlayer()

while not kodi_event_monitor.waitForAbort(1):
pass
Logger.debug('Abort Requested')

finally:
Logger.stop()
7 changes: 2 additions & 5 deletions script.service.checkpreviousepisode/resources/lib/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,10 @@

class KodiEventMonitor(xbmc.Monitor):

def __init__(self, *args, **kwargs):
xbmc.Monitor.__init__(self)
def __init__(self):
super().__init__()
Logger.debug('KodiEventMonitor __init__')

def onSettingsChanged(self):
Logger.info('onSettingsChanged - reload them.')
Store.load_config_from_settings()

def onAbortRequested(self):
Logger.debug('onAbortRequested')
Loading