rndusr / torf

Python module to create, parse and edit torrent files and magnet links
GNU General Public License v3.0
180 stars 17 forks source link

wrong infohash #18

Closed ayasechan closed 4 years ago

ayasechan commented 4 years ago

the torrent file can download from https://nyaa.si/view/1284768

torf package version is 3.1.1

the infohash using torf is 95f3619484546e6735b0837e58d003cd0c93775f but the correct value is fb8899e9faff4c0682fec40b0446cfbccbbbed18

ayasechan commented 4 years ago

After modifying the decode_valuefunction of the _utils.py file as follows, I got the correct value

def decode_value(value):
    if isinstance(value, collections.abc.ByteString):
        try:
            return bytes.decode(value, encoding='utf-8', errors='strict')
        except UnicodeDecodeError:
            return value
    elif isinstance(value, collections.abc.Sequence):
        return decode_list(value)
    elif isinstance(value, collections.abc.Mapping):
        return decode_dict(value)
    else:
        return value
rndusr commented 4 years ago

Thank you for debugging this!

I made a new release with your fix.