Browse Source

Merge pull request #3020 from ngosang/fix_piratebay

[search engine] Fix thepiratebay engine. Closes #3012
adaptive-webui-19844
sledgehammer999 9 years ago
parent
commit
14b5d15268
  1. 39
      src/searchengine/nova/engines/piratebay.py
  2. 2
      src/searchengine/nova/engines/versions.txt
  3. 39
      src/searchengine/nova3/engines/piratebay.py
  4. 2
      src/searchengine/nova3/engines/versions.txt

39
src/searchengine/nova/engines/piratebay.py

@ -1,7 +1,8 @@
#VERSION: 2.10 #VERSION: 2.11
#AUTHORS: Fabien Devaux (fab@gnux.info) #AUTHORS: Fabien Devaux (fab@gnux.info)
#CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org) #CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org)
# Arthur (custparasite@gmx.se) # Arthur (custparasite@gmx.se)
# Diego de las Heras (diegodelasheras@gmail.com)
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -35,7 +36,7 @@ from helpers import download_file
class piratebay(object): class piratebay(object):
""" Search engine class """ """ Search engine class """
url = 'https://thepiratebay.se' url = 'https://thepiratebay.gd'
name = 'The Pirate Bay' name = 'The Pirate Bay'
supported_categories = {'all': '0', 'music': '100', 'movies': '200', 'games': '400', 'software': '300'} supported_categories = {'all': '0', 'music': '100', 'movies': '200', 'games': '400', 'software': '300'}
@ -69,6 +70,9 @@ class piratebay(object):
self.save_item = "name" self.save_item = "name"
elif link.startswith("magnet"): elif link.startswith("magnet"):
self.current_item["link"] = link self.current_item["link"] = link
# end of the 'name' item
self.current_item['name'] = self.current_item['name'].strip()
self.save_item = None
def handle_start_tag_font(self, attrs): def handle_start_tag_font(self, attrs):
""" Handler for start tag font """ """ Handler for start tag font """
@ -110,7 +114,6 @@ class piratebay(object):
elif tag == "div": elif tag == "div":
self.result_query = "center" == attrs[0][1] self.result_query = "center" == attrs[0][1]
def handle_endtag(self, tag): def handle_endtag(self, tag):
""" Parser's end tag handler """ """ Parser's end tag handler """
if self.result_tbody: if self.result_tbody:
@ -134,21 +137,29 @@ class piratebay(object):
def handle_data(self, data): def handle_data(self, data):
""" Parser's data handler """ """ Parser's data handler """
if self.save_item == "size": if self.save_item:
temp_data = data.split() if self.save_item == "size":
if "Size" in temp_data: temp_data = data.split()
self.current_item[self.save_item] = temp_data[2] if "Size" in temp_data:
elif "ULed" in temp_data: self.current_item[self.save_item] = temp_data[2]
temp_string = self.current_item[self.save_item] elif "ULed" in temp_data:
self.current_item[self.save_item] = " ".join((temp_string, temp_data[0][:-1])) temp_string = self.current_item[self.save_item]
elif self.save_item: self.current_item[self.save_item] = " ".join((temp_string, temp_data[0][:-1]))
self.current_item[self.save_item] = data
self.save_item = None elif self.save_item == "name":
# names with special characters like '&' are splitted in several pieces
if 'name' not in self.current_item:
self.current_item['name'] = ''
self.current_item['name'] += data
else:
self.current_item[self.save_item] = data
self.save_item = None
def search(self, what, cat='all'): def search(self, what, cat='all'):
""" Performs search """ """ Performs search """
connection = https("thepiratebay.se") connection = https("thepiratebay.gd")
#prepare query. 7 is filtering by seeders #prepare query. 7 is filtering by seeders
cat = cat.lower() cat = cat.lower()

2
src/searchengine/nova/engines/versions.txt

@ -1,6 +1,6 @@
torrentreactor: 1.33 torrentreactor: 1.33
mininova: 1.51 mininova: 1.51
piratebay: 2.10 piratebay: 2.11
extratorrent: 1.2 extratorrent: 1.2
kickasstorrents: 1.26 kickasstorrents: 1.26
btdigg: 1.24 btdigg: 1.24

39
src/searchengine/nova3/engines/piratebay.py

@ -1,7 +1,8 @@
#VERSION: 2.10 #VERSION: 2.11
#AUTHORS: Fabien Devaux (fab@gnux.info) #AUTHORS: Fabien Devaux (fab@gnux.info)
#CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org) #CONTRIBUTORS: Christophe Dumez (chris@qbittorrent.org)
# Arthur (custparasite@gmx.se) # Arthur (custparasite@gmx.se)
# Diego de las Heras (diegodelasheras@gmail.com)
# Redistribution and use in source and binary forms, with or without # Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met: # modification, are permitted provided that the following conditions are met:
@ -35,7 +36,7 @@ from helpers import download_file
class piratebay(object): class piratebay(object):
""" Search engine class """ """ Search engine class """
url = 'https://thepiratebay.se' url = 'https://thepiratebay.gd'
name = 'The Pirate Bay' name = 'The Pirate Bay'
supported_categories = {'all': '0', 'music': '100', 'movies': '200', 'games': '400', 'software': '300'} supported_categories = {'all': '0', 'music': '100', 'movies': '200', 'games': '400', 'software': '300'}
@ -69,6 +70,9 @@ class piratebay(object):
self.save_item = "name" self.save_item = "name"
elif link.startswith("magnet"): elif link.startswith("magnet"):
self.current_item["link"] = link self.current_item["link"] = link
# end of the 'name' item
self.current_item['name'] = self.current_item['name'].strip()
self.save_item = None
def handle_start_tag_font(self, attrs): def handle_start_tag_font(self, attrs):
""" Handler for start tag font """ """ Handler for start tag font """
@ -110,7 +114,6 @@ class piratebay(object):
elif tag == "div": elif tag == "div":
self.result_query = "center" == attrs[0][1] self.result_query = "center" == attrs[0][1]
def handle_endtag(self, tag): def handle_endtag(self, tag):
""" Parser's end tag handler """ """ Parser's end tag handler """
if self.result_tbody: if self.result_tbody:
@ -134,21 +137,29 @@ class piratebay(object):
def handle_data(self, data): def handle_data(self, data):
""" Parser's data handler """ """ Parser's data handler """
if self.save_item == "size": if self.save_item:
temp_data = data.split() if self.save_item == "size":
if "Size" in temp_data: temp_data = data.split()
self.current_item[self.save_item] = temp_data[2] if "Size" in temp_data:
elif "ULed" in temp_data: self.current_item[self.save_item] = temp_data[2]
temp_string = self.current_item[self.save_item] elif "ULed" in temp_data:
self.current_item[self.save_item] = " ".join((temp_string, temp_data[0][:-1])) temp_string = self.current_item[self.save_item]
elif self.save_item: self.current_item[self.save_item] = " ".join((temp_string, temp_data[0][:-1]))
self.current_item[self.save_item] = data
self.save_item = None elif self.save_item == "name":
# names with special characters like '&' are splitted in several pieces
if 'name' not in self.current_item:
self.current_item['name'] = ''
self.current_item['name'] += data
else:
self.current_item[self.save_item] = data
self.save_item = None
def search(self, what, cat='all'): def search(self, what, cat='all'):
""" Performs search """ """ Performs search """
connection = https("thepiratebay.se") connection = https("thepiratebay.gd")
#prepare query. 7 is filtering by seeders #prepare query. 7 is filtering by seeders
cat = cat.lower() cat = cat.lower()

2
src/searchengine/nova3/engines/versions.txt

@ -1,6 +1,6 @@
torrentreactor: 1.33 torrentreactor: 1.33
mininova: 1.51 mininova: 1.51
piratebay: 2.10 piratebay: 2.11
extratorrent: 1.2 extratorrent: 1.2
kickasstorrents: 1.26 kickasstorrents: 1.26
btdigg: 1.23 btdigg: 1.23

Loading…
Cancel
Save