UncleGoogle / galaxy-integration-humblebundle

Humble Bundle integration for GOG Galaxy 2.0
GNU General Public License v3.0
187 stars 18 forks source link

Paused Humble Choice: previous Humble Choice month are not visible/imported #146

Closed nosyn00b closed 3 years ago

nosyn00b commented 3 years ago

It seems that Humble Choice games before last "paused month" are not imported.

I have been an HB subscriber of Humble Choice with an annual plan from some time now (and I paused the HB subscription many times) . In configuration/settings dialog all Humble Choice months before the last paused month do not show, and relative games are not imported.

For example, in my case the July Humble Choice is not shown (I paused Subscription in August) and games in July humble choice games are not imported. Even all other previus Humble choice months are not seen in settings and relative games imported.

Plugin was installed directly from Galaxy

Logs do not report anything about the Missing Humble Choice months, for example:

2021-01-20 01:23:25,796 - galaxy.task_manager - DEBUG - Task manager jsonrpc server: finished task 21 (start_subscription_games_import) 2021-01-20 01:23:25,796 - root - DEBUG - GET, https://www.humblebundle.com/subscription/december-2020, (), {} 2021-01-20 01:23:25,798 - root - DEBUG - GET, https://www.humblebundle.com/subscription/november-2020, (), {} 2021-01-20 01:23:25,799 - root - DEBUG - GET, https://www.humblebundle.com/subscription/october-2020, (), {} 2021-01-20 01:23:25,800 - root - DEBUG - GET, https://www.humblebundle.com/subscription/september-2020, (), {} 2021-01-20 01:23:25,802 - root - DEBUG - GET, https://www.humblebundle.com/subscription/january-2021, (), {}

Having paused August, where is July, and previuous subscribed months?

UncleGoogle commented 3 years ago

Valid point.

I've prematurely assumed I can use "isChoiceTier" field https://github.com/UncleGoogle/galaxy-integration-humblebundle/blob/master/src/webservice.py#L117

to distinguish humble Choice and Monthly. As a side effect generator stops there - assumed if there is Humble Monthly, then no more Humble Choice months.

Apparently, if you don't unlock specific month (like a pause), then it still comes from API response but without most of fields. I think we can use 'gamekey' field presence to distinguish unlocked months.

I'll do the fix in spare time, but as it may not be very quickly, PR is welcomed as well.

UncleGoogle commented 3 years ago

@nosyn00b could you find your August and for example July subscirption in humble API here? How the json looks like?

https://www.humblebundle.com/api/v1/subscriptions/humble_monthly/subscription_products_with_gamekeys/

just iterate back in time using cursor like

https://www.humblebundle.com/api/v1/subscriptions/humble_monthly/subscription_products_with_gamekeys/CnwKEgoFc3RhcnQSCQiAiJ3IyInrAhJiahFzfmhyLWh1bWJsZWJ1bmRsZXJNCxIMTW9kZWxQb2ludGVyIidQcm9kdWN0LW1hY2hpbmVfbmFtZS1hdWd1c3RfMjAyMF9jaG9pY2UMCxIHUHJvZHVjdBiAgKStu-HiCQwYACAB

(each time changing cursor from previous query

UncleGoogle commented 3 years ago

@nosyn00b please try patch.zip

replace those 2 files in %localappdata%\GOG.com\Galaxy\plugins\installed\humble-f0ca3d80-a432-4d35-a9e3-60f27161ac3

attach plugin logs if still does not work.

nosyn00b commented 3 years ago

I had a quick try (I cannot indagate now), but currently I do not see the subscritptions even in the setting dialog, as happened before applying the patch, so perhaps i did not even get to what was patched :-)

image

The last time I had such situation, to make subscriptions re-appear I had to uninstall the plugin removing it completly, to restart, then reinstalling and finally restarting ....

Anyway, this error shows in logs while calling the subscription API:

2021-01-30 00:03:32,672 - root - DEBUG - GET, https://www.humblebundle.com/api/v1/subscriptions/humble_monthly/subscription_products_with_gamekeys/, (), {} 2021-01-30 00:03:34,807 - galaxy.api.jsonrpc - ERROR - Unexpected exception raised in plugin handler [....] \AppData\Local\GOG.com\Galaxy\plugins\installed\humble_f0ca3d80-a432-4d35-a9e3-60f27161ac3a\plugin.py", line 206, in get_subscriptions self._normalize_subscription_name(product.product_machine_name), AttributeError: 'dict' object has no attribute 'product_machine_name'

UncleGoogle commented 3 years ago

Ah, forgot to test. Change

self._normalize_subscription_name(product.product_machine_name), to self._normalize_subscription_name(product['productMachineName'])

in plugin.py

nosyn00b commented 3 years ago

Ok, I changed that, but I get another error: somehow the code comes to a cursor position that gives a 404 error

2021-01-30 09:47:01,252 - galaxy.http - WARNING - Got status 404 while performing GET request for https://www.humblebundle.com/api/v1/subscriptions/humble_monthly/subscription_products_with_gamekeys/Cn8KEgo...

And that url really gives a 404 also testing it with a browser.

I went back with the cursor query by query as you explained trying to understand when it happens with the goal to give you proper feedback, but I came where there are only Humble Bundle without getting errors: do you read also through old Humble Bundle's nodes?

Regarding the logic for understanding if an Humble Choice was paused, here in the image is the Agust json: the Choice month really is returned even if suspended.

image

Some check on unlockedContentEvents node presence may be useful/semanticly correct to understand if it was unlocked.

Ragarding the logic to understand if the node is an Humble Bundle or an Humble Choice the flag isChoiceTier seems quite a good choice also to me. Perhapse also the presence of the contentCoicheData could do (and many others), because json structure of Humble Bundles is so different!

UncleGoogle commented 3 years ago

I was using isChoiceTier primarily, but as you see there is no such node in case of paused Choice month.

contentChoiceData - yup seems legit for Choice, should be always there, MAX_CHOICES too which value depends on sub plan I guess.

unlockedContentEvents - I think you suggestion is correct as well, but I'm not 100% sure it is safe to use - maybe there can be other type of "events", not only about selecting specific choice month. I've already seen other "events" in that list, but usually unlocked choice month event was there as well.


I'll use gamekey as indicator of unlocked month and contentChoiceData as indicator of choice type of subscription. BTW don't worry about privacy - it is just an id related to your account and nobody can use it.

WARNING - Got status 404 while performing GET request for

eh, more bugs. I've added some unit tests; fixed version #148 build.zip

nosyn00b commented 3 years ago

Thx UG, I was eager to try, but using the non FOG version, and also forking from your repository I get this error while the plugin is starting

import sentry_sdk
ModuleNotFoundError: No module named 'sentry_sdk'

Using VS Code and pointing to the integrated Phyton version, sentry_sdk is resolved, but no way to make that work within galaxy :-(. Any suggestion?

UncleGoogle commented 3 years ago

You can use the ready build attached in my previous comment. Closing Galaxy first of course

If you want yo build yourself, follow instructions from readme https://github.com/UncleGoogle/galaxy-integration-humblebundle#from-source

One more comment: it may be required to reconnect plugin if previous version has error during getting subscripions - Galaxy may no longer ask for in in such case

nosyn00b commented 3 years ago

I tried both

Using your build the plugin crashes but the log file is simply not updated, so I don't know what is happening!

I also already tried from scratch from the sources, but there are so many "red errors" while getting dependencies (perhaps also a C compiler is needed?) that I have to look at it when I have a loooooot of time....

Sorry, but I cannot help testing the fix at the moment :-(. I'm stuck!

UncleGoogle commented 3 years ago

I can help, lets move on discord priv

UncleGoogle commented 3 years ago

You can also just download it via Galaxy, and then replace files that were changed in the PR above. No dependnecies were changed so it should work w/o problems.

nosyn00b commented 3 years ago

I tried to do that for the n-th time and finally plugin did not crashed. Subscriptions also workd as expected. I finally can confirm this issue is solved! Thankyou so much!