From e0ae0ca05b9ca8ce4a451c182594bdc481c22264 Mon Sep 17 00:00:00 2001 From: Stefano Date: Thu, 4 Apr 2013 14:07:14 +0200 Subject: PutlockerCom: using SimpleHoster to clean the code and make it work better --- module/plugins/hoster/PutlockerCom.py | 112 ++++++++++------------------------ 1 file changed, 32 insertions(+), 80 deletions(-) (limited to 'module/plugins/hoster/PutlockerCom.py') diff --git a/module/plugins/hoster/PutlockerCom.py b/module/plugins/hoster/PutlockerCom.py index ca5336231..e98e4d332 100644 --- a/module/plugins/hoster/PutlockerCom.py +++ b/module/plugins/hoster/PutlockerCom.py @@ -1,4 +1,5 @@ # -*- coding: utf-8 -*- + """ This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,103 +17,56 @@ @author: jeix """ +# http://www.putlocker.com/file/83C174C844583CF7 + import re -from module.plugins.Hoster import Hoster -from module.network.RequestFactory import getURL - -def getInfo(urls): - result = [] - - for url in urls: - - html = getURL(url) - if re.search(PutlockerCom.PATTERN_OFFLINE, html): - result.append((url, 0, 1, url)) - else: - name = re.search(PutlockerCom.PATTERN_FILENAME_1, html) - if name is None: - name = re.search(PutlockerCom.PATTERN_FILENAME_2, html) - if name is None: - result.append((url, 0, 1, url)) - continue - - name = name.group(1) - - # size = re.search(PutlockerCom.PATTERN_FILESIZE, html) - # if size is None: - # result.append((url, 0, 1, url)) - # continue - - # size = size.group(1) - - result.append((name, 0, 2, url)) - yield result - -class PutlockerCom(Hoster): + +from module.plugins.internal.SimpleHoster import SimpleHoster + + +class PutlockerCom(SimpleHoster): __name__ = "PutlockerCom" __type__ = "hoster" __pattern__ = r'http://(www\.)?putlocker\.com/(file|embed)/[A-Z0-9]+' - __version__ = "0.21" + __version__ = "0.22" __description__ = """Putlocker.Com""" - __author_name__ = ("jeix") - - PATTERN_OFFLINE = r"This file doesn't exist, or has been removed." - PATTERN_FILENAME_1 = "site-content.*?

(.*?)\s*

(?P.+)\( (?P[^)]+) \)

' + + def handleFree(self): + self.html = self.load(self.pyfile.url, decode=True) + self.link = self._getLink() if not self.link.startswith('http://'): self.link = "http://www.putlocker.com" + self.link - self.download( self.link ) - - def _checkOnline(self): - if re.search(self.PATTERN_OFFLINE, self.html): - return False - else: - return True - - def _getName(self): - name = re.search(self.PATTERN_FILENAME_1, self.html) - if name is None: - name = re.search(self.PATTERN_FILENAME_2, self.html) - # if name is None: - # self.fail("%s: Plugin broken." % self.__name__) - - return name.group(1) - + self.download(self.link, disposition=True) + def _getLink(self): self.hash = re.search("", self.html) # if self.hash is None: - # self.fail("%s: Plugin broken." % self.__name__) - + # self.fail("%s: Plugin broken." % self.__name__) + self.param = "hash=" + self.hash.group(1) + "&confirm=Continue+as+Free+User" self.html2 = self.load(self.pyfile.url, post=self.param) if ">You have exceeded the daily stream limit for your country\\. You can wait until tomorrow" in self.html2 or "(>This content server has been temporarily disabled for upgrades|Try again soon\\. You can still download it below\\.<)" in self.html2: self.waittime = 2 * 60 * 60 self.retry(wait_time=self.waittime, reason="Waiting %s seconds" % self.waittime) - - self.link = re.search("Tired of ads and waiting\\? Go Pro\\![\t\n\rn ]+[\t\n\rn ]+Tired of ads and waiting\\? Go Pro\\![\t\n\rn ]+[\t\n\rn ]+ Date: Thu, 4 Apr 2013 20:55:09 +0200 Subject: PutlockerCom: code optimized and cleaned up --- module/plugins/hoster/PutlockerCom.py | 77 +++++++++++++++++------------------ 1 file changed, 38 insertions(+), 39 deletions(-) (limited to 'module/plugins/hoster/PutlockerCom.py') diff --git a/module/plugins/hoster/PutlockerCom.py b/module/plugins/hoster/PutlockerCom.py index e98e4d332..043adcb06 100644 --- a/module/plugins/hoster/PutlockerCom.py +++ b/module/plugins/hoster/PutlockerCom.py @@ -28,7 +28,7 @@ class PutlockerCom(SimpleHoster): __name__ = "PutlockerCom" __type__ = "hoster" __pattern__ = r'http://(www\.)?putlocker\.com/(file|embed)/[A-Z0-9]+' - __version__ = "0.22" + __version__ = "0.23" __description__ = """Putlocker.Com""" __author_name__ = ("jeix", "stickell") __author_mail__ = ("l.stickell@yahoo.it") @@ -39,43 +39,42 @@ class PutlockerCom(SimpleHoster): def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) - self.link = self._getLink() - if not self.link.startswith('http://'): - self.link = "http://www.putlocker.com" + self.link - self.download(self.link, disposition=True) + link = self._getLink() + if not link.startswith('http://'): + link = "http://www.putlocker.com" + link + self.download(link, disposition=True) def _getLink(self): - self.hash = re.search("", self.html) - # if self.hash is None: - # self.fail("%s: Plugin broken." % self.__name__) - - self.param = "hash=" + self.hash.group(1) + "&confirm=Continue+as+Free+User" - self.html2 = self.load(self.pyfile.url, post=self.param) - if ">You have exceeded the daily stream limit for your country\\. You can wait until tomorrow" in self.html2 or "(>This content server has been temporarily disabled for upgrades|Try again soon\\. You can still download it below\\.<)" in self.html2: - self.waittime = 2 * 60 * 60 - self.retry(wait_time=self.waittime, reason="Waiting %s seconds" % self.waittime) - - self.link = re.search( - "Tired of ads and waiting\\? Go Pro\\![\t\n\rn ]+[\t\n\rn ]+', self.html) + if not hash_data: + self.parseError('Unable to detect hash') + + post_data = {"hash": hash_data.group(1), "confirm": "Continue+as+Free+User"} + self.html = self.load(self.pyfile.url, post=post_data) + if ">You have exceeded the daily stream limit for your country\\. You can wait until tomorrow" in self.html or \ + "(>This content server has been temporarily disabled for upgrades|Try again soon\\. You can still download it below\\.<)" in self.html: + self.retry(wait_time=2 * 60 * 60, reason="Download limit exceeded or server disabled") + + link = re.search(r'(/get_file\.php\?id=[A-Z0-9]+&key=[A-Za-z0-9=]+&original=1)', self.html) + if not link: + link = re.search(r"(/get_file\.php\?download=[A-Z0-9]+&key=[a-z0-9]+)", self.html) + + if not link: + link = re.search(r"(/get_file\.php\?download=[A-Z0-9]+&key=[a-z0-9]+&original=1)", self.html) + + if not link: + link = re.search( + r'Tired of ads and waiting\? Go Pro![\t\n\rn ]+[\t\n\rn ]+ Date: Fri, 5 Apr 2013 17:37:13 +0200 Subject: PutlockerCom: using loop to avoid repeated statement --- module/plugins/hoster/PutlockerCom.py | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) (limited to 'module/plugins/hoster/PutlockerCom.py') diff --git a/module/plugins/hoster/PutlockerCom.py b/module/plugins/hoster/PutlockerCom.py index 043adcb06..9eff0dc2b 100644 --- a/module/plugins/hoster/PutlockerCom.py +++ b/module/plugins/hoster/PutlockerCom.py @@ -28,7 +28,7 @@ class PutlockerCom(SimpleHoster): __name__ = "PutlockerCom" __type__ = "hoster" __pattern__ = r'http://(www\.)?putlocker\.com/(file|embed)/[A-Z0-9]+' - __version__ = "0.23" + __version__ = "0.24" __description__ = """Putlocker.Com""" __author_name__ = ("jeix", "stickell") __author_mail__ = ("l.stickell@yahoo.it") @@ -55,19 +55,15 @@ class PutlockerCom(SimpleHoster): "(>This content server has been temporarily disabled for upgrades|Try again soon\\. You can still download it below\\.<)" in self.html: self.retry(wait_time=2 * 60 * 60, reason="Download limit exceeded or server disabled") - link = re.search(r'(/get_file\.php\?id=[A-Z0-9]+&key=[A-Za-z0-9=]+&original=1)', self.html) - if not link: - link = re.search(r"(/get_file\.php\?download=[A-Z0-9]+&key=[a-z0-9]+)", self.html) - - if not link: - link = re.search(r"(/get_file\.php\?download=[A-Z0-9]+&key=[a-z0-9]+&original=1)", self.html) - - if not link: - link = re.search( - r'Tired of ads and waiting\? Go Pro![\t\n\rn ]+[\t\n\rn ]+Tired of ads and waiting\? Go Pro![\t\n\rn ]+[\t\n\rn ]+