From 22fe027409eb639d7a3494dd7d1ab7d4ea4a14e9 Mon Sep 17 00:00:00 2001 From: Stefano Date: Sat, 11 Jan 2014 14:44:13 +0100 Subject: TurbobitNetFolder: fixed #471 Merged with fixes #472 --- module/plugins/crypter/TurbobitNetFolder.py | 39 +++++++++++++---------------- 1 file changed, 17 insertions(+), 22 deletions(-) (limited to 'module') diff --git a/module/plugins/crypter/TurbobitNetFolder.py b/module/plugins/crypter/TurbobitNetFolder.py index e172f8037..bec5a4480 100644 --- a/module/plugins/crypter/TurbobitNetFolder.py +++ b/module/plugins/crypter/TurbobitNetFolder.py @@ -15,7 +15,7 @@ # along with this program. If not, see . # ############################################################################ -import math +from math import ceil import re from module.plugins.internal.SimpleCrypter import SimpleCrypter @@ -29,32 +29,27 @@ def format_links(fid): class TurbobitNetFolder(SimpleCrypter): __name__ = "TurbobitNetFolder" __type__ = "crypter" - __pattern__ = r"http://(?:w{3}.)?turbobit\.net/download/folder/(?P\w+)" - __version__ = "0.01" + __pattern__ = r"http://(?:www\.)?turbobit\.net/download/folder/(?P\w+)" + __version__ = "0.02" __description__ = """Turbobit.net Folder Plugin""" - __author_name__ = ("stickell") - __author_mail__ = ("l.stickell@yahoo.it") + __author_name__ = ("stickell", "Walter Purcaro") + __author_mail__ = ("l.stickell@yahoo.it", "vuolter@gmail.com") - TITLE_PATTERN = r"(?P.+)</div>" + TITLE_PATTERN = r"src='/js/lib/grid/icon/folder.png'> <span>(?P<title>.+?)</span>" - def getLinks(self): - folder_id = re.search(self.__pattern__, self.pyfile.url).group('id') - grid = self.load('http://turbobit.net/downloadfolder/gridFile', - get={'id_folder': folder_id, 'rows': 200}, decode=True) - grid = json_loads(grid) + def _getLinks(self, id, page=1): + gridFile = self.load('http://turbobit.net/downloadfolder/gridFile', + get={'rootId': id, 'rows': 200, 'page': page}, decode=True) + grid = json_loads(gridFile) - links_count = grid["records"] - pages = int(math.ceil(links_count / 200.0)) + pages = int(ceil(grid["records"] / 200.0)) - ids = list() for i in grid['rows']: - ids.append(i['id']) + yield i['id'] - for p in range(2, pages + 1): - grid = self.load('http://turbobit.net/downloadfolder/gridFile', - get={'id_folder': folder_id, 'rows': 200, 'page': p}, decode=True) - grid = json_loads(grid) - for i in grid['rows']: - ids.append(i['id']) + if page < pages: + self._getLinks(id, page + 1) - return map(format_links, ids) + def getLinks(self): + folder_id = re.match(self.__pattern__, self.pyfile.url).group('ID') + return map(format_links, self._getLinks(folder_id)) -- cgit v1.2.3