xuzhengyi1995 / Renta_Downloader

Download manga you rent from http://renta.papy.co.jp/
50 stars 16 forks source link

Exception: Unknown encoding #8

Closed sabydjuli closed 3 years ago

sabydjuli commented 3 years ago

I've used the code multiple times before this without issue, but today I tried to use it and got the following error despite doing the same as before...

Traceback (most recent call last): File "xx", line 125, in get_download_info data = org_data.decode('utf-8') UnicodeDecodeError: 'utf-8' codec can't decode byte 0x8b in position 1: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "xx", line 128, in get_download_info data = org_data.decode('EUC-JP') UnicodeDecodeError: 'euc_jp' codec can't decode byte 0x8b in position 1: illegal multibyte sequence

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "xx", line 307, in start_download(url) File "xx", line 97, in start_download download_info = get_download_info(url) File "xx", line 130, in get_download_info raise Exception('Unknow encoding.') Exception: Unknow encoding.

Any help would be much appreciated, thank you!

persia7emily commented 3 years ago

begin from line 119, change it like this

org_data = getter.get()
try:
    **thisdata** = gzip.decompress(org_data)
except:
    **thisdata** = org_data

try:
    data = **thisdata**.decode('utf-8')
except:
    try:
        data = **thisdata**.decode('euc-jp')
    except:
        raise Exception('Unknown encoding.')
persia7emily commented 3 years ago

no **

sabydjuli commented 3 years ago

Thank you @persia7emily for the solution, it works perfectly now!