Dis90 / plugin.video.discoveryplus

discovery+ add-on for Kodi
65 stars 13 forks source link

Repeatedly enter Home menu with error #92

Closed Liqianyu closed 1 year ago

Liqianyu commented 1 year ago

Every time you enter the add-on, no error is reported when you enter the Home menu for the first time. However, Kodi will report an error if you return to the add-on's Home screen and enter it again. Kodi Log

Dis90 commented 1 year ago

Does other menus work, my list etc? Is it just home menu what is broken?

Liqianyu commented 1 year ago

@Dis90 My version of Kodi is kodi 21 omega Nightlies Other menus (e.g. Browse, My List) don't have this problem. This is a somewhat strange and annoying problem that doesn't always occur, but the odds are not bad.

By the way, if you click Search but OK without entering anything, this can get Kodi stuck. Maybe it could be in the code to prevent blank searches?

Dis90 commented 1 year ago

Kodi 21 is not currently tested/supported. Can you test with Kodi 20? If I remember correctly list views in Kodi 21 needs change in addon.

By the way, if you click Search but OK without entering anything, this can get Kodi stuck. Maybe it could be in the code to prevent blank searches?

Thanks for reporting. You are right there should be check for preventing search without search term. Edit. There's already check for this situation and works on Kodi 20. Maybe Kodi 21 problem?

Kodi 21 is currently in alpha stage. I will make required modifications to addon code at some point. Hopefully I don't have to make own repository for it.

Dis90 commented 1 year ago

I just tested with Kodi 21 and everything works. Can you login d+ in browser and then open page https://us1-prod-direct.discoveryplus.com/cms/routes/tabbed-home and save it to file and post it here so I can investigate why it fails.

Liqianyu commented 1 year ago

Ok, but is this URL correct? The browser returns the following { "errors" : [ { "status" : "400", "code" : "invalid.parameter", "id" : "8LipnrQpca", "detail" : "parameter 'include' must be set to 'default'" } ] }

The developer tool displays the request URL as https://us1-prod-direct.discoveryplus.com/cms/routes/tabbed-home?include=default&decorators=viewingHistory,isFavorite,playbackAllowed,badges The browser returns the following https://paste.kodi.tv/uhehoducuv

I also tried https://us1-prod-direct.discoveryplus.com/cms/routes/tabbed-home?include=default The browser returns the following https://paste.kodi.tv/imesukujef

By the way, my Profiles names are blank (special) characters. I don't know if this is causing an exception. I tested using another profile and the problem remained the same. Also I tested on Kodi 20.1 and had the same problem.

Dis90 commented 1 year ago

Sorry I forgot all parameters :D Can you give example of profile name which is not displayed?

Liqianyu commented 1 year ago

I tried to change the profile to normal characters. The problem still happens, the special character I used before is https://www.compart.com/en/unicode/U+3164

This should have nothing to do with the other profile names that I am not using right?

Dis90 commented 1 year ago

In developer tools find file called profiles. Is profiles listed like this:

    "attributes" : {
      "avatarName" : "2",
      "isDefault" : false,
      "isDeletable" : true,
      "pinRestricted" : true,
      "preferredLanguageTags" : [ ],
      "profileName" : "Testi"
Liqianyu commented 1 year ago

"attributes" : { "avatarName" : "", "brandId" : "dplus", "isDefault" : false, "isDeletable" : true, "pinRestricted" : true, "preferredLanguageTags" : [ ], "profileName" : "DSCP" }, Other profiles have "ageRestricted" : false in the line above the avatarName.

Dis90 commented 1 year ago

Okay that is same. So no reason for why profile names are not displayed.

I have age restricted profiles like this

    "attributes" : {
      "ageRestricted" : true,
      "avatarName" : "",
      "contentRestrictionLevelId" : "restriction_level_3",
      "isDefault" : false,
      "isDeletable" : true,
      "preferredLanguageTags" : [ ],
      "profileName" : "Testi2"
    },
    "id" : "PROFILEID4-x",
    "relationships" : {
      "contentRestrictionLevel" : {
        "data" : {
          "id" : "restriction_level_3",
          "type" : "contentRestrictionLevel"
        }
      }
    },
    "type" : "profile"

Have you tried different device?

Liqianyu commented 1 year ago

I haven't tested it with other devices and the problem is a bit strange. Because it always happens when returning to the main menu and entering again. And sometimes it takes multiple times. Maybe Kodi is not clearing some values? Or is this something to do with the web server itself?

The issue is just a bit annoying and doesn't affect usage, so I think I can leave the issue open for now and observe further.

Dis90 commented 1 year ago

The developer tool displays the request URL as https://us1-prod-direct.discoveryplus.com/cms/routes/tabbed-home?include=default&decorators=viewingHistory,isFavorite,playbackAllowed,badges The browser returns the following https://paste.kodi.tv/uhehoducuv

I also tried https://us1-prod-direct.discoveryplus.com/cms/routes/tabbed-home?include=default The browser returns the following https://paste.kodi.tv/imesukujef

Sorry but I didn't found any reason why Home is not listed correctly for you but can you try following. In addon.py replace this:

                                        next_page_path = [x['attributes']['url'] for x in routes if
                                                          x['id'] == taxonomyNode['relationships']['routes']['data'][0]['id']][0]

                                        plugin_url = plugin.url_for(list_page, next_page_path)

                                        folder_name = page['attributes'].get('pageMetadataTitle')

                                        helper.add_item(taxonomyNode['attributes']['name'], url=plugin_url)

With this:

                                        if taxonomyNode.get('relationships'):
                                            next_page_path = [x['attributes']['url'] for x in routes if
                                                              x['id'] == taxonomyNode['relationships']['routes']['data'][0]['id']][0]

                                            plugin_url = plugin.url_for(list_page, next_page_path)

                                            folder_name = page['attributes'].get('pageMetadataTitle')

                                            helper.add_item(taxonomyNode['attributes']['name'], url=plugin_url)
Liqianyu commented 1 year ago

Replacing the corresponding code in addon.py successfully fixed the issue. I think the Home menu is loading faster. Well done!

Dis90 commented 1 year ago

I haven't tested it with other devices and the problem is a bit strange. Because it always happens when returning to the main menu and entering again. And sometimes it takes multiple times. Maybe Kodi is not clearing some values? Or is this something to do with the web server itself?

The issue is just a bit annoying and doesn't affect usage, so I think I can leave the issue open for now and observe further.

It is possible that problem is Kodi itself or Discovery API returning invalid data sometimes. Log says that relationships are missing in taxonomyNode. Some other listings there are categories which doesn't have any content. Maybe this is something similar.

Dis90 commented 1 year ago

Can you post complete profiles file? Hide any possible personal data :)

Liqianyu commented 1 year ago

https://us1-prod-direct.discoveryplus.com/users/me/profiles

{ "data" : [ { "attributes" : { "ageRestricted" : false, "avatarName" : "5", "brandId" : "dplus", "isDefault" : false, "isDeletable" : true, "pinRestricted" : true, "preferredLanguageTags" : [ ], "profileName" : "1" }, "id" : "PROFILEID00000000-0000-0000-0000-000000000000", "type" : "profile" }, { "attributes" : { "avatarName" : "6", "brandId" : "dplus", "isDefault" : true, "isDeletable" : false, "isPreview" : false, "pinRestricted" : true, "preferredLanguageTags" : [ ], "profileName" : "2" }, "id" : "PROFILEID00000000-0000-0000-0000-000000000000", "type" : "profile" }, { "attributes" : { "ageRestricted" : false, "avatarName" : "4", "brandId" : "dplus", "isDefault" : false, "isDeletable" : true, "pinRestricted" : true, "preferredLanguageTags" : [ ], "profileName" : "3" }, "id" : "PROFILEID00000000-0000-0000-0000-000000000000", "type" : "profile" }, { "attributes" : { "avatarName" : "", "brandId" : "dplus", "isDefault" : false, "isDeletable" : true, "pinRestricted" : true, "preferredLanguageTags" : [ ], "profileName" : "4" }, "id" : "PROFILEID00000000-0000-0000-0000-000000000000", "type" : "profile" }, { "attributes" : { "ageRestricted" : false, "avatarName" : "2", "brandId" : "dplus", "isDefault" : false, "isDeletable" : true, "pinRestricted" : true, "preferredLanguageTags" : [ ], "profileName" : "5" }, "id" : "PROFILEID00000000-0000-0000-0000-000000000000", "type" : "profile" } ], "meta" : { "site" : { "attributes" : { "brand" : "dplus_us", "brandId" : "dplus", "mainTerritoryCode" : "us", "theme" : "dplus_us", "websiteHostName" : "" }, "id" : "dplus_us", "type" : "site" } } }

Dis90 commented 1 year ago

Thanks. Can you make one profile age restricted?

Dis90 commented 1 year ago

By the way what skin you're using? Maybe profile names missing is skin issue.

Liqianyu commented 1 year ago

By the way what skin you're using? Maybe profile names missing is skin issue.

I don't think it's a mistake to not show the profile username. Because, that is a special blank character.

Dis90 commented 1 year ago

Okay. Can you post screenshot?

Liqianyu commented 1 year ago

Profiles Other Profiles can be displayed normally, just mosaic.

Dis90 commented 1 year ago

Please try with Estuary skin.

Liqianyu commented 1 year ago

I have tried it with the same result, but Estuary can correctly display the countdown bar with the numeric code at login. Have you fixed the empty search issue?

Liqianyu commented 1 year ago

@Dis90 I checked the log when empty query. There is a display of "No search query provided." but Kodi is stuck in constant loading.

Dis90 commented 1 year ago

Works correctly for me but I try to make some changes after weekend.

Dis90 commented 1 year ago

@Liqianyu Can you try replace this line https://github.com/Dis90/plugin.video.discoveryplus/blob/5d614929b2fee5323edae6d191ba788c8e74be4e/resources/lib/addon.py#L1503 with this:

return helper.dialog('ok', helper.language(30006), 'No search query provided.')

Liqianyu commented 1 year ago

@Dis90 A pop-up window displays an error, No search query provided. However after OK, Kodi is stuck in loading.

Dis90 commented 1 year ago

@Liqianyu Could you try on another device? I am unable to reproduce the problem on two different devices. Also debug log would be nice.

Liqianyu commented 1 year ago

@Dis90 Another device ? Does that mean non-Android ? I will check this issue. I tried a fresh install of Kodi 20.1 Windows and it got the same result.

2023-06-13 00:15:59.223 T:17976 debug : CGUIMediaWindow::GetDirectory (plugin://plugin.video.discoveryplus/search) 2023-06-13 00:15:59.223 T:17976 debug : ParentPath = [plugin://plugin.video.discoveryplus/] 2023-06-13 00:15:59.224 T:18208 debug : Thread waiting start, auto delete: false 2023-06-13 00:15:59.224 T:18208 debug : CScriptRunner: running add-on script discovery+('plugin://plugin.video.discoveryplus/search', '4', '') 2023-06-13 00:15:59.224 T:18208 debug : CScriptInvocationManager::GetLanguageInvoker - Reusing LanguageInvokerThread 5 for script C:\Users\Users\AppData\Roaming\Kodi\addons\plugin.video.discoveryplus\default.py 2023-06-13 00:15:59.225 T:20360 debug : initializing python engine. 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5, C:\Users\Users\AppData\Roaming\Kodi\addons\plugin.video.discoveryplus\default.py): start processing 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5): adding args: 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5): plugin://plugin.video.discoveryplus/search 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5): 4 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5):
2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5): resume:false 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5, C:\Users\Users\AppData\Roaming\Kodi\addons\plugin.video.discoveryplus\default.py): entering source directory C:\Users\Users\AppData\Roaming\Kodi\addons\plugin.video.discoveryplus 2023-06-13 00:15:59.225 T:20360 debug : CPythonInvoker(5, C:\Users\Users\AppData\Roaming\Kodi\addons\plugin.video.discoveryplus\default.py): instantiating addon using automatically obtained id of "plugin.video.discoveryplus" dependent on version 3.0.0 of the xbmc.python api 2023-06-13 00:15:59.225 T:20360 debug : [plugin.video.discoveryplus][routing] Dispatching to 'search', args: {} 2023-06-13 00:15:59.325 T:17976 debug : ------ Window Init (DialogBusy.xml) ------ 2023-06-13 00:15:59.327 T:17976 info : Loading skin file: DialogKeyboard.xml, load type: KEEP_IN_MEMORY 2023-06-13 00:15:59.337 T:17976 debug : ------ Window Init (DialogKeyboard.xml) ------

Liqianyu commented 1 year ago

@Dis90

https://github.com/Dis90/plugin.video.discoveryplus/blob/5d614929b2fee5323edae6d191ba788c8e74be4e/resources/lib/addon.py#L1503

Replacing this line with sys.exit() solved the problem for me.

Dis90 commented 1 year ago

I was finally able to reproduce this problem. Try to replace mentioned line with this helper.eod()

Liqianyu commented 1 year ago

@Dis90 I tested it and it works. It will let the add-on get empty search results. And it won't get stuck. But I think a better behavior would be to use banner hints and not go to the blank search result page.

Dis90 commented 1 year ago

Yep. I try to investigate better option. sys.exit() works but will result errors in log.

Dis90 commented 1 year ago

@Liqianyu How about this solution. Replace:

    else:
        helper.log('No search query provided.')
        return False

With this:

    else:
        helper.log('No search query provided.')
        helper.eod()
        helper.dialog('ok', helper.language(30006), 'No search query provided.')
        import xbmc
        xbmc.executebuiltin('Container.Update({0},replace)'.format(plugin.url_for(list_menu)))
Dis90 commented 1 year ago

Fixed in 1.6.25+matrix.1