adameste / anidbcli

AniDB UDP API client written in Python
MIT License
34 stars 8 forks source link

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 1398: invalid continuation byte when downloading info #14

Closed msdos closed 4 years ago

msdos commented 4 years ago

The error was just [ERROR] Failed to get file info: 'utf-8' codec can't decode byte 0xd1 in position 1398: invalid continuation byte when trying to get information from a file. So I removed the try except from operations.py, printed ret variable and now have a full traceback:

[INFO] Processing file "Gurren Lagann [Dual Audio] [BD 1080p] Episode 08.mkv"
[SUCCESS] Generated ed2k link.
b"220 FILE\n1426430|4575|73552|0|0|4096|958797008|5b4ba917f9ee4b4be4ed42e45c2d8307|05f196849d408479f888c42ce0532205|86c379bcf8de54c489b115de18594dfdb5792a1b|8b9ddd6b||very high|Blu-ray|FLAC'(HE-)AAC|1504'202|H264/AVC|3521|1920x1080|mkv|japanese'english|english'english|1461|1179619200|Tengen Toppa Gurren Lagann - 08 - Farewell Comrades! - [RAW](8b9ddd6b).mkv|27|27|2007-2007|TV Series|Transforming Robot,Future,Sci-Fi,Mecha,Plot Continuity,Shounen,Earth,Action,Piloted Robot,New,Post-apocalypse,Comedy,General Lack of Common Sense,Alien,Humanoid Alien,Adventure,Skimpy Clothing,Tragedy,Space,Slapstick,Desert,Calling Your Attacks,Shipboard,Anthropomorphism,Boobs in Your Face,Angst,Politics,Romance,Ecchi,Violence,Boing,Space Travel,Large Breasts,Moon,Nosebleed,Lethal Cooking,Parody,Nudity,Pantsu|Tengen Toppa Gurren Lagann|\xe5\xa4\xa9\xe5\x85\x83\xe7\xaa\x81\xe7\xa0\xb4 \xe3\x82\xb0\xe3\x83\xac\xe3\x83\xb3\xe3\x83\xa9\xe3\x82\xac\xe3\x83\xb3|Gurren Lagann|\xe5\xa4\xa9\xe5\x85\x83\xe7\xaa\x81\xe7\xa0\xb4 \xe3\x82\xb0\xe3\x83\xac\xe3\x83\xb3\xe3\x83\xa9\xe3\x82\xac\xe3\x83\xb3'Gurren Lagann'Sfondamento dei Cieli Gurren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93\xd1\x83\xd1\x80\xd1\x80\xd0\xb5\xd0\xbd \xd0\x9b\xd0\xb0\xd0\xb3\xd0\xb0\xd0\xbd\xd0\xbd - \xd0\xbf\xd1\x80\xd0\xbe\xd1\x87\xd1\x8c \xd0\xb8\xd0\xb7 \xd1\x8d\xd1\x82\xd0\xbe\xd0\xb3\xd0\xbe \xd0\xbc\xd0\xb8\xd1\x80\xd0\xb0'Poko\xc5\x99itel nebes Gurren-Lagann'Gurren-Lagann'\xd2\x90\xd1\n\x08\x08\x08\x08\x08\x08\x08\x08"
Traceback (most recent call last):
  File "/usr/local/bin/anidbcli", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/anidbcli/cli.py", line 139, in main
    cli(obj={})
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.5/dist-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/usr/local/lib/python3.5/dist-packages/anidbcli/cli.py", line 84, in api
    res = operation.Process(file_obj)
  File "/usr/local/lib/python3.5/dist-packages/anidbcli/operations.py", line 71, in Process
    res = self.connector.send_request(API_ENDPOINT_FILE % (file["size"], file["ed2k"]))
  File "/usr/local/lib/python3.5/dist-packages/anidbcli/anidbconnector.py", line 117, in send_request
    res = self.crypto.Decrypt(res)
  File "/usr/local/lib/python3.5/dist-packages/anidbcli/encryptors.py", line 32, in Decrypt
    ret = ret.decode("utf-8")
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xd1 in position 1398: invalid continuation byte
adameste commented 4 years ago

Ah, finally encoutered that error myself, will look into it

adameste commented 4 years ago

Debugged, fixed. in 1.54. Ignoring utf-8 decoding errors. The output seemed fine even with the errors ignored. Probably some bad characters contained in string, possibly characters unknown to python.