summaryrefslogtreecommitdiffstats
path: root/module/plugins
diff options
context:
space:
mode:
authorGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-08 22:20:53 +0200
committerGravatar Walter Purcaro <vuolter@users.noreply.github.com> 2015-06-08 22:20:53 +0200
commitdee142a5f3be3fcbd245aab21686f0bc3aeab582 (patch)
treea68e3136bd0b1ce0f0884bf9d3e396acea8d7695 /module/plugins
parent[GamefrontCom] Fixup (diff)
downloadpyload-dee142a5f3be3fcbd245aab21686f0bc3aeab582.tar.xz
[GamefrontCom] Update
Diffstat (limited to 'module/plugins')
-rw-r--r--module/plugins/hoster/GamefrontCom.py84
1 files changed, 15 insertions, 69 deletions
diff --git a/module/plugins/hoster/GamefrontCom.py b/module/plugins/hoster/GamefrontCom.py
index afa9cccff..590a85ee8 100644
--- a/module/plugins/hoster/GamefrontCom.py
+++ b/module/plugins/hoster/GamefrontCom.py
@@ -1,90 +1,36 @@
# -*- coding: utf-8 -*-
-import re
+from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo
-from module.network.RequestFactory import getURL
-from module.plugins.internal.Hoster import Hoster
-from module.utils import parseFileSize
-
-class GamefrontCom(Hoster):
+class GamefrontCom(SimpleHoster):
__name__ = "GamefrontCom"
__type__ = "hoster"
- __version__ = "0.06"
+ __version__ = "0.07"
- __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'>File Name:</dt>\s*<dd>(?P<N>.+?)<'
+ 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.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("&amp;", "&")
-
-
-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 handleFree(self, pyfile):
+ self.html = self.load("http://www.gamefront.com/files/service/thankyou",
+ get={'id': self.info['pattern']['ID']})
+ return super(GamefrontCom, self).handleFree(pyfile)
- result.append((name, size, 3, url))
- yield result
+getInfo = create_getInfo(GamefrontCom)