edit4ever / script.module.tvh2kodi

Kodi interface for TVheadend setup
GNU General Public License v3.0
11 stars 9 forks source link

Could this link be broken causing tvh2kodi to fail? #6

Open guezmo opened 2 years ago

guezmo commented 2 years ago

https://github.com/edit4ever/script.module.tvh2kodi/blob/63e2fd9d792935c07c3ef7e659b92d62d639b7b1/picons.py#L36

url_latest = 'http://cvh.libreelec.tv/picons/latest2.json'

I am unable to locate that link

2022-03-19 21:58:42.266 T:1478    ERROR <general>: EXCEPTION Thrown (PythonToCppException) : -->Python callback/script returned the following error<--
                                                    - NOTE: IGNORING THIS CAN LEAD TO MEMORY LEAKS!
                                                   Error Type: <class 'urllib.error.HTTPError'>
                                                   Error Contents: HTTP Error 404: Not Found
                                                   Traceback (most recent call last):
                                                     File "/storage/.kodi/addons/script.module.tvh2kodi/default.py", line 37, in <module>
                                                       import picons
                                                     File "/storage/.kodi/addons/script.module.tvh2kodi/picons.py", line 37, in <module>
                                                       latest_json = urllib.request.urlopen(url_latest)
                                                     File "/usr/lib/python3.8/urllib/request.py", line 222, in urlopen
                                                     File "/usr/lib/python3.8/urllib/request.py", line 531, in open
cappa758 commented 2 years ago

I experimented the same issue too. Removing the call to the URL let the add-on start, but if you try with other functions (e.g. scan for new channels) python fails on another function call, saying it accepts two parameters, while three are being passed.

guezmo commented 2 years ago

Thanks... I just edited /storage/.kodi/addons/script.module.tvh2kodi/resources/settings.xml to fit in user and password (assumes no security concerns... etc).

I tried what you mentioned above:

url_latest = None  
#latest_json = urllib.request.urlopen(url_latest) 
latest_json = None 

this url seems to be forbidden: http://127.0.0.1:9981/api/status/connections, though from another machine on the network I could grab it.

On the librelec host running my tvh, I used wget http://127.0.0.1:9981/api/status/connections as a test command and worked on tvh user accounts permissions/configuration (I also made at least temporarily a wild card account). Need to revisit this part to articulate what I did.

I now have the tvh2kodi moving forward with more menus.

'Scan for new channels' does seem to break , like cappa758 said with same or similar log message.

Reducing the below to two arguments (in /storage/.kodi/addons/script.module.tvh2kodi/default.py) seems to solve things, at least for this part. pDialog.update(int(update_scan_perc), "Scanning: " + str(stream_freq) , "New services found: " + str(update_serv_num)) Change to > pDialog.update(int(update_scan_perc), "Scanning: " + str(stream_freq) + " New services found: " + str(update_serv_num))

not sure if versions match ( or I am looking at official documentation), but looked up API via google and saw two args specified for pDialog.update so gave it a try.

cappa758 commented 2 years ago

Changed the code also for the pDialog.update, but the addon is still failing when reaching the end of new channel scan. Moreover I don't know why, but I am not able to see any label in the plug-in configuration section.

guezmo commented 2 years ago

I had to change this line also and remove the third argument (append the two strings all as 2nd argument). It depends on versions of the libraries I guess, but in this case, other than cosmetic, two arguments I think would work for older and newer libraries. dialog.ok('Scanning complete.', "New services found: " + str(update_serv_num), "There are no new services to map to channels.") change to (note I did not check for typo errors) -> dialog.ok('Scanning complete.', "New services found: " + str(update_serv_num) + " There are no new services to map to channels.")

This one too needs to be changed to two args... dialog.ok("Channel mapping complete.", str(map_ok_num) + " new channels added.", str(map_ignore_num) + " services ignored.", str(map_fail_num) + " services failed."

There may be some other dialog quirks due to library changes, but I was able to run with the above. I think some others may need modification (I forgot), though not doing so did not prevent me from running.

I too have the config problem you write about. I was able to get by without doing any configuration for the module, and/or edited /storage/.kodi/addons/script.module.tvh2kodi/resources/settings.xml myself.

I don't know of course other places that may need edits, but I was able to use the functionality I did with these temporary hacks.

I think I see the following changes for kodi dev 19, 20 as it pertains to the areas of code I reviewed for 'ok' and 'Progress Update' (I am not very experienced on this platform).

Function: xbmcgui.Dialog().ok(heading, message)
OK dialog

The functions permit the call of a dialog of information, a confirmation of the user by press from OK required.

Parameters
    heading string or unicode - dialog heading.
    message string or unicode - message text.

Returns
    Returns True if 'Ok' was pressed, else False.

v19 Python API changes:

    Renamed option line1 to message.
    Removed option line2.
    Removed option line3.
◆ update()
update  (       ... )   

Function: xbmcgui.DialogProgress().update(percent[, message])
Updates the progress dialog.

Parameters
    percent integer - percent complete. (0:100)
    message [opt] string or unicode - message text.

v19 Python API changes:
    Renamed option line1 to message.
    Removed option line2.
    Removed option line3.

Example:
pDialog.update(25, 'Importing modules...')

Using a google search I found this here, though maybe a more official link is available . https://alwinesch.github.io/group__python___dialog_progress.html#ga6bfa818f28a3ff9fbe3ea0bb71c64476 (note this link points to v20, not v19, but I see the v19 changes documented)

cappa758 commented 2 years ago

Hi guezmo, thanks for the insights. I updated all the dialog in the code to reflect the new specifications of Kodi 19. Moreover I have been able to find also the cause why the settings do not show any label. Support for string.xml file has been removed from Kodi 19, passing to strings.po. https://kodi.wiki/view/Language_support

edit4ever commented 2 years ago

Thanks all for continuing to keep this one alive. I haven't chimed in as I don't have time to work on this project any longer - but it could use a rewrite for the changes in Kodi 19 as well as changes that have likely happened in TVheadend.

It's just using the webui api to get info from TVH and display that info as dialogs in Kodi - so it can be a great project for someone learning. Or there are likely better ways to implement what I did here as it was one of my early learning projects.

Hope it at least helps some folks!

guezmo commented 6 days ago

I started a branch of a fork to work on this and did some minimal edits. I considered a merge request to here but see below.

Most things are working for me but...

The back end dialog box is mixed up (I don't need it right now, but it should probably work better) The "rerun internal grabber" in the EPG Modules section has issues.

Here are the edits:

https://github.com/guezmo/script.module.tvh2kodi/tree/libreelec12_0_1