diff options
author | 2015-08-09 00:50:54 +0200 | |
---|---|---|
committer | 2015-08-09 00:50:54 +0200 | |
commit | b0ef3f1673e1930916604bb1264ca3a38414bc8d (patch) | |
tree | c97936e4d2a4cd6eb1072c65c8a08a7d18816b18 /module/plugins/hoster/GamefrontCom.py | |
parent | [XFileSharingPro][XFileSharingProFolder] Added default __pattern__ (diff) | |
parent | Fix https://github.com/pyload/pyload/issues/1707 (diff) | |
download | pyload-b0ef3f1673e1930916604bb1264ca3a38414bc8d.tar.xz |
Merge pull request #1 from pyload/stable
sync with stable
Diffstat (limited to 'module/plugins/hoster/GamefrontCom.py')
-rw-r--r-- | module/plugins/hoster/GamefrontCom.py | 87 |
1 files changed, 17 insertions, 70 deletions
diff --git a/module/plugins/hoster/GamefrontCom.py b/module/plugins/hoster/GamefrontCom.py index c68866f87..fb3b98f5e 100644 --- a/module/plugins/hoster/GamefrontCom.py +++ b/module/plugins/hoster/GamefrontCom.py @@ -1,90 +1,37 @@ # -*- coding: utf-8 -*- -import re +from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo -from module.network.RequestFactory import getURL -from module.plugins.Hoster import Hoster -from module.utils import parseFileSize - -class GamefrontCom(Hoster): +class GamefrontCom(SimpleHoster): __name__ = "GamefrontCom" __type__ = "hoster" - __version__ = "0.04" + __version__ = "0.09" + __status__ = "testing" - __pattern__ = r'http://(?:www\.)?gamefront\.com/files/\w+' + __pattern__ = r'http://(?:www\.)?gamefront\.com/files/(?P<ID>\d+)' __description__ = """Gamefront.com hoster plugin""" __license__ = "GPLv3" - __authors__ = [("fwannmacher", "felipe@warhammerproject.com")] + __authors__ = [("Walter Purcaro", "vuolter@gmail.com")] + + NAME_PATTERN = r'<title>(?P<N>.+?) \| Game Front</title>' + SIZE_PATTERN = r'>File Size:</dt>\s*<dd>(?P<S>[\d.,]+) (?P<U>[\w^_]+)' + OFFLINE_PATTERN = r'<p>File not found' - PATTERN_FILENAME = r'<title>(.*?) | Game Front' - PATTERN_FILESIZE = r'<dt>File Size:</dt>[\n\s]*<dd>(.*?)</dd>' - PATTERN_OFFLINE = r'This file doesn\'t exist, or has been removed.' + LINK_FREE_PATTERN = r"downloadUrl = '(.+?)'" def setup(self): - self.resumeDownload = True + self.resume_download = True self.multiDL = True - self.chunkLimit = -1 - - - def process(self, pyfile): - self.pyfile = pyfile - self.html = self.load(pyfile.url, decode=True) - - if not self._checkOnline(): - self.offline() - - pyfile.name = self._getName() - - link = self._getLink() - - if not link.startswith('http://'): - link = "http://www.gamefront.com/" + link - - self.download(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, self.html) - if name is None: - self.fail(_("Plugin broken") - - return name.group(1) - - - def _getLink(self): - self.html2 = self.load("http://www.gamefront.com/" + re.search("(files/service/thankyou\\?id=\w+)", - self.html).group(1)) - return re.search("<a href=\"(http://media\d+\.gamefront.com/.*)\">click here</a>", self.html2).group(1).replace("&", "&") - - -def getInfo(urls): - result = [] - for url in urls: - html = getURL(url) - if re.search(GamefrontCom.PATTERN_OFFLINE, html): - result.append((url, 0, 1, url)) - else: - name = re.search(GamefrontCom.PATTERN_FILENAME, html) - if name is None: - result.append((url, 0, 1, url)) - else: - name = name.group(1) - size = re.search(GamefrontCom.PATTERN_FILESIZE, html) - size = parseFileSize(size.group(1)) + def handle_free(self, pyfile): + self.html = self.load("http://www.gamefront.com/files/service/thankyou", + get={'id': self.info['pattern']['ID']}) + return super(GamefrontCom, self).handle_free(pyfile) - result.append((name, size, 3, url)) - yield result +getInfo = create_getInfo(GamefrontCom) |