diff options
| author | 2012-10-26 09:06:12 +0200 | |
|---|---|---|
| committer | 2012-10-26 09:06:12 +0200 | |
| commit | bebb155fd45a9cd6a4af25bd5e365cc39f6bd55d (patch) | |
| tree | 14cad117b1fbbf0be7ac31b875b2dd5bafd78e04 /module/plugins/hoster | |
| parent | update youtube plugin - closed #686 (diff) | |
| download | pyload-bebb155fd45a9cd6a4af25bd5e365cc39f6bd55d.tar.xz | |
gamefront.com plugin - thanx fwannmacher - closed #705
Diffstat (limited to 'module/plugins/hoster')
| -rw-r--r-- | module/plugins/hoster/GamefrontCom.py | 79 | 
1 files changed, 79 insertions, 0 deletions
| diff --git a/module/plugins/hoster/GamefrontCom.py b/module/plugins/hoster/GamefrontCom.py new file mode 100644 index 000000000..1e3ca77e5 --- /dev/null +++ b/module/plugins/hoster/GamefrontCom.py @@ -0,0 +1,79 @@ +import re +from module.plugins.Hoster import Hoster +from module.network.RequestFactory import getURL + +class GamefrontCom(Hoster): +    __name__ = "GamefrontCom" +    __type__ = "hoster" +    __pattern__ = r"http://(?:\w*\.)*?gamefront.com/files/[A-Za-z0-9]+" +    __version__ = "0.01" +    __description__ = """gamefront.com hoster plugin""" +    __author_name__ = ("fwannmacher") +    __author_mail__ = ("felipe@warhammerproject.com") +     +    HOSTER_NAME = "gamefront.com" +    PATTERN_FILENAME = r'<title>(.*?) | Game Front' +    PATTERN_FILESIZE = r'<dt>File Size:</dt>[\n\s]*<dd>(.*?)</dd>' +    PATTERN_OFFLINE = "This file doesn't exist, or has been removed." +     +    def setup(self): +        self.resumeDownload = True +        self.multiDL = False + +    def process(self, pyfile): +        self.pyfile = pyfile +        self.html = self.load(pyfile.url, decode=True) + +        if not self._checkOnline(): +            self.offline() +         +        self.pyfile.name = self._getName() +         +        self.link = self._getLink() +         +        if not self.link.startswith('http://'): +            self.link = "http://www.gamefront.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, self.html) +        if name is None: +            self.fail("%s: Plugin broken." % self.__name__) + +        return name.group(1) +         +    def _getLink(self):  +        self.html2 = self.load("http://www.gamefront.com/" + re.search("(files/service/thankyou\\?id=[A-Za-z0-9]+)", self.html).group(1)) +        self.link = re.search("<a href=\"(http://media[0-9]+\.gamefront.com/.*)\">click here</a>", self.html2) + +        return self.link.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)) +                continue +                 +            name = name.group(1) +            size = re.search(GamefrontCom.PATTERN_FILESIZE, html) +            size = parseFileSize(size.group(1))  +             +            result.append((name, size, 3, url)) + +    yield result
\ No newline at end of file | 
