From 559bcf930c89fae1ab9a023be96ec4d14f00674b Mon Sep 17 00:00:00 2001 From: Marcelo Kronberg Date: Wed, 27 Jun 2018 14:33:07 +0100 Subject: [PATCH] fix for empty href on links that ocasionally cause an uncaught exception --- pirate/torrent.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pirate/torrent.py b/pirate/torrent.py index 5398909..340618d 100644 --- a/pirate/torrent.py +++ b/pirate/torrent.py @@ -100,7 +100,10 @@ def parse_page(html): # parse the rows one by one (skipping headings) for row in table('tr')[1:]: # grab info about the row - id_ = row.find('a', class_='detLink')['href'].split('/')[2] + row_link = row.find('a', class_='detLink') + if row_link is None: + continue + id_ = row_link['href'].split('/')[2] seeds, leechers = [i.text for i in row('td')[-2:]] magnet = row.find(lambda tag: tag.name == 'a' and @@ -207,4 +210,4 @@ def copy_magnets(printer, chosen_links, results): clipboard_text += magnet + "\n" printer.print('Copying {:X} to clipboard'.format(info_hash)) - pyperclip.copy(clipboard_text) \ No newline at end of file + pyperclip.copy(clipboard_text)