vikstrous / pirate-get

A command line interface for The Pirate Bay
GNU Affero General Public License v3.0
337 stars 53 forks source link

exception while searching #47

Closed vikstrous closed 9 years ago

vikstrous commented 9 years ago
$ pirate-get game of thrones
Trying https://www.piratefly.com... Ok 
LINK   SEED  LEECH  RATIO  SIZE       UPLOAD       NAME                                       
Traceback (most recent call last):
  File "/usr/bin/pirate-get", line 691, in <module>
    main()
  File "/usr/bin/pirate-get", line 586, in main
    print_search_results(mags, sizes, uploaded, local=args.database)
  File "/usr/bin/pirate-get", line 362, in print_search_results
    size = float(sizes[m][0])
IndexError: list index out of range
vikstrous commented 9 years ago

Now I get this sometimes when I have unreliable internet:

Traceback (most recent call last):
  File "./pirate-get.py", line 686, in <module>
    main()
  File "./pirate-get.py", line 579, in main
    print_search_results(mags, sizes, uploaded, local=args.database)
  File "./pirate-get.py", line 349, in print_search_results
    torrent_name = parse.unquote(name.group(1)).replace('+', ' ')
AttributeError: 'NoneType' object has no attribute 'group'
rnhmjoj commented 9 years ago

I noticed this some time ago but I wasn't able to reproduce it. It also seems related to the proxy used.

rnhmjoj commented 9 years ago

I found one of the mirrors that is giving this problem. Basically there is no magnet uri found: this is the magnet parsed ['', '346', '51'] That means the regex for the magnet in remote(args, mirror) is not working:

found = re.findall(r'"(magnet\:\?xt=[^"]*)|<td align="right">'
                                                 r'([^<]+)</td>', res)
vikstrous commented 9 years ago

Sweet. If you can figure out which mirror it is and what the html looks like, it'll probably be a simple fix. We might want to switch to not using regex though :P That might also solve the problem.

rnhmjoj commented 9 years ago

It's not our fault. The page is missing all the magnets! The magnet icon is just a link to the torrent page. https://thepirateboat.eu/s/?q=&page=0&orderby=99

vikstrous commented 9 years ago

I blacklisted thebay.tv for this reason: https://github.com/vikstrous/pirate-get/commit/398614704d40a83c01f668d3fdbc503d7fcb167d

We can handle this case by storing the url to the torrent page and then getting the magnet link only after you choose the torrent. This is a weird thing to have to detect and I don't know why some mirrors do this.

In other news, thebay.tv seems to open popups that immediately close themselves periodically. I suspect that it's malware attempting to exploit the browser, a DDoS attack or fake ad views. I haven't investigated, but this whole mirror business is not great. The pirate bay has a .onion domain, so maybe we can detect a local tor instance and use that instead of mirrors whenever we can.

vikstrous commented 9 years ago

Nothing to be done here...