im85288 / service.upnext

GNU General Public License v2.0
80 stars 41 forks source link

Fix error when kodi is not playing video any longer #298

Closed AnonTester closed 1 year ago

AnonTester commented 1 year ago

Fixes timing issue that sometimes pops up when stopping or forward skipping at end of movie/show just as UpNext is starting up resulting in error:

error : EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--

MoojMidge commented 1 year ago

Thanks for this.

Properly handling the RuntimeError raised by xbmc.Player methods when playback ends is something that could be done in a more general manner, but it is a little bit more involved than using try/catch for each individual method call.

In this particular instance however, catching the exception is probably not quite the right fix. The actual code in get_next that triggers the error should probably be changed to use the filename of the currently tracked video instead, as this avoids the potential for Unicode decode errors in Kodi 18, (using Python 2) and also allows the rest of the code to terminate normally if playback has stopped.

https://github.com/im85288/service.upnext/blob/147ed8502fc8a824081db6de5da970548b07fadc/resources/lib/playitem.py#L61

    current_file = self.player.get_last_file()

Also there is no need to update the changelog and bump the version number, as that is done as part of a separate PR in order to trigger the release workflow.

MoojMidge commented 1 year ago

@AnonTester - did you want to update this?

AnonTester commented 1 year ago

@MoojMidge adjusted to remove version and changelog and changing the try/catch which works for me with your suggestion instead.

MoojMidge commented 1 year ago

Hmm looks like this uncovered a previous old issue - player.Player was renamed to player.UpNextPlayer but a number of the imports were not updated. Now importing player.Player actually imports xbmc.player rather than the new class.

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information