idlesign / torrentool

The tool to work with torrent files.
https://github.com/idlesign/torrentool
BSD 3-Clause "New" or "Revised" License
148 stars 30 forks source link

Valid torrent file trips up torrentool (and other python torrent libraries) #16

Closed Zorlin closed 3 years ago

Zorlin commented 3 years ago

Hi!

I run riff.cc and we're ingesting 1M+ torrents from archive.org at the moment.

I noticed this torrent:

https://archive.org/details/electricsheep-flock-244-72500-6

causes this error:

DEBUG/opt/radio/collections/ElectricSheep/archive.org/download/electricsheep-flock-244-45000-0/electricsheep-flock-244-45000-0_archive.torrent
Traceback (most recent call last):
  File "/Users/wings/projects/librarian/sizer.py", line 18, in <module>
    torrentstats = Torrent.from_file(os.path.join(path, name))
  File "/opt/homebrew/lib/python3.9/site-packages/torrentool/torrent.py", line 430, in from_file
    torrent = cls(Bencode.read_file(filepath, byte_keys={'pieces'}))
  File "/opt/homebrew/lib/python3.9/site-packages/torrentool/bencode.py", line 206, in read_file
    return cls.decode(contents, byte_keys=byte_keys)
  File "/opt/homebrew/lib/python3.9/site-packages/torrentool/bencode.py", line 167, in decode
    raise BencodeDecodingError(f'Unable to interpret `{char}` char.')
torrentool.exceptions.BencodeDecodingError: Unable to interpret `T` char.

but it's a valid torrent.

idlesign commented 3 years ago

Thank you for the report. I'll try to check this out this week.

Zorlin commented 3 years ago

No worries, thank you! I've switched temporarily to parsing the output of transmission-show but it's an ugly hack to do that, I'd love to just use this lib. There's no rush though :)

idlesign commented 3 years ago

Unable to reproduce using https://archive.org/download/electricsheep-flock-244-72500-6/electricsheep-flock-244-72500-6_archive.torrent

shot

Zorlin commented 3 years ago

Hi,

Sorry what specifically doesn't work is checking that torrent for total size.

On Tue, 18 May 2021, 19:13 Igor Starikov, @.***> wrote:

Unable to reproduce using https://archive.org/download/electricsheep-flock-244-72500-6/electricsheep-flock-244-72500-6_archive.torrent

[image: shot] https://user-images.githubusercontent.com/145644/118641621-93900000-b804-11eb-8094-baab86c0cb61.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/idlesign/torrentool/issues/16#issuecomment-843080539, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKONLDTM6E4ME4MMVR4CKDTOJDWHANCNFSM447UMQHQ .

Zorlin commented 3 years ago

Huh. Let me make some sample code to repro, cheers

On Tue, 18 May 2021, 19:20 Benjamin, @.***> wrote:

Hi,

Sorry what specifically doesn't work is checking that torrent for total size.

On Tue, 18 May 2021, 19:13 Igor Starikov, @.***> wrote:

Unable to reproduce using https://archive.org/download/electricsheep-flock-244-72500-6/electricsheep-flock-244-72500-6_archive.torrent

[image: shot] https://user-images.githubusercontent.com/145644/118641621-93900000-b804-11eb-8094-baab86c0cb61.png

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/idlesign/torrentool/issues/16#issuecomment-843080539, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAKONLDTM6E4ME4MMVR4CKDTOJDWHANCNFSM447UMQHQ .

idlesign commented 3 years ago

Screenshot shows total_size property is evaluated on 1.1.1. Sample code to test:

torrent = Torrent.from_file(datafix_dir / 'a.torrent')
size = t.total_size
Zorlin commented 3 years ago

It's possible my torrent was just corrupted. I'll close this and recreate it if I can reproduce it.