Egsagon / nekosama

API for the Neko Sama anime website.
MIT License
2 stars 0 forks source link

IndexError: list index out of range, again #3

Closed ghost closed 1 year ago

ghost commented 1 year ago

Hello! I'm facing a similar issue as this one : #2 Here is the output I get when I try to download any anime :

=> Starting download!

* Downloading 1
[FRAG] Fetched provider best
Traceback (most recent call last):
  File "/home/gaslec/src/neko-sama-api/main.py", line 71, in <module>
    episode.download(path + str(episode.index) + '.mp4',
  File "/home/gaslec/.venv/lib/python3.11/site-packages/nekosama-3.1-py3.11.egg/nekosama/core.py", line 269, in download
  File "/home/gaslec/.venv/lib/python3.11/site-packages/nekosama-3.1-py3.11.egg/nekosama/core.py", line 212, in get_fragments
IndexError: list index out of range

Would be awesome if this fixable, sorry I don't know much about scraping so I couldn't find how they obfuscated the .json Thanks for this great software, have a great day.

Egsagon commented 1 year ago

Hellooo

Apparently, they didn't changed anything on the obfuscation side, but they might have finally for some reason encoded their data according to the browser choices. I currently fixed that with https://github.com/Egsagon/neko-sama-api/commit/ad34184823072f98abbee1a90b111358a6b39cb2 by removing encoding for now. Anyway, it should work fine now, just update the package with pip:

pip install -U git+https://github.com/Egsagon/neko-sama-api.git

Thanks for reporting this, have a great day too!

Egsagon commented 1 year ago

I don't know much about scraping so I couldn't find how they obfuscated the .json

Their obfuscation is really simple. Given any anime, e.g.: https://neko-sama.fr/anime/info/16800-tensei-shitara-slime-datta-ken-2nd-season-part-2_vostfr You will have an associated direct URL to its player: https://fusevideo.net/e/wgD0G79PpODMeoE Then in that player, just search for the JS file. It contains a b64 encoded json file, you just have to find it with regexes and decode it and then you got the M3U. They recentlychanged how they store the obfuscated string, that what #2 was about. In that case we just change the regex.

ghost commented 1 year ago

It's now working just fine, thanks a lot for this really quick fix! And also thanks for the time you spent to explain me what was happening, was really interesting!

Egsagon commented 1 year ago

No problem :) Have a great day!