diff --git a/NyaaPy/utils.py b/NyaaPy/utils.py index c2c1082..cf108a1 100644 --- a/NyaaPy/utils.py +++ b/NyaaPy/utils.py @@ -76,66 +76,37 @@ class Utils: torrents = [] for row in table_rows[:limit]: -<<<<<<< HEAD block = [] for td in row.find_all('td'): - for link in td.find_all('a'): - if link.get('href')[-9:] != '#comments': - block.append(link.get('href')) - block.append(link.text.rstrip()) + if td.find_all('a'): + for link in td.find_all('a'): + if link.get('href')[-9:] != '#comments': + block.append(link.get('href')) + if link.text.rstrip(): + block.append(link.text) if td.text.rstrip(): block.append(td.text.rstrip()) - torrent = { - 'id': block[1].replace("/view/", ""), - 'category': Utils.nyaa_categories(block[0]), - 'url': "http://nyaa.si{}".format(block[1]), - 'name': block[2], - 'download_url': "http://nyaa.si{}".format(block[4]), - 'magnet': block[5], - 'size': block[6], - 'date': block[7], - 'seeders': block[8], - 'leechers': block[9], - 'completed_downloads': block[10], - } - - torrents.append(torrent) -======= - block = [] + try: + torrent = { + 'id': block[1].replace("/view/", ""), + 'category': Utils.nyaa_categories(self, block[0]), + 'url': "http://nyaa.si{}".format(block[1]), + 'name': block[2], + 'download_url': "http://nyaa.si{}".format(block[4]), + 'magnet': block[5], + 'size': block[6], + 'date': block[7], + 'seeders': block[8], + 'leechers': block[9], + 'completed_downloads': block[10], + } - for td in row.find_all('td'): - if td.find_all('a'): - for link in td.find_all('a'): - if link.get('href')[-9:] != '#comments': - block.append(link.get('href')) - if link.text.rstrip(): - block.append(link.text) - - if td.text.rstrip(): - block.append(td.text.rstrip()) - - try: - torrent = { - 'id': block[1].replace("/view/", ""), - 'category': Utils.nyaa_categories(self, block[0]), - 'url': "http://nyaa.si{}".format(block[1]), - 'name': block[2], - 'download_url': "http://nyaa.si{}".format(block[4]), - 'magnet': block[5], - 'size': block[6], - 'date': block[7], - 'seeders': block[8], - 'leechers': block[9], - 'completed_downloads': block[10], - } - - torrents.append(torrent) - except IndexError as ie: - pass ->>>>>>> 8df5b27bd43ffbfacbc58124f2082370e9287a92 + torrents.append(torrent) + except IndexError as ie: + pass return torrents @@ -290,4 +261,4 @@ class Utils: for lang in value: query += "&lang={}".format(lang) - return query \ No newline at end of file + return query