JohnDoee / autotorrent2

Cross-seed matching and torrent lifecycle tool
https://johndoee.github.io/autotorrent2/
MIT License
142 stars 10 forks source link

More information (verbose) when at2 outputs "failed to parse torrent file" #36

Closed newadventure079 closed 1 year ago

newadventure079 commented 1 year ago

Can we get some more info on why at2 failed to parse torrent file? I ran at2 with the verbose flag and no additional info was outputted.

at2 --verbose add rtorrent-2021-2022 (find ~/torrents/tmp/ -name \*.torrent) --print-summary --stopped
DEBUG:libtc.clients.rtorrent:42:Creating Normal XMLRPC Proxy with url http://172.17.0.1:8004/RPC2
DEBUG:libtc.clients.rtorrent:42:Creating Normal XMLRPC Proxy with url http://172.17.0.1:8006/RPC2
DEBUG:libtc.clients.rtorrent:42:Creating Normal XMLRPC Proxy with url http://172.17.0.1:8008/RPC2
Matching 1 torrent
 [Failed]  'xyz.torrent' failed to parse torrent file

Summary:
 Added:          0
 Missing files:  0
 Failed:         1
 Folder exists:  0
 Already seeded: 0
 Total:          1
JohnDoee commented 1 year ago

I threw in an exception logger, it'll show up in a release soon (and in master now)

JohnDoee commented 1 year ago

Fixed in 1.2.3

newadventure079 commented 1 year ago

@JohnDoee

There wasn't a ton more info outputted but it looks like the issue is Broken path elements found in torrent, try utf-8 compat mode

ERROR:autotorrent.__main__:489:Failed to parse torrent file
Traceback (most recent call last):
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/__main__.py", line 487, in add
    torrent = parse_torrent(torrent_data, utf8_compat_mode=db.utf8_compat_mode)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/utils.py", line 584, in parse_torrent
    raise FailedToParseTorrentException(
autotorrent.exceptions.FailedToParseTorrentException: Broken path elements found in torrent, try utf-8 compat mode

Looking at the filelist in a torrent editor and on the tracker site, my guess is there's a special character it's puking on. The website has a filename with €“. In the torrent editor, the same chars show up as �� and in rutorrent, they show up as ??

Is it possible to add some encoding when parsing? Like utf-16 or utf-8 compat mode

Jerrk commented 1 year ago

-u, --utf8-compat-mode Try work around utf-8 errors, not recommended

JohnDoee commented 1 year ago

A huge problem with bittorrent is that you can throw whatever you want into it, no rules here. If autotorrent can't decode it, it likely can't find the files on the disk to begin with.

Torrent sites aren't helping this problem along either as they ALSO just allow whatever garbage people can fit into a .torrent file.

Each client handles filename normalization differently, a feature not yet in autotorrent.

newadventure079 commented 1 year ago

@Jerrk Thanks for pointing out that option. I forgot it existed. And thanks @JohnDoee for the explanation

newadventure079 commented 8 months ago

FYI The --utf8-compat-mode goes before the add command. at2 --utf8-compat-mode add rtorrent