Release Kodi Check Previous Episode (Matrix+, v0.4.1+)
#1
(Continues from https://forum.kodi.tv/showthread.php?tid...&page=last)

As of June 2020 I have taken over up-keep of this addon, and it is now in the Kodi Matrix (and beyond) repository. 
Thanks to Lucleonhart for the original work, and to Razzeee & enen92 on guiding the transition to Matrix/Python 3.

A simple Kodi service to:

Prevent accidental spoilers by checking the episode (in the Kodi library) prior to the one you are starting to watch, to make sure you have actually watched it.

You can mark shows where episode order doesn't matter as show to be ignored (and unmark them in the addon settings), 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 actually is 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 only, or carry on and also mark the show as one to ignore from now on.


Available from the official Kodi Repository (Matrix onwards).
Source on Github: https://github.com/bossanova808/script.s...ousepisode

Change log:

2020-06-23 - Updated for Kodi Matrix, Python 3, and minor big fixes etc.
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#2
Thank you for this, it's a real life saver for me. But, I wonder if you would possibly consider adding trakt functionality as well?
Thanks!
Reply
#3
@bluenote I think that that is beyond the scope of what I want to take on right now - although I see where you're coming from of course.  But the call to an online API would be dramatically slower than the current checks, so I am not sure that would work nicely anyway...
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#4
Pretty sure I used this addon years ago and lost it between Kodi version updates, and its something I've missed without knowing what I'd used or if it was part on an old skin etc.
Im trying to get the same functionality I remember, but its close but not ideal. 

Using your original example with Dexter, if I accidentally open an episode out of sequence, I want it to take me to the show folder so I can see my eps and pic the right one.
I've enabled the 'force to browse show in library' option, and if my next unwatched ep is s01e05 and I click on s03e08, and pick 'Stop Playback', it's dumping me inside the Season 3 folder.

Could this be changed to open inside the 'all seasons' either by default or new setting? Hopefully that makes sense.
I can understand it might not be idea as the default, particularly if your showing all videos (watched & unwatched) and you've gotta go through dozens of eps etc. However its somewhat flawed assuming you want the same season as the one you clicked on.

Thanks
Reply
#5
Is it, though?  How often do folks click on something in entirely the wrong season (for a show where order matters).  @PaulC2K

That said, maybe you could experiment for me - I'm a tad busy right now - line 163 of default.py is the one you'd want to change:

                                       
                                         command = '{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://2/2/%d/%d" ] }, "id": 1}' % (
                                            playingTvshowid, playingSeason)

..that is some ancient code and should be updated anyway, but I would guess that changing the second parameter to 0 (or -1?) might potentially be what you need...


                                          command = f'{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}/0" ] }, "id": 1}

If you can confirm what works there, I can integrate it properly sometime soon...
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#6
(2021-08-06, 05:15)bossanova808 Wrote: Is it, though?  How often do folks click on something in entirely the wrong season (for a show where order matters).  @PaulC2K

That said, maybe you could experiment for me - I'm a tad busy right now - line 163 of default.py is the one you'd want to change:

                                       
                                         command = '{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://2/2/%d/%d" ] }, "id": 1}' % (
                                            playingTvshowid, playingSeason)

..that is some ancient code and should be updated anyway, but I would guess that changing the second parameter to 0 (or -1?) might potentially be what you need...


                                          command = f'{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}/0" ] }, "id": 1}

If you can confirm what works there, I can integrate it properly sometime soon...

Thats spitting out an error.

Code:
ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'SyntaxError'>
                                                   Error Contents: EOL while scanning string literal (default.py, line 163)
                                                     File "C:\Users\PaulC2K\AppData\Roaming\Kodi\addons\script.service.checkpreviousepisode\default.py", line 163
                                                       command = f'{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}/0" ] }, "id": 1}
                                                                                                                                                                                                                                 ^
                                                   SyntaxError: EOL while scanning string literal
                                                   -->End of Python script error report<--

Same with: {playingTvshowid}/-1"  which i think was what you were suggesting here: changing the second parameter to 0 (or -1?)

Maybe its just me, but the reason why i prefer this method is because i'll typically look at my 'recently added' list when i come to stick something on, and just because its just added a S04 episode doesnt mean im caught up to S04.
I'd assume most people are also going through a 'recently added' list if they're potentially playing something out of sequence.

Theres obviously no urgency to this, things are better how it currently is than it was without the addon, and LazyTV only gives me the warning linking to the first unwatched episode and then dumps me back at the recently added list, and what i always liked was basically the ability to use an out-of-sequence episode as a shortcut to the shows folder.

Ive never dabbled with kodi but i'll have a look and see if i can make sense of the ActivateWindow options and see if i can manipulate it to do exactly what im looking for.


Edit: Not sure if its a stray 'f' at the start of your code, doesnt change anything with Kodi, but i sense notepad++ didnt like the f there.
Edit 2: The error is gone, but 'cancel' just returns me to the 'recently added' list again. I'd directly replaced the first block of code with the modified version, but i noticed it wasnt intended to be a direct replacement. So i now have:
command = '{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}/0" ] }, "id": 1}' % (playingTvshowid, playingSeason)
Reply
#7
the f is deliberate, it's just missing a quote at the end (...an 'f string' is a template string - the more modern way to substitute variable values in to a string. Things in {} will be replaced with variable values (rather than using %d and a list at the end).

But yeah, my suspicion is there is no specific way to get to the ALL Seasons view...I'll


command = f'{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}/0" ] }, "id": 1}'

So try that ^ - but for the 0 on the end, try -1, and -2, as sometimes those are used as special indicators. 

Also, might be worth trying without _any_ value, so


command = f'{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}/" ] }, "id": 1}'

or

command = f'{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/{playingTvshowid}" ] }, "id": 1}'


Ot you could ask in the Kodi JSON working examples thread if anyone knows there.   I have done some searching and can't find any reference to that particular view anywhere, so far...so it might not be reachable via JSON?
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#8
Im getting an error every time.
Im not 100% sure whether the: % (playingTvshowid, playingSeason) bit needs to be there or not, so im trying it with and without, but theres always an error when i launch and the addon doesnt halt the video when playing something out of sequence.
Both with and without the above information added to the command, i get the following complaint in the log: 
Code:
SyntaxError: f-string: expressions nested too deeply

Its not the end of the world though, its just something i vaguely remember being able to do a good 6-8yrs ago and every now & then i'll make a failed attempt at trying to figure out if that feature was dropped from XBMC/Kodi many versions ago, was a function built into an old skin, or an addon i'd not remembered etc. Being dumped in the correct shows folder but in the wrong season is just a minor inconvenience whenever i have future unwatched seasons, and doesnt take much effort to get to the right location either.

If theres nothing obvious ive done wrong and you think its probably not possible, dont worry about it, im still infinitely better off with the addon than i was 2 days ago.

Thanks.
Reply
#9
Ah no that's my bad - I forgot there are other { in the string so ...leave it with me, I'll look at it when I have time.
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#10
So I am told:



command = '{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/%d/-1" ] }, "id": 1}' % (playingTvshowid)


Should do it... (i.e. the -1)

Can you confirm?
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#11
(2021-08-09, 04:11)bossanova808 Wrote: So I am told:



command = '{"jsonrpc": "2.0", "method": "GUI.ActivateWindow", "params": { "window": "videos", "parameters": [ "videodb://tvshows/titles/%d/-1" ] }, "id": 1}' % (playingTvshowid)


Should do it... (i.e. the -1)

Can you confirm?

Yeah, that seems to have worked perfectly. Thanks.
Reply
#12
No worries.  I'll add it as a proper option once I have time...I also want to re-write the addon into modern code as it's pretty gross right now....so will do that all together.
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#13
Right, so I've re-written this addon to much more modern Python3 code.  And I've added a setting for your request to force browse to All Seasons.

All seems to be working here. 

@PaulC2K Can you test it for me, too, though, before I submit it to the main Kodi repo please?  Here's the link to the updated version: https://www.dropbox.com/s/84oubur8iwxvjh...e.zip?dl=0 - it should work just like the previous, except with this extra option to force browse to all seasons.  If you do see any issues or oddness -> can you reproduce and post/dm me a link to a full debug log, please.
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply
#14
(2021-08-11, 04:56)bossanova808 Wrote: Right, so I've re-written this addon to much more modern Python3 code.  And I've added a setting for your request to force browse to All Seasons.

All seems to be working here. 

@PaulC2K Can you test it for me, too, though, before I submit it to the main Kodi repo please?  Here's the link to the updated version: https://www.dropbox.com/s/84oubur8iwxvjh...e.zip?dl=0 - it should work just like the previous, except with this extra option to force browse to all seasons.  If you do see any issues or oddness -> can you reproduce and post/dm me a link to a full debug log, please.

Yup. 'Force to library' + 'go to All Seasons' works perfectly for me. No errors in the log.
Reply
#15
Thanks for confirming, will submit it to the Kodi gods...
Addons I wrote &/or maintain:
OzWeather (Australian BOM weather) | Check Previous Episode | Playback Resumer | Unpause Jumpback | XSqueezeDisplay | (Legacy - XSqueeze & XZen)
Sorry, no help w/out a *full debug log*.
Reply



Logout Mark Read Team Forum Stats Members Help
Kodi Check Previous Episode (Matrix+, v0.4.1+)0
This forum uses Lukasz Tkacz MyBB addons.