Skip to content

problem with live channels #30

@claudeha

Description

@claudeha

Hi, I'm using latest LibreELEC minimal OS for Kodi on rpi4, but had some problems with Live Channels in this plugin/addon for tv3cat (symptom: clicking live channels in the addon ui would just display an error in the top right saying to check log). Here is a log snippet:

2022-05-28 15:35:46.000 T:10478   DEBUG <general>: plugin.video.tv3.cat classe UI - run()  mode = ['directe']
2022-05-28 15:35:46.000 T:10478   DEBUG <general>: -----------------listDirecte--------------------
2022-05-28 15:35:46.413 T:10478   ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'AttributeError'>
                                                   Error Contents: 'str' object has no attribute 'get'
                                                   Traceback (most recent call last):
                                                     File "/storage/.kodi/addons/plugin.video.tv3.cat/addon.py", line 32, in <module>
                                                       ui.run(mode, url)
                                                     File "/storage/.kodi/addons/plugin.video.tv3.cat/resources/lib/ui/UI.py", line 116, in run
                                                       lVideos = self.tv3.listDirecte()
                                                     File "/storage/.kodi/addons/plugin.video.tv3.cat/resources/lib/tv3cat/TV3cat.py", line 314, in listDirecte
                                                       nameChannel = c[i].get('ara_fem', {}).get('codi_canal', None)
                                                   AttributeError: 'str' object has no attribute 'get'
                                                   -->End of Python script error report<--

I edited plugin.video.tv3.cat/resources/lib/tv3cat/TV3cat.py to add try/except around line 314 and following, and then the error changed:

2022-05-28 15:43:37.483 T:10532   DEBUG <general>: -----------------listDirecte--------------------
2022-05-28 15:43:37.775 T:10532   ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'UnboundLocalError'>
                                                   Error Contents: local variable 'infotv3' referenced before assignment
                                                   Traceback (most recent call last):
                                                     File "/storage/.kodi/addons/plugin.video.tv3.cat/addon.py", line 32, in <module>
                                                       ui.run(mode, url)
                                                     File "/storage/.kodi/addons/plugin.video.tv3.cat/resources/lib/ui/UI.py", line 116, in run
                                                       lVideos = self.tv3.listDirecte()
                                                     File "/storage/.kodi/addons/plugin.video.tv3.cat/resources/lib/tv3cat/TV3cat.py", line 346, in listDirecte
                                                       infolabelstv3['plot'] = infotv3
                                                   UnboundLocalError: local variable 'infotv3' referenced before assignment
                                                   -->End of Python script error report<--

so I just initialized like infotv3 = 'n/a' (and the other similar variables) before the blocks where they are set/used...

Here are all the changes I made that got live Catalan TV working for me:

$ diff -u TV3cat.py.orig TV3cat.py
--- TV3cat.py.orig	2022-05-28 15:50:13.127127849 +0100
+++ TV3cat.py	2022-05-28 15:50:13.099127586 +0100
@@ -311,6 +311,7 @@
 
                 i = 0
                 while i < 5:
+                  try:
                     nameChannel = c[i].get('ara_fem', {}).get('codi_canal', None)
 
                     if nameChannel == 'tv3':
@@ -325,14 +326,16 @@
                     if nameChannel == '324':
                         arafem324 = c[i].get('ara_fem', {}).get('titol_programa', None)
                         arafem324_sinop = c[i].get('ara_fem', {}).get('sinopsi', None)
-
-                    i = i + 1
+                  except AttributeError:
+                    pass
+                  i = i + 1
 
             infolabelstv3 = {}
             infolabels324 = {}
             infolabels33 = {}
             infolabelsesp3 = {}
 
+            infotv3 = 'n/a'
             if arafemtv3:
                 infolabelstv3['title'] = arafemtv3
                 infotv3 = '[B]' + arafemtv3 + '[/B]' + '[CR]'
@@ -343,6 +346,7 @@
 
             infolabelstv3['plot'] = infotv3
 
+            info33 = 'n/a'
             if arafem33:
                 infolabels33['title'] = arafem33
                 info33 = '[B]' + arafem33 + '[/B]' + '[CR]'
@@ -353,6 +357,7 @@
 
             infolabels33['plot'] = info33
 
+            infoesp3 = 'n/a'
             if arafemesp3:
                 infolabelsesp3['title'] = arafemesp3
                 infoesp3 = '[B]' + arafemesp3 + '[/B]' + '[CR]'
@@ -363,6 +368,7 @@
 
             infolabelsesp3['plot'] = infoesp3
 
+            info324 = 'n/a'
             if arafem324:
                 infolabels324['title'] = arafem324
                 info324 = '[B]' + arafem324 + '[/B]' + '[CR]'

Thanks very much for your work on this plugin/addon, it's really appreciated. If you would prefer, I can make a pull request with the above changes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions