idlesign / torrt

Automates torrent updates for you
https://github.com/idlesign/torrt
BSD 3-Clause "New" or "Revised" License
112 stars 19 forks source link

Torrent removed from rutracker fails torrt walk #65

Closed eliduvid closed 3 years ago

eliduvid commented 3 years ago

I have registered torrent with hash 518f22c40ac78b2dcb72cd8747926ed01266c812. Every time I run torrt walk and it gets to this one it prints stacktrace and fails.

Traceback (most recent call last):
  File "/usr/local/bin/torrt", line 10, in <module>
    sys.exit(process_commands())
  File "/usr/local/lib/python3.7/dist-packages/torrt/main.py", line 197, in process_commands
    walk(forced=args['forced'], silent=True)
  File "/usr/local/lib/python3.7/dist-packages/torrt/toolbox.py", line 309, in walk
    updated = update_torrents(cfg['torrents'], remove_outdated=remove_outdated)
  File "/usr/local/lib/python3.7/dist-packages/torrt/toolbox.py", line 387, in update_torrents
    tracker_torrent = get_torrent_from_url(page_url)
  File "/usr/local/lib/python3.7/dist-packages/torrt/utils.py", line 455, in get_torrent_from_url
    torrent_info = tracker.get_torrent(url)
  File "/usr/local/lib/python3.7/dist-packages/torrt/base_tracker.py", line 377, in get_torrent
    parsed = parse_torrent(torrent_contents)
  File "/usr/local/lib/python3.7/dist-packages/torrt/utils.py", line 291, in parse_torrent
    return Torrent.from_string(torrent)
  File "/usr/local/lib/python3.7/dist-packages/torrentool/torrent.py", line 418, in from_string
    return cls(Bencode.read_string(string, byte_keys={'pieces'}))
  File "/usr/local/lib/python3.7/dist-packages/torrentool/bencode.py", line 189, in read_string
    return cls.decode(string, byte_keys=byte_keys)
  File "/usr/local/lib/python3.7/dist-packages/torrentool/bencode.py", line 167, in decode
    raise BencodeDecodingError(f'Unable to interpret `{char}` char.')
torrentool.exceptions.BencodeDecodingError: Unable to interpret `<` char.

Please contact me if you need more details.

idlesign commented 3 years ago

The torrent file torrt downloaded seems to be malformed so we're unable to parse it. Since the character is < I can assume that this might be an html page but not a torrent file. You may want to run walk with --dump option to see what's been downloaded. Next, for example If you see that a login page html has been downloaded instead of a torrent, it'd mean that you'll need to check your credentials.

eliduvid commented 3 years ago

OK, not surprisingly (although, now I understand that I never mentioned it properly) I got a message that torrent is replaced and cannot be downloaded:

Раздача имеет статус: поглощено

Скачивание запрещено 

UPD: personally I think it's not a big problem to fail here. (Specific handling for replaced torrents from RuTracker may be nice, but not essential.) The problem is that because of one failed torrent it's not trying to handle rest of them

idlesign commented 3 years ago

Probably we need to think about warning and skip for such cases. Thank you for the report.

idlesign commented 3 years ago

Implemented in https://github.com/idlesign/torrt/commit/a73da8e171c14dec85e33ae7c27f732241287c0e Soon to be released.