From 47d3ef52a10e1a0db8b73fde81c9d3a7eaed00c3 Mon Sep 17 00:00:00 2001 From: Stefano <l.stickell@yahoo.it> Date: Wed, 2 Jul 2014 14:56:10 +0200 Subject: [Filefactory] getInfo handle direct links Partially fixes #648 --- module/plugins/hoster/FilefactoryCom.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index 21b803649..05edf6b99 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -16,14 +16,26 @@ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, create_getInfo +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo +from module.network.RequestFactory import getURL + + +def getInfo(urls): + for url in urls: + h = getURL(url, just_header=True) + m = re.search(r'Location: (.+)\r\n', h) + if m and not re.match(m.group(1), FilefactoryCom.__pattern__): # It's a direct link! Skipping + yield (url, 0, 3, url) + else: # It's a standard html page + file_info = parseFileInfo(FilefactoryCom, url, getURL(url)) + yield file_info class FilefactoryCom(SimpleHoster): __name__ = "FilefactoryCom" __type__ = "hoster" __pattern__ = r'https?://(?:www\.)?filefactory\.com/file/(?P<id>[a-zA-Z0-9]+)' - __version__ = "0.48" + __version__ = "0.49" __description__ = """Filefactory.com hoster plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" @@ -101,6 +113,3 @@ class FilefactoryCom(SimpleHoster): self.logDebug('DIRECT PREMIUM LINK: ' + url) self.download(url, disposition=True) - - -getInfo = create_getInfo(FilefactoryCom) -- cgit v1.2.3 From 521a8122e24cbcf27578e88d75fea356b4ea4a5f Mon Sep 17 00:00:00 2001 From: Stefano <l.stickell@yahoo.it> Date: Wed, 2 Jul 2014 15:17:50 +0200 Subject: [Filefactory] Improved offline pattern Forced english locale --- module/plugins/hoster/FilefactoryCom.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index 05edf6b99..ab0d3232f 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -35,15 +35,16 @@ class FilefactoryCom(SimpleHoster): __name__ = "FilefactoryCom" __type__ = "hoster" __pattern__ = r'https?://(?:www\.)?filefactory\.com/file/(?P<id>[a-zA-Z0-9]+)' - __version__ = "0.49" + __version__ = "0.50" __description__ = """Filefactory.com hoster plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" FILE_INFO_PATTERN = r'<div id="file_name"[^>]*>\s*<h2>(?P<N>[^<]+)</h2>\s*<div id="file_info">\s*(?P<S>[\d.]+) (?P<U>\w+) uploaded' DIRECT_LINK_PATTERN = r'<a href="(https?://[^"]+)"[^>]*><i[^>]*></i> Download with FileFactory Premium</a>' - FILE_OFFLINE_PATTERN = r'<h2>File Removed</h2>' + FILE_OFFLINE_PATTERN = r'<h2>File Removed</h2>|This file is no longer available' PREMIUM_ONLY_PATTERN = r'>Premium Account Required<' + SH_COOKIES = [('.filefactory.com', 'locale', 'en_US.utf8')] def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) -- cgit v1.2.3 From 93592862b520a862c01f80c019e5c4bc43746c19 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sat, 5 Jul 2014 16:54:20 +0200 Subject: [SimpleHoster] Better inline docs + changed "FILE_OFFLINE_PATTERN" to "OFFLINE_PATTERN" --- module/plugins/hoster/FilefactoryCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index ab0d3232f..d6a15b0ea 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -42,7 +42,7 @@ class FilefactoryCom(SimpleHoster): FILE_INFO_PATTERN = r'<div id="file_name"[^>]*>\s*<h2>(?P<N>[^<]+)</h2>\s*<div id="file_info">\s*(?P<S>[\d.]+) (?P<U>\w+) uploaded' DIRECT_LINK_PATTERN = r'<a href="(https?://[^"]+)"[^>]*><i[^>]*></i> Download with FileFactory Premium</a>' - FILE_OFFLINE_PATTERN = r'<h2>File Removed</h2>|This file is no longer available' + OFFLINE_PATTERN = r'<h2>File Removed</h2>|This file is no longer available' PREMIUM_ONLY_PATTERN = r'>Premium Account Required<' SH_COOKIES = [('.filefactory.com', 'locale', 'en_US.utf8')] -- cgit v1.2.3 From 04038a2cf0c4c2d9cc9a0c8e8bf9beb6426afae8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Thu, 10 Jul 2014 03:02:26 +0200 Subject: Use parseError instead PluginParseError + unified all download pattern attributes as LINK_PATTERN + removed some old patterns (not used anymore) + other code cosmetics --- module/plugins/hoster/FilefactoryCom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index d6a15b0ea..bcef5a5db 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -41,7 +41,7 @@ class FilefactoryCom(SimpleHoster): __author_mail__ = "l.stickell@yahoo.it" FILE_INFO_PATTERN = r'<div id="file_name"[^>]*>\s*<h2>(?P<N>[^<]+)</h2>\s*<div id="file_info">\s*(?P<S>[\d.]+) (?P<U>\w+) uploaded' - DIRECT_LINK_PATTERN = r'<a href="(https?://[^"]+)"[^>]*><i[^>]*></i> Download with FileFactory Premium</a>' + LINK_PATTERN = r'<a href="(https?://[^"]+)"[^>]*><i[^>]*></i> Download with FileFactory Premium</a>' OFFLINE_PATTERN = r'<h2>File Removed</h2>|This file is no longer available' PREMIUM_ONLY_PATTERN = r'>Premium Account Required<' SH_COOKIES = [('.filefactory.com', 'locale', 'en_US.utf8')] @@ -106,7 +106,7 @@ class FilefactoryCom(SimpleHoster): else: self.logInfo('You could enable "Direct Downloads" on http://filefactory.com/account/') html = self.load(self.pyfile.url) - found = re.search(self.DIRECT_LINK_PATTERN, html) + found = re.search(self.LINK_PATTERN, html) if found: url = found.group(1) else: -- cgit v1.2.3 From 05d258d98dd8c2faf0b769840fa1e3c4acccdce8 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 20 Jul 2014 03:25:14 +0200 Subject: Fix and improve 5060e4c6374a5116d0d8b02528f910f8c5f8bcf9 --- module/plugins/hoster/FilefactoryCom.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index bcef5a5db..0874e1410 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -66,7 +66,7 @@ class FilefactoryCom(SimpleHoster): else: # This section could be completely useless now # Load the page that contains the direct link url = re.search(r"document\.location\.host \+\s*'(.+)';", self.html) - if not url: + if url is None: self.parseError('Unable to detect free link') url = 'http://www.filefactory.com' + url.group(1) self.html = self.load(url, decode=True) -- cgit v1.2.3 From a9f81c043c62abcb3ce38971237693736833fdbe Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 20 Jul 2014 03:28:23 +0200 Subject: Fix hosters SH_COOKIES syntax --- module/plugins/hoster/FilefactoryCom.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index 0874e1410..013448b09 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -44,7 +44,9 @@ class FilefactoryCom(SimpleHoster): LINK_PATTERN = r'<a href="(https?://[^"]+)"[^>]*><i[^>]*></i> Download with FileFactory Premium</a>' OFFLINE_PATTERN = r'<h2>File Removed</h2>|This file is no longer available' PREMIUM_ONLY_PATTERN = r'>Premium Account Required<' - SH_COOKIES = [('.filefactory.com', 'locale', 'en_US.utf8')] + + SH_COOKIES = [(".filefactory.com", "locale", "en_US.utf8")] + def handleFree(self): self.html = self.load(self.pyfile.url, decode=True) -- cgit v1.2.3 From 9395182da7afed55a29bde1c7cbefe4204e783f0 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Sun, 20 Jul 2014 03:02:09 +0200 Subject: Store all re.search/match object as "m" instead "found" --- module/plugins/hoster/FilefactoryCom.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index 013448b09..98a97121c 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -108,9 +108,9 @@ class FilefactoryCom(SimpleHoster): else: self.logInfo('You could enable "Direct Downloads" on http://filefactory.com/account/') html = self.load(self.pyfile.url) - found = re.search(self.LINK_PATTERN, html) - if found: - url = found.group(1) + m = re.search(self.LINK_PATTERN, html) + if m: + url = m.group(1) else: self.parseError('Unable to detect premium direct link') -- cgit v1.2.3 From ba916633f2bedb04c7358000b91aed69f52e8e43 Mon Sep 17 00:00:00 2001 From: Walter Purcaro <vuolter@gmail.com> Date: Fri, 1 Aug 2014 19:35:59 +0200 Subject: Remove trailing whitespaces + remove license headers + import urllib methods directly + sort and fix key attributes + use save_join instead join + sort some import declarations + other minor code cosmetics --- module/plugins/hoster/FilefactoryCom.py | 20 ++++---------------- 1 file changed, 4 insertions(+), 16 deletions(-) (limited to 'module/plugins/hoster/FilefactoryCom.py') diff --git a/module/plugins/hoster/FilefactoryCom.py b/module/plugins/hoster/FilefactoryCom.py index 98a97121c..1ac7550fc 100644 --- a/module/plugins/hoster/FilefactoryCom.py +++ b/module/plugins/hoster/FilefactoryCom.py @@ -1,23 +1,9 @@ # -*- coding: utf-8 -*- -############################################################################ -# This program is free software: you can redistribute it and/or modify # -# it under the terms of the GNU Affero General Public License as # -# published by the Free Software Foundation, either version 3 of the # -# License, or (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU Affero General Public License for more details. # -# # -# You should have received a copy of the GNU Affero General Public License # -# along with this program. If not, see <http://www.gnu.org/licenses/>. # -############################################################################ import re -from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo from module.network.RequestFactory import getURL +from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo def getInfo(urls): @@ -34,8 +20,10 @@ def getInfo(urls): class FilefactoryCom(SimpleHoster): __name__ = "FilefactoryCom" __type__ = "hoster" - __pattern__ = r'https?://(?:www\.)?filefactory\.com/file/(?P<id>[a-zA-Z0-9]+)' __version__ = "0.50" + + __pattern__ = r'https?://(?:www\.)?filefactory\.com/file/(?P<id>[a-zA-Z0-9]+)' + __description__ = """Filefactory.com hoster plugin""" __author_name__ = "stickell" __author_mail__ = "l.stickell@yahoo.it" -- cgit v1.2.3