JohnDoee / autotorrent2

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

IndexError: list index out of range #24

Open newadventure079 opened 2 years ago

newadventure079 commented 2 years ago
Traceback (most recent call last):
  File "/var/services/homes/me/.autotorrent/bin/at2", line 8, in <module>
    sys.exit(cli())
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/__main__.py", line 477, in add
    match_result = matcher.match_files_dynamic(
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/matcher.py", line 265, in match_files_dynamic
    self._select_best_candidate(
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/matcher.py", line 162, in _select_best_candidate
    return sorted(
IndexError: list index out of range

I dont really have any other info to provide. It was going along and spit this out in the same spot each time. I dont know what torrent it was on because I think it only shows the name after it's been processed

newadventure079 commented 2 years ago

It might be due to add_limit_percent = 100. I had it at 100 and it happened each time. I changed it to 99 and it didn't error

JohnDoee commented 2 years ago

It probably thinks there's a match when all files are missing, since that's what add_limit_percent = 100 so should be easy to fix.

newadventure079 commented 1 year ago
Traceback (most recent call last):
  File "/var/services/homes/me/.autotorrent/bin/at2", line 8, in <module>
    sys.exit(cli())
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/__main__.py", line 533, in add
    match_result = matcher.match_files_dynamic(
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/matcher.py", line 368, in match_files_dynamic
    self._select_best_candidate(
  File "/var/services/homes/me/.autotorrent/lib/python3.8/site-packages/autotorrent/matcher.py", line 260, in _select_best_candidate
    return sorted(
IndexError: list index out of range

I'm using add_limit_percent = 10

newadventure079 commented 8 months ago

I'm seeing this again and again now

newadventure079 commented 8 months ago

I debugged this and found the issue.

In _select_best_candidate(), evaluated_candidates is an empty list, so the call to sorted()[0] at the end of the function causes the list index out of range error.

I actually had a folder that contained video files and also a DVD VIDEO_TS folder. I think at2 was trying to add all the individual .VOB files and such. I told at2 not to match DVD folders and now it works, but a check for an empty evaluated_candidates list should be added to the code

newadventure079 commented 8 months ago

I didn't like how it would mark DVD torrents as Failed because I had .VOB and .IFO as an ignore_file_pattern. So what I did now was before we call self._select_best_candidate() in match_files_dynamic(), I put in

if len(candidates) == 0:
    return DynamicMatchResult(False, current_missing_size, None, None)