Terrance / SkPy

An unofficial Python library for interacting with the Skype HTTP API.
https://skpy.t.allofti.me
BSD 3-Clause "New" or "Revised" License
262 stars 66 forks source link

409 error when try to get skype staticfiles (emotions) #268

Closed mihalt closed 1 month ago

mihalt commented 1 month ago

Before we start...

Summary

When I call SkypeUtils.static["items"], I get SkypeApiException with 409 error

That's how the link is looks like in browser from loggined account изображение

Code sample

SkypeUtils.static["items"]

Code output

Traceback (most recent call last):
2024-08-10T12:42:28.759916343Z   File "/code/manage.py", line 24, in <module>
2024-08-10T12:42:28.762766161Z     main()
2024-08-10T12:42:28.762796662Z   File "/code/manage.py", line 20, in main
2024-08-10T12:42:28.765946893Z     execute_from_command_line(sys.argv)
2024-08-10T12:42:28.765989494Z   File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 442, in execute_from_command_line
2024-08-10T12:42:28.766167802Z     utility.execute()
2024-08-10T12:42:28.766184102Z   File "/usr/local/lib/python3.10/site-packages/django/core/management/__init__.py", line 436, in execute
2024-08-10T12:42:28.766399611Z     self.fetch_command(subcommand).run_from_argv(self.argv)
2024-08-10T12:42:28.766412212Z   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 413, in run_from_argv
2024-08-10T12:42:28.766581819Z     self.execute(*args, **cmd_options)
2024-08-10T12:42:28.766609720Z   File "/usr/local/lib/python3.10/site-packages/django/core/management/base.py", line 459, in execute
2024-08-10T12:42:28.766668022Z     output = self.handle(*args, **options)
2024-08-10T12:42:28.766681023Z   File "/code/communications/management/commands/update_emotions.py", line 15, in handle
2024-08-10T12:42:28.773220293Z     for item in SkypeUtils.static["items"]:
2024-08-10T12:42:28.773247795Z   File "/usr/local/lib/python3.10/site-packages/skpy/util.py", line 91, in __get__
2024-08-10T12:42:28.773361899Z     return self.fget.__get__(None, owner)()
2024-08-10T12:42:28.773374900Z   File "/usr/local/lib/python3.10/site-packages/skpy/util.py", line 227, in wrapper
2024-08-10T12:42:28.773394301Z     cache[key] = fn(*args, **kwargs)
2024-08-10T12:42:28.773400501Z   File "/usr/local/lib/python3.10/site-packages/skpy/util.py", line 277, in static
2024-08-10T12:42:28.773655111Z     return SkypeConnection.externalCall("GET", json.get("pes_config")).json()
2024-08-10T12:42:28.773665412Z   File "/usr/local/lib/python3.10/site-packages/skpy/conn.py", line 123, in externalCall
2024-08-10T12:42:28.773669612Z     raise SkypeApiException("{0} response from {1} {2}".format(resp.status_code, method, url), resp)
2024-08-10T12:42:28.773810018Z skpy.core.SkypeApiException: ('409 response from GET https://static-asm.secure.skypeassets.com/pes/v1/configs/{some_id_here}/views/default', <Response [409]>)

Explain your code

call static

SkPy version

0.10.7

Python version

3.10

Anything else?

No response

Terrance commented 1 month ago

It looks like Skype for Web doesn't make that call any more -- I'm guessing they've transitioned to a list of emoticons built into the JavaScript code instead. There does seem to be an endpoint to look up individual emoticons (e.g. here for (hi)), but I can't see a way to get a list of them any more.

mihalt commented 1 month ago

It looks like Skype for Web doesn't make that call any more -- I'm guessing they've transitioned to a list of emoticons built into the JavaScript code instead. There does seem to be an endpoint to look up individual emoticons (e.g. here for (hi)), but I can't see a way to get a list of them any more.

oh, not good. So, do I understand correct that the only way to get full old emotions ids is to fetch saved from my old database? And get a peacture of each of them separately through its api?

Do you have this ids list? Or should I send you?

Terrance commented 1 month ago

Note that the list of emoticons SkPy fetched was an old (and likely incomplete) list in any case, probably due to requesting against a fake version 0.0.0.0. If you have a cached copy of the static data then you can continue to use it for your own lookups -- I don't think I want to ship a copy with SkPy though as everything else is currently retrieved directly from Skype servers.

There is a support page with the "full list" of all emoticons, which looks like it might actually live up to its name (it includes all the hidden ones too), so you could probably parse those tables into an updated list, though the IDs aren't there. In most if not all cases, the ID should be one of the shortcuts, but when there are multiple you'll have to figure out which one it is.

mihalt commented 1 month ago

There is a support page with the "full list" of all emoticons, which looks like it might actually live up to its name (it includes all the hidden ones too), so you could probably parse those tables into an updated list, though the IDs aren't there. In most if not all cases, the ID should be one of the shortcuts, but when there are multiple you'll have to figure out which one it is.

Yes, not all. For example "Grinning face with big eyes". Its id "grinningfacewithbigeyes" doesn't match with skype url. It would be really nice to have any built-in possibility of getting fresh emotions. Or at least to be able to use previous old with mock or something like that.

Can you also maybe create any built-in api to use previously mentioned https://static-asm.secure.skypeassets.com/pes/v1/emoticons/hi/views/meta.en-GB too?

Terrance commented 1 month ago

https://static-asm.secure.skypeassets.com/pes/v1/configs/4b4a007d331244a1ab2e45457708c8b7/views/default

Has the static endpoint just started working again? SkypeUtils.static requests a config file which gives this static URL and which seems to be working as before. A temporary issue perhaps?

mihalt commented 1 month ago

Indeed, it woks now, ahaha. It's a luck when problem is resolving by itself. Thank's for your attention!