mattblovell / kodi_panel

Front panel LCD display for Kodi (via JSON-RPC)
MIT License
12 stars 5 forks source link

Artwork error causing crash #5

Closed skunge2000 closed 3 years ago

skunge2000 commented 3 years ago

When I play Music everything works OK, however when I play a TV Show or TV Recording sometimes I get the following error :

Unexpected error: <class 'UnboundLocalError'> Traceback (most recent call last): File "kodi_panel_fb.py", line 89, in kodi_panel_display.main(device) File "/home/pi/kodi_panel/kodi_panel_display.py", line 1507, in main update_display() File "/home/pi/kodi_panel/kodi_panel_display.py", line 1314, in update_display video_screens(image, draw, video_info, prog) File "/home/pi/kodi_panel/kodi_panel_display.py", line 1116, in video_screens _static_image = video_screen_static(info) File "/home/pi/kodi_panel/kodi_panel_display.py", line 1038, in video_screen_static layout["thumb"]["width"], layout["thumb"]["height"]) File "/home/pi/kodi_panel/kodi_panel_display.py", line 525, in get_artwork r = requests.get(image_url, stream = True) UnboundLocalError: local variable 'image_url' referenced before assignment

mattblovell commented 3 years ago

There are some debug print() statements that are currently commented out on Lines 500, 517, and 521. Can you uncomment those, start kodi_display, and give it a try again?

That will let us see what get_artwork() is dealing with. Hopefully that is sufficient information, otherwise we may have to go further back and see what sort of response the JSON-RPC call in update_screen() on Lines 1277-1297 is getting. (There is a print statement on Line 1297 toward that end. Uncommenting it, though, prints the potentially lengthy response every second.)

Thanks!

mattblovell commented 3 years ago

The line numbers all reference kodi_panel_display.py of course.

mattblovell commented 3 years ago

One guess is that the episodes triggering the error have no artwork. If you examine the start of get_artwork(), it checks for the cover_path being either empty or the literal DefaultAlbumCover.png.

    if (cover_path != '' and
        cover_path != 'DefaultAlbumCover.png' and
        not _airtunes_re.match(cover_path)):

Kodi could well have some other file that it uses by default for movies and/or TV episodes that don't have artwork. If that's the case, then kodi_panel_display.py will need some updates to handle those defaults, similar to what's done now with _default_thumb. At present, there's only a single default that is intended for audio -- that will have to be expanded to other categories.

UPDATE: The github for kodi, in the Estuary skin

https://github.com/xbmc/xbmc/tree/master/addons/skin.estuary/media

looks to have several possible files that would fit the above description: DefaultTVShows.png, DefaultVideo.png, DefaultVideoCover.png.

skunge2000 commented 3 years ago

Yep - I think you're right - it's to do with missing artwork. When I went through all my TV shows that had artwork - all played fine (though the series title wasn't displayed - just the episode title - but that's by the by)

However when I went to a folder of .ts recordings that aren't in any library, and haven't been scraped and don't have any metadata files with them, via Videos->Files I got a crash :

image_path :  DefaultVideoCover.png
Response:  {"error": {"code": -32602, "data": {"details": null}, "message": "Invalid params."}, "id": 5, "jsonrpc": "2.0"}
Unexpected error:  <class 'UnboundLocalError'>
Traceback (most recent call last):
  File "kodi_panel_fb.py", line 89, in <module>
    kodi_panel_display.main(device)
  File "/home/pi/kodi_panel/kodi_panel_display.py", line 1507, in main
    update_display()
  File "/home/pi/kodi_panel/kodi_panel_display.py", line 1314, in update_display
    video_screens(image, draw, video_info, prog)
  File "/home/pi/kodi_panel/kodi_panel_display.py", line 1116, in video_screens
    _static_image = video_screen_static(info)
  File "/home/pi/kodi_panel/kodi_panel_display.py", line 1038, in video_screen_static
    layout["thumb"]["width"], layout["thumb"]["height"])
  File "/home/pi/kodi_panel/kodi_panel_display.py", line 525, in get_artwork
    r = requests.get(image_url, stream = True)
UnboundLocalError: local variable 'image_url' referenced before assignment
mattblovell commented 3 years ago

However when I went to a folder of .ts recordings that aren't in any library, and haven't been scraped and don't have any metadata files with them, via Videos->Files I got a crash

Ok. I can't quite duplicate it here (although I could see if I can remove existing metadata from some demonstration videos), but I'll try to set up a path to handle it.

skunge2000 commented 3 years ago

Adding a new folder with just a video file as a source in the Videos->Files section and not including it in any library would replicate my situation I suspect. (i.e. not defining it as containing TV Shows or Movies etc.) In case it matters - they are all SMB folders in my set-up - I have no local storage

mattblovell commented 3 years ago

Please try the latest release (v1.10).

I was able, briefly, to replicate the issue. I think I have some scrapers installed in Kodi that make quick work of grabbing a frame from a video file and using that as a cover, lacking any other metadata!

Please reopen if the problem still exists.

skunge2000 commented 3 years ago

Yep - can confirm this now solves the crashing issue - and I get a generic play icon when there is no artwork.

mattblovell commented 3 years ago

Great.

The image used by default can be modified using the setup.toml file. Just as there is a DEFAULT_AUDIO string, giving the path to a default image to use when playing audio, one can also specify DEFAULT_VIDEO image. So, one could set both to images copied from, say, a Kodi skin, if desired.