summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-13 00:47:02 +0100
committerGravatar zoidberg10 <zoidberg@mujmail.cz> 2011-11-13 00:47:02 +0100
commite3a62f8a2e9dcb4212f6fa8e1a94f832ad66d35a (patch)
tree121b107759d11e11890267355119ecf47e3e7fba
parentMerged in nick_de/pyload (pull request #5) (diff)
downloadpyload-e3a62f8a2e9dcb4212f6fa8e1a94f832ad66d35a.tar.xz
Move getFileInfo to SimpleHoster.py; update Mediafire
-rw-r--r--module/plugins/hoster/BezvadataCz.py65
-rw-r--r--module/plugins/hoster/DataportCz.py43
-rw-r--r--module/plugins/hoster/DepositfilesCom.py50
-rw-r--r--module/plugins/hoster/FilejungleCom.py44
-rw-r--r--module/plugins/hoster/FilepostCom.py42
-rw-r--r--module/plugins/hoster/FlyshareCz.py32
-rw-r--r--module/plugins/hoster/FourSharedCom.py99
-rw-r--r--module/plugins/hoster/HellshareCz.py55
-rw-r--r--module/plugins/hoster/HellspyCz.py28
-rw-r--r--module/plugins/hoster/IfileIt.py57
-rw-r--r--module/plugins/hoster/IfolderRu.py34
-rw-r--r--module/plugins/hoster/MediafireCom.py50
-rw-r--r--module/plugins/hoster/MegasharesCom.py63
-rw-r--r--module/plugins/hoster/MultishareCz.py47
-rw-r--r--module/plugins/hoster/QuickshareCz.py34
-rw-r--r--module/plugins/hoster/SendspaceCom.py53
-rw-r--r--module/plugins/hoster/ShareRapidCom.py32
-rw-r--r--module/plugins/hoster/StahnuTo.py51
-rw-r--r--module/plugins/hoster/UlozTo.py45
-rw-r--r--module/plugins/hoster/UloziskoSk.py74
-rw-r--r--module/plugins/hoster/UploadkingCom.py46
-rw-r--r--module/plugins/internal/SimpleHoster.py107
22 files changed, 365 insertions, 786 deletions
diff --git a/module/plugins/hoster/BezvadataCz.py b/module/plugins/hoster/BezvadataCz.py
index 71622885a..4c198d95f 100644
--- a/module/plugins/hoster/BezvadataCz.py
+++ b/module/plugins/hoster/BezvadataCz.py
@@ -17,50 +17,37 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
+from module.network.RequestFactory import getURL
-class BezvadataCz(Hoster):
+def getInfo(urls):
+ result = []
+
+ for url in urls:
+ file_info = parseFileInfo(BezvadataCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
+ yield result
+
+class BezvadataCz(SimpleHoster):
__name__ = "BezvadataCz"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)*bezvadata.cz/stahnout/.*"
- __version__ = "0.2"
+ __version__ = "0.21"
__description__ = """BezvaData.cz"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
- ID_PATTERN = r'<input type="hidden" name="souborId" value="([^"]+)">'
- HASH_PATTERN = r'<input type="hidden" name="souborHash" value="([^"]+)">'
- FILENAME_PATTERN = r'<title>BezvaData \| Sthnout soubor ([^<]+)</title>'
- OFFLINE_PATTERN = r'<title>BezvaData \| Soubor nenalezen</title>'
-
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url, decode = True)
-
- if re.search(self.OFFLINE_PATTERN, self.html) is not None:
- self.offline()
-
- found = re.search(self.FILENAME_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (FILENAME)")
- pyfile.name = found.group(1)
-
- found = re.search(self.ID_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (ID)")
- souborId = found.group(1)
-
- found = re.search(self.HASH_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (HASH)")
- souborHash = found.group(1)
-
- self.logDebug("URL:"+pyfile.url+" ID:"+souborId+" HASH:"+souborHash)
-
- self.download(pyfile.url, post = {
- "souborId": souborId,
- "souborHash": souborHash,
- "_send": 'STAHNOUT SOUBOR'
- }) \ No newline at end of file
+ FILE_NAME_PATTERN = r'<p><b>Soubor: ([^<]+)</b></p>'
+ FILE_SIZE_PATTERN = r'<li><strong>Velikost:</strong> ([0-9.]+) ([kKMG]i?B)</li>'
+ FILE_OFFLINE_PATTERN = r'<title>BezvaData \| Soubor nenalezen</title>'
+ DOWNLOAD_FORM_PATTERN = r'<form class="download" action="([^"]+)" method="post" id="frm-stahnoutForm">'
+
+ def handleFree(self):
+ found = re.search(self.DOWNLOAD_FORM_PATTERN, self.html)
+ if found is None: self.parseError("Download form")
+ url = "http://bezvadata.cz" + found.group(1)
+ self.logDebug("Download form: %s" % url)
+
+ self.download(url, post = {"stahnoutSoubor": "St%C3%A1hnout"}, cookies = True)
+ \ No newline at end of file
diff --git a/module/plugins/hoster/DataportCz.py b/module/plugins/hoster/DataportCz.py
index 896c4b47a..ed4ffa07c 100644
--- a/module/plugins/hoster/DataportCz.py
+++ b/module/plugins/hoster/DataportCz.py
@@ -17,59 +17,38 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
-
- html = getURL(url, decode=True)
- if re.search(DataportCz.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(DataportCz.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
- result.append((name, 0, 2, url))
+ file_info = parseFileInfo(DataportCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class DataportCz(Hoster):
+
+class DataportCz(SimpleHoster):
__name__ = "DataportCz"
__type__ = "hoster"
__pattern__ = r"http://.*dataport.cz/file/.*"
- __version__ = "0.3a"
- __description__ = """dataport.cz"""
+ __version__ = "0.32"
+ __description__ = """Dataport.cz plugin - free only"""
__author_name__ = ("zoidberg")
FILE_NAME_PATTERN = r'<h2 style="color: red;">([^<]+)</h2>'
+ FILE_SIZE_PATTERN = r'<td>Velikost souboru:</td>\s*<td>([0-9.]+)([kKMG]i?B)</td>'
URL_PATTERN = r'<td><a href="([^"]+)"[^>]*class="ui-state-default button hover ui-corner-all "><strong>'
NO_SLOTS_PATTERN = r'<td><a href="http://dataport.cz/kredit/"[^>]*class="ui-state-default button hover ui-corner-all ui-state-disabled">'
FILE_OFFLINE_PATTERN = r'<h2>Soubor nebyl nalezen</h2>'
-
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
-
- self.html = self.load(pyfile.url, decode=True)
-
- if re.search(self.FILE_OFFLINE_PATTERN, self.html):
- self.offline()
-
+
+ def handleFree(self):
if re.search(self.NO_SLOTS_PATTERN, self.html):
self.setWait(900, True)
self.wait()
self.retry(12, 0, "No free slots")
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (NAME)")
- pyfile.name = found.group(1)
-
found = re.search(self.URL_PATTERN, self.html)
if found is None:
self.fail("Parse error (URL)")
diff --git a/module/plugins/hoster/DepositfilesCom.py b/module/plugins/hoster/DepositfilesCom.py
index 81e6aa4d6..b02445005 100644
--- a/module/plugins/hoster/DepositfilesCom.py
+++ b/module/plugins/hoster/DepositfilesCom.py
@@ -2,8 +2,8 @@
# -*- coding: utf-8 -*-
import re
-import urllib
-from module.plugins.Hoster import Hoster
+from urllib import unquote
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
from module.plugins.ReCaptcha import ReCaptcha
@@ -11,31 +11,21 @@ def getInfo(urls):
result = []
for url in urls:
- html = getURL(re.sub(r"\.com(/.*?)?/files", ".com/en/files", url), decode=True)
- if re.search(DepositfilesCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(DepositfilesCom.FILE_INFO_PATTERN, html)
- if found is not None:
- name, size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(DepositfilesCom, url, getURL(re.sub(r"\.com(/.*?)?/files", ".com/en/files", url), decode=True))
+ result.append(file_info)
+
yield result
-class DepositfilesCom(Hoster):
+class DepositfilesCom(SimpleHoster):
__name__ = "DepositfilesCom"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?depositfiles\.com(/\w{1,3})?/files/[\w]+"
- __version__ = "0.34"
+ __version__ = "0.35"
__description__ = """Depositfiles.com Download Hoster"""
__author_name__ = ("spoob", "zoidberg")
__author_mail__ = ("spoob@pyload.org", "zoidberg@mujmail.cz")
- FILE_INFO_PATTERN = r'File name: <b title="([^"]+)">.*\s*<span class="nowrap">File size: <b>([0-9.]+)&nbsp;(KB|MB|GB)</b>'
+ FILE_INFO_PATTERN = r'File name: <b title="([^"]+)">.*\s*<span class="nowrap">File size: <b>([0-9.]+)&nbsp;([kKMG]i?B)</b>'
FILE_OFFLINE_PATTERN = r'<span class="html_download_api-not_exists"></span>'
RECAPTCHA_PATTERN = r"Recaptcha.create\('([^']+)', this\);"
DOWNLOAD_LINK_PATTERN = r'<form action="(http://.+?\.depositfiles.com/.+?)" method="get"'
@@ -46,22 +36,11 @@ class DepositfilesCom(Hoster):
self.pyfile.url = re.sub(r"\.com(/.*?)?/files", ".com/en/files", self.pyfile.url)
def process(self, pyfile):
-
if re.search(r"(.*)\.html", self.pyfile.url):
self.pyfile.url = re.search(r"(.*)\.html", self.pyfile.url).group(1)
self.html = self.load(self.pyfile.url, cookies=True if self.account else False, decode = True)
-
- if self.FILE_OFFLINE_PATTERN in self.html:
- self.offline()
-
- pyfile.name, size, units = re.search(self.FILE_INFO_PATTERN, self.html).groups()
- pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
- self.logDebug ("FILENAME: %s" % pyfile.name)
- #return_url = self.req.lastEffectiveURL.split("/", 3)[3]
- #self.html = self.load(r'http://depositfiles.com/switch_lang.php?return_url=%s&lang=en' % return_url)
-
- #pyfile.name = re.search('(?s)Dateiname: <b title=\"(.*?)\">.*?</b>', self.html).group(1)
+ self.getFileInfo()
if self.account:
self.handlePremium()
@@ -70,8 +49,6 @@ class DepositfilesCom(Hoster):
def handleFree(self):
- self.html = self.load(self.pyfile.url, post={"gateway_result":"1"})
-
if re.search(r'File is checked, please try again in a minute.', self.html) is not None:
self.log.info("DepositFiles.com: The file is being checked. Waiting 1 minute.")
self.setWait(61)
@@ -112,8 +89,9 @@ class DepositfilesCom(Hoster):
for i in range(5):
self.html = self.load("http://depositfiles.com/get_file.php", get = params)
+
if '<input type=button value="Continue" onclick="check_recaptcha' in self.html:
- if not captcha_key: self.fail('Parse error (Captcha key)')
+ if not captcha_key: raise PluginParseError('Captcha key')
if 'response' in params: self.invalidCaptcha()
params['challenge'], params['response'] = recaptcha.challenge(captcha_key)
self.logDebug(params)
@@ -122,11 +100,11 @@ class DepositfilesCom(Hoster):
found = re.search(self.DOWNLOAD_LINK_PATTERN, self.html)
if found:
if 'response' in params: self.correctCaptcha()
- link = urllib.unquote(found.group(1))
+ link = unquote(found.group(1))
self.logDebug ("LINK: %s" % link)
break
else:
- self.fail('Parse error (Download link)')
+ raise PluginParseError('Download link')
else:
self.fail('No valid captcha response received')
@@ -136,5 +114,5 @@ class DepositfilesCom(Hoster):
self.retry(wait_time = 60)
def handlePremium(self):
- link = urllib.unquote(re.search('<div id="download_url">\s*<a href="(http://.+?\.depositfiles.com/.+?)"', self.html).group(1))
+ link = unquote(re.search('<div id="download_url">\s*<a href="(http://.+?\.depositfiles.com/.+?)"', self.html).group(1))
self.download(link) \ No newline at end of file
diff --git a/module/plugins/hoster/FilejungleCom.py b/module/plugins/hoster/FilejungleCom.py
index 53681d350..597d1aa3f 100644
--- a/module/plugins/hoster/FilejungleCom.py
+++ b/module/plugins/hoster/FilejungleCom.py
@@ -17,7 +17,7 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
from module.plugins.ReCaptcha import ReCaptcha
@@ -25,26 +25,16 @@ def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(FilejungleCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(FilejungleCom.FILE_INFO_PATTERN, html)
- if found is not None:
- name, size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(FilejungleCom, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-class FilejungleCom(Hoster):
+class FilejungleCom(SimpleHoster):
__name__ = "FilejungleCom"
__type__ = "hoster"
__pattern__ = r"http://(?:www\.)?filejungle\.com/f/([^/]+).*"
- __version__ = "0.2"
+ __version__ = "0.22"
__description__ = """Filejungle.com plugin - free only"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
@@ -54,24 +44,8 @@ class FilejungleCom(Hoster):
RECAPTCHA_KEY_PATTERN = r"var reCAPTCHA_publickey='([^']+)'"
WAIT_TIME_PATTERN = r'<h1>Please wait for (\d+) seconds to download the next file\.</h1>'
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url)
- self.getFileInfo(pyfile)
- self.handleFree(pyfile)
-
- def getFileInfo(self, pyfile):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_INFO_PATTERN, self.html)
- if not found: self.fail("Parse error (file info)")
- pyfile.name, size, units = found.groups()
- pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- def handleFree(self, pyfile):
- file_id = re.search(self.__pattern__, pyfile.url).group(1)
+ def handleFree(self):
+ file_id = re.search(self.__pattern__, self.pyfile.url).group(1)
url = "http://www.filejungle.com/f/%s" % file_id
self.logDebug("File ID: %s" % file_id)
@@ -80,7 +54,7 @@ class FilejungleCom(Hoster):
if not found: self.fail("Captcha key not found")
captcha_key = found.group(1)
- json_response = self.load(pyfile.url, post = {"checkDownload" : "check"}, decode = True)
+ json_response = self.load(self.pyfile.url, post = {"checkDownload" : "check"}, decode = True)
self.logDebug(json_response)
if r'"success":"showCaptcha"' in json_response:
recaptcha = ReCaptcha(self)
diff --git a/module/plugins/hoster/FilepostCom.py b/module/plugins/hoster/FilepostCom.py
index 319d85214..779eef1d2 100644
--- a/module/plugins/hoster/FilepostCom.py
+++ b/module/plugins/hoster/FilepostCom.py
@@ -17,7 +17,7 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
from module.plugins.ReCaptcha import ReCaptcha
from module.common.json_layer import json_loads
@@ -27,26 +27,16 @@ def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(FilepostCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(FilepostCom.FILE_INFO_PATTERN, html)
- if found is not None:
- name, size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(FilepostCom, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-class FilepostCom(Hoster):
+class FilepostCom(SimpleHoster):
__name__ = "FilepostCom"
__type__ = "hoster"
__pattern__ = r"https?://(?:www\.)?filepost\.com/files/([^/]+).*"
- __version__ = "0.2"
+ __version__ = "0.22"
__description__ = """Filepost.com plugin - free only"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
@@ -56,25 +46,9 @@ class FilepostCom(Hoster):
RECAPTCHA_KEY_PATTERN = r"Captcha.init\({\s*key:\s*'([^']+)'"
FLP_TOKEN_PATTERN = r"store.set\('flp_token', '([^']+)'\);"
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url)
- self.getFileInfo(pyfile)
- self.handleFree(pyfile)
-
- def getFileInfo(self, pyfile):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_INFO_PATTERN, self.html)
- if not found: self.fail("Parse error (file info)")
- pyfile.name, size, units = found.groups()
- pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- def handleFree(self, pyfile):
+ def handleFree(self):
# Find token and captcha key
- file_id = re.search(self.__pattern__, pyfile.url).group(1)
+ file_id = re.search(self.__pattern__, self.pyfile.url).group(1)
found = re.search(self.FLP_TOKEN_PATTERN, self.html)
if not found: self.fail("Parse error (token)")
flp_token = found.group(1)
diff --git a/module/plugins/hoster/FlyshareCz.py b/module/plugins/hoster/FlyshareCz.py
index eb07f3d9e..fc7e9f13b 100644
--- a/module/plugins/hoster/FlyshareCz.py
+++ b/module/plugins/hoster/FlyshareCz.py
@@ -17,31 +17,23 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(FlyshareCz.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(FlyshareCz.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
- result.append((name, 0, 2, url))
+ file_info = parseFileInfo(FlyshareCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class FlyshareCz(Hoster):
+class FlyshareCz(SimpleHoster):
__name__ = "FlyshareCz"
__type__ = "hoster"
__pattern__ = r"http://.*flyshare.cz/stahni/.*"
- __version__ = "0.3"
+ __version__ = "0.31"
__description__ = """flyshare.cz"""
__author_name__ = ("zoidberg")
@@ -49,9 +41,6 @@ class FlyshareCz(Hoster):
ERR_PATTERN = r'<p class="errorreport_error">Chyba: ([^<]+)</p>'
FILE_OFFLINE_PATTERN = r'<p class="errorreport_error">Chyba: File is not available on the server</p>'
- def setup(self):
- self.multiDL = False
-
def process(self, pyfile):
self.html = self.load(pyfile.url, decode=True)
@@ -65,12 +54,11 @@ class FlyshareCz(Hoster):
else:
self.fail(err_dsc)
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None:
- self.fail("Parse error")
- pyfile.name = found.group(1)
+ self.getFileInfo()
+ self.handleFree()
- self.download(pyfile.url, post={
+ def handleFree(self):
+ self.download(self.pyfile.url, post={
"wmod_command": "wmod_fileshare3:startDownload",
"method": "free"
})
diff --git a/module/plugins/hoster/FourSharedCom.py b/module/plugins/hoster/FourSharedCom.py
index 03da15fb0..1c12a2d34 100644
--- a/module/plugins/hoster/FourSharedCom.py
+++ b/module/plugins/hoster/FourSharedCom.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster
from module.network.RequestFactory import getURL
import re
@@ -9,82 +9,47 @@ def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(FourSharedCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(FourSharedCom.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = float(found.group(1).replace(',','')), found.group(2)
- size = size * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(FourSharedCom.FILE_NAME_PATTERN, html)
- if found is not None:
- name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), found.group(1))
-
- if found or size > 0:
- result.append((name, size, 2, url))
+ name, size, status, url = parseFileInfo(FourSharedCom, url, getURL(url, decode=True))
+ if status == 2:
+ name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), name)
+ result.append(name, size, status, url)
+
yield result
-
-class FourSharedCom(Hoster):
+class FourSharedCom(SimpleHoster):
__name__ = "FourSharedCom"
__type__ = "hoster"
__pattern__ = r"http://[\w\.]*?4shared(-china)?\.com/(account/)?(download|get|file|document|photo|video|audio)/.+?/.*"
- __version__ = "0.2"
+ __version__ = "0.21"
__description__ = """4Shared Download Hoster"""
__author_name__ = ("jeix", "zoidberg")
__author_mail__ = ("jeix@hasnomail.de", "zoidberg@mujmail.cz")
FILE_NAME_PATTERN = '<meta name="title" content="([^"]+)" />'
- FILE_SIZE_PATTERN = '<span title="Size: ([0-9,.]+) (KB|MB|GB)">'
- FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.'
-
- def setup(self):
- self.multiDL = False
+ FILE_SIZE_PATTERN = '<span title="Size: ([0-9,.]+) ([kKMG]i?B)">'
+ FILE_OFFLINE_PATTERN = 'The file link that you requested is not valid\.|This file was deleted.'
+ FREE_LINK_PATTERN = '<a href="([^"]+)" class="dbtn"'
+ DOWNLOAD_URL_PATTERN = "<div class=\"(?:dl|xxlarge bold)\">\s*<a href='([^']+)'"
def process(self, pyfile):
-
self.html = self.load(pyfile.url, decode=True)
- self.getFileInfo(pyfile)
- self.handleFree(pyfile)
-
- def getFileInfo(self, pyfile):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if not found: self.fail("Parse error (file name)")
- pyfile.name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), found.group(1))
-
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if found is None: self.fail("Parse error (file size)")
- size, units = float(found.group(1).replace(',','')), found.group(2)
- pyfile.size = size * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- def handleFree(self, pyfile):
- tmp_link = link = ""
- wait = 20
-
- for line in self.html.splitlines():
- if "dbtn" in line:
- tmp_link = line.split('href="')[1].split('"')[0]
-
- if tmp_link:
- self.html = self.load(tmp_link).splitlines()
- for i, line in enumerate(self.html):
- if "id='divDLStart'" in line:
- link = self.html[i+2].split("<a href='")[1].split("'")[0]
- elif '<div class="sec">' in line:
- wait = int(line.split(">")[1].split("<")[0])
-
- self.setWait(wait)
- self.wait()
-
- if link:
- self.download(link)
- else:
- self.offline() \ No newline at end of file
+ self.getFileInfo()
+ pyfile.name = re.sub(r"&#(\d+).", lambda m: unichr(int(m.group(1))), pyfile.name)
+ self.handleFree()
+
+ def handleFree(self):
+ found = re.search(self.FREE_LINK_PATTERN, self.html)
+ if not found: raise PluginParseError('Free download button')
+ link = found.group(1)
+
+ self.html = self.load(link)
+
+ found = re.search(self.DOWNLOAD_URL_PATTERN, self.html)
+ if not found: raise PluginParseError('Download link')
+ link = found.group(1)
+
+ self.setWait(20)
+ self.wait()
+ self.download(link)
+
+ \ No newline at end of file
diff --git a/module/plugins/hoster/HellshareCz.py b/module/plugins/hoster/HellshareCz.py
index c067dc40d..d2f5c8e40 100644
--- a/module/plugins/hoster/HellshareCz.py
+++ b/module/plugins/hoster/HellshareCz.py
@@ -18,42 +18,27 @@
import re
import datetime
-from math import ceil
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(HellshareCz.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(HellshareCz.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = found.groups()
- size = float(size) * 1024 ** {'kB': 1, 'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(HellshareCz.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if found or size > 0:
- result.append((name, 0, 2, url))
+ file_info = parseFileInfo(HellshareCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-class HellshareCz(Hoster):
+class HellshareCz(SimpleHoster):
__name__ = "HellshareCz"
__type__ = "hoster"
__pattern__ = r"http://(?:.*\.)*hellshare\.(?:cz|com|sk|hu)/[^?]*/(\d+).*"
- __version__ = "0.73"
+ __version__ = "0.74"
__description__ = """Hellshare.cz"""
__author_name__ = ("zoidberg")
- FREE_URL_PATTERN = r'<h3>I\'ll wait.*\s*<form action="([^"]*)"'
+ FREE_URL_PATTERN = r'<form[^>]*action="(http://free\d*\.helldata[^"]*)"'
PREMIUM_URL_PATTERN = r"launchFullDownload\('([^']*)'\);"
FILE_NAME_PATTERN = r'<h1 id="filename">([^<]+)</h1>'
FILE_SIZE_PATTERN = r'<td><span>Size</span></td>\s*<th><span>([0-9.]*)&nbsp;(kB|KB|MB|GB)</span></th>'
@@ -73,7 +58,7 @@ class HellshareCz(Hoster):
pyfile.url = re.search(r'([^?]*)', pyfile.url).group(1)
self.html = self.load(pyfile.url, decode = True)
- self.getFileInfo(pyfile)
+ self.getFileInfo()
if "do=relatedFileDownloadButton" in self.html:
found = re.search(self.__pattern__, self.pyfile.url)
@@ -87,22 +72,6 @@ class HellshareCz(Hoster):
else:
self.handleFree()
- def getFileInfo(self, pyfile):
- #marks the file as "offline" when the pattern was found on the html-page
- if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None:
- self.offline()
-
- # parse the name from the site and set attribute in pyfile
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (Filename")
- pyfile.name = found.group(1)
-
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if found is not None:
- size, units = found.groups()
- pyfile.size = float(size) * 1024 ** {'kB': 1, 'KB': 1, 'MB': 2, 'GB': 3}[units]
-
def handleFree(self):
# hellshare is very generous
if "You exceeded your today's limit for free download. You can download only 1 files per 24 hours." in self.html:
@@ -114,23 +83,23 @@ class HellshareCz(Hoster):
# parse free download url
found = re.search(self.FREE_URL_PATTERN, self.html)
- if found is None: self.fail("Parse error (URL)")
+ if found is None: self.parseError("Free URL)")
parsed_url = found.group(1)
self.logDebug("Free URL: %s" % parsed_url)
# decrypt captcha
found = re.search(self.CAPTCHA_PATTERN, self.html)
- if found is None: self.fail("Parse error (Captcha)")
+ if found is None: self.parseError("Captcha")
captcha_url = found.group(1)
captcha = self.decryptCaptcha(captcha_url)
self.logDebug('CAPTCHA_URL:' + captcha_url + ' CAPTCHA:' + captcha)
-
+
self.download(parsed_url, post = {"captcha" : captcha, "submit" : "Download"})
# check download
check = self.checkDownload({
- "wrong_captcha": "<p>Incorrectly copied code from the image</p>"
+ "wrong_captcha": re.compile(self.FREE_URL_PATTERN)
})
if check == "wrong_captcha":
diff --git a/module/plugins/hoster/HellspyCz.py b/module/plugins/hoster/HellspyCz.py
index fb7fa41dc..e1077a0cb 100644
--- a/module/plugins/hoster/HellspyCz.py
+++ b/module/plugins/hoster/HellspyCz.py
@@ -17,39 +17,23 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
-
- html = getURL(url, decode=True)
- if re.search(HellspyCz.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(HellspyCz.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
- found = re.search(HellspyCz.FILE_CREDITS_PATTERN, html)
- if found is not None:
- size = float(found.group(1))
- units = found.group(2)
-
- pow = {'kB' : 1, 'MB' : 2, 'GB' : 3}[units]
- size = int(size*1024**pow)
-
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(HellspyCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-class HellspyCz(Hoster):
+class HellspyCz(SimpleHoster):
__name__ = "HellspyCz"
__type__ = "hoster"
__pattern__ = r"http://(?:\w*\.)*hellspy\.(?:cz|com|sk|hu)(/\S+/\d+)/?.*"
- __version__ = "0.2"
+ __version__ = "0.21"
__description__ = """HellSpy.cz"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
diff --git a/module/plugins/hoster/IfileIt.py b/module/plugins/hoster/IfileIt.py
index 2b70729a9..3bc60220a 100644
--- a/module/plugins/hoster/IfileIt.py
+++ b/module/plugins/hoster/IfileIt.py
@@ -17,62 +17,39 @@
"""
import re
-
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.common.json_layer import json_loads
-from module.common.JsEngine import JsEngine
from module.plugins.ReCaptcha import ReCaptcha
-from module.plugins.Hoster import Hoster
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(IfileIt.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(IfileIt.FILE_INFO_PATTERN, html)
- if found is not None:
- name, size, units = found.groups()
- size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units]
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(IfileIt, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class IfileIt(Hoster):
+class IfileIt(SimpleHoster):
__name__ = "IfileIt"
__type__ = "hoster"
- __pattern__ = r"http://(?:\w*\.)*ifile\.it/.*"
- __version__ = "0.2"
+ __pattern__ = r"http://(?:\w*\.)*ifile\.it/(\w+).*"
+ __version__ = "0.22"
__description__ = """Ifile.it"""
__author_name__ = ("zoidberg")
- EVAL_PATTERN = r'(eval\(function\(p,a,c,k,e,d\).*)'
- DEC_PATTERN = r"function requestBtn_clickEvent[^}]*url:\s*([^,]+)"
+ #EVAL_PATTERN = r'(eval\(function\(p,a,c,k,e,d\).*)'
+ #DEC_PATTERN = r"requestBtn_clickEvent[^}]*url:\s*([^,]+)"
DOWNLOAD_LINK_PATTERN = r'</span> If it doesn\'t, <a target="_blank" href="([^"]+)">'
RECAPTCHA_KEY_PATTERN = r"var __recaptcha_public\s*=\s*'([^']+)';"
- FILE_INFO_PATTERN = r'<span style="cursor: default;[^>]*>\s*(.*?)\s*&nbsp;\s*<strong>\s*([0-9.]+)\s*(kB|MB|GB)\s*</strong>\s*</span>'
+ FILE_INFO_PATTERN = r'<span style="cursor: default;[^>]*>\s*(.*?)\s*&nbsp;\s*<strong>\s*([0-9.]+)\s*([kKMG]i?B)\s*</strong>\s*</span>'
FILE_OFFLINE_PATTERN = r'$\("#errorPnl"\)\.empty\(\)\.append\( "no such file" \);'
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url)
-
- found = re.search(self.FILE_INFO_PATTERN, self.html)
- pyfile.name = found.group(1)
- pyfile.size = pyfile.size = float(found.group(2)) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[found.group(3)]
-
- eval_string = re.search(self.EVAL_PATTERN, self.html).group(1)
- dec_string = re.search(self.DEC_PATTERN, self.html).group(1)
-
- js = JsEngine()
- json_url = js.eval(eval_string + ";" + dec_string)
- self.logDebug(json_url)
-
+
+ def handleFree(self):
+ ukey = re.search(self.__pattern__, self.pyfile.url).group(1)
+ json_url = 'http://ifile.it/download-request2.json?ukey=' + ukey
+
json_response = json_loads(self.load(json_url))
self.logDebug(json_response)
if json_response["captcha"]:
@@ -98,8 +75,8 @@ class IfileIt(Hoster):
self.fail("Incorrect captcha")
# load twice
- self.html = self.load(pyfile.url)
- self.html = self.load(pyfile.url)
+ self.html = self.load(self.pyfile.url)
+ self.html = self.load(self.pyfile.url)
download_url = re.search(self.DOWNLOAD_LINK_PATTERN, self.html).group(1)
self.download(download_url) \ No newline at end of file
diff --git a/module/plugins/hoster/IfolderRu.py b/module/plugins/hoster/IfolderRu.py
index c0e45a87a..8a8e18282 100644
--- a/module/plugins/hoster/IfolderRu.py
+++ b/module/plugins/hoster/IfolderRu.py
@@ -18,39 +18,28 @@
import re
from urllib import quote
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
-
- html = getURL(url, decode=True)
- if re.search(IfolderRu.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(IfolderRu.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
- found = re.search(IfolderRu.FILE_SIZE_PATTERN, html)
- if found is not None:
- size = float(found.group(1)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(2)]
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(IfolderRu, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-class IfolderRu(Hoster):
+class IfolderRu(SimpleHoster):
__name__ = "IfolderRu"
__type__ = "hoster"
__pattern__ = r"http://(?:\w*\.)?ifolder.ru/(\d+).*"
- __version__ = "0.31"
+ __version__ = "0.32"
__description__ = """ifolder.ru"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
-
+ SIZE_UNITS = {u'Кб': 1, u'Мб': 2, u'Гб': 3}
FILE_NAME_PATTERN = ur'(?:<div><span>)?Название:(?:</span>)? <b>([^<]+)</b><(?:/div|br)>'
FILE_SIZE_PATTERN = ur'(?:<div><span>)?Размер:(?:</span>)? <b>([0-9.]+) ([^<]+)</b><(?:/div|br)>'
SESSION_ID_PATTERN = r'<a href=(http://ints.ifolder.ru/ints/sponsor/\?bi=\d*&session=([^&]+)&u=[^>]+)>'
@@ -69,14 +58,7 @@ class IfolderRu(Hoster):
def process(self, pyfile):
file_id = re.search(self.__pattern__, pyfile.url).group(1)
self.html = self.load("http://ifolder.ru/%s" % file_id, cookies=True, decode=True)
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if not found: self.fail("Parse error (File name)")
- pyfile.name = found.group(1)
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if not found: self.fail("Parse error (File size)")
- pyfile.size = float(found.group(1)) * 1024 ** {u'Кб': 1, u'Мб': 2, u'Гб': 3}[found.group(2)]
+ self.getFileInfo()
url = "http://ints.ifolder.ru/ints/?ifolder.ru/%s?ints_code=" % file_id
self.html = self.load(url, cookies=True, decode=True)
diff --git a/module/plugins/hoster/MediafireCom.py b/module/plugins/hoster/MediafireCom.py
index e06447c7c..15fc9f3c6 100644
--- a/module/plugins/hoster/MediafireCom.py
+++ b/module/plugins/hoster/MediafireCom.py
@@ -17,7 +17,7 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
from module.plugins.ReCaptcha import ReCaptcha
@@ -25,35 +25,19 @@ def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(MediafireCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(MediafireCom.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = found.group(1), found.group(2).replace('k','K')
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(MediafireCom.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if found or size > 0:
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(MediafireCom, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
def replace_eval(js_expr):
return js_expr.replace(r'eval("', '').replace(r"\'", r"'").replace(r'\"', r'"')
-class MediafireCom(Hoster):
+class MediafireCom(SimpleHoster):
__name__ = "MediafireCom"
__type__ = "hoster"
__pattern__ = r"http://(?:\w*\.)*mediafire\.com/.*"
- __version__ = "0.61"
+ __version__ = "0.64"
__description__ = """Mediafire.com plugin - free only"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
@@ -72,29 +56,9 @@ class MediafireCom(Hoster):
FINAL_LINK_PATTERN = r'parent.document.getElementById\(\'(\w{32})\'\).*(http://[^"]+)" \+(\w+)\+ "([^"]+)">'
FILE_NAME_PATTERN = r'<META NAME="description" CONTENT="([^"]+)"/>'
- FILE_SIZE_PATTERN = r'<div style="font-size:14px;padding-top:12px;color:#777;">\(([0-9.]+) (kB|KB|MB|GB)\)</div>'
+ FILE_SIZE_PATTERN = r'<input type="hidden" id="sharedtabsfileinfo1-fs" value="([0-9.]+) ([kKMG]i?B)">'
FILE_OFFLINE_PATTERN = r'class="error_msg_title"> Invalid or Deleted File. </div>'
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url, decode=True)
- self.getFileInfo(pyfile)
- self.handleFree()
-
- def getFileInfo(self, pyfile):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if not found: self.fail("Parse error (file name)")
- pyfile.name = found.group(1)
-
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if found:
- size, units = found.group(1), found.group(2).replace('k','K')
- pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
def handleFree(self):
found = re.search(self.RECAPTCHA_PATTERN, self.html)
if found:
diff --git a/module/plugins/hoster/MegasharesCom.py b/module/plugins/hoster/MegasharesCom.py
index 0a326c268..3c17eb979 100644
--- a/module/plugins/hoster/MegasharesCom.py
+++ b/module/plugins/hoster/MegasharesCom.py
@@ -18,40 +18,23 @@
import re
from time import time
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(MegasharesCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(MegasharesCom.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(MegasharesCom.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if found or size > 0:
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(MegasharesCom, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class MegasharesCom(Hoster):
+class MegasharesCom(SimpleHoster):
__name__ = "MegasharesCom"
__type__ = "hoster"
__pattern__ = r"http://(\w+\.)?megashares.com/.*"
- __version__ = "0.1"
+ __version__ = "0.12"
__description__ = """megashares.com plugin - free only"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
@@ -59,35 +42,23 @@ class MegasharesCom(Hoster):
FILE_NAME_PATTERN = '<h1 class="black xxl"[^>]*title="([^"]+)">'
FILE_SIZE_PATTERN = '<strong><span class="black">Filesize:</span></strong> ([0-9.]+) (KB|MB|GB)<br />'
DOWNLOAD_URL_PATTERN = '<div id="show_download_button_2" style="display:none">\s*<a href="([^"]+)">'
- PASSPORT_LEFT_PATTERN = 'Your Download Passport is: <[^>]*>(\w+).*\s*You have\s*<[^>]*>\s*([0-9.]+) (KB|MB|GB)'
+ PASSPORT_LEFT_PATTERN = 'Your Download Passport is: <[^>]*>(\w+).*\s*You have\s*<[^>]*>\s*([0-9.]+) ([kKMG]i?B)'
PASSPORT_RENEW_PATTERN = 'Your download passport will renew in\s*<strong>(\d+)</strong>:<strong>(\d+)</strong>:<strong>(\d+)</strong>'
REACTIVATE_NUM_PATTERN = r'<input[^>]*id="random_num" value="(\d+)" />'
REACTIVATE_PASSPORT_PATTERN = r'<input[^>]*id="passport_num" value="(\w+)" />'
REQUEST_URI_PATTERN = r'var request_uri = "([^"]+)";'
-
- FILE_OFFLINE_PATTERN = r'<dd class="red">Invalid Link Request - file does not exist.</dd>'
-
- def setup(self):
- self.multiDL = False
+ NO_SLOTS_PATTERN = r'<dd class="red">All download slots for this link are currently filled'
+ FILE_OFFLINE_PATTERN = r'<dd class="red">(Invalid Link Request|Link has been deleted)'
def process(self, pyfile):
self.html = self.load(pyfile.url, decode=True)
- self.getFileInfo(pyfile)
- self.handleFree(pyfile)
-
- def getFileInfo(self, pyfile):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None: self.fail("Parse error (file name)")
- pyfile.name = found.group(1)
-
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if found is None: self.fail("Parse error (file size)")
- pyfile.size = float(found.group(1)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(2)]
+ if self.NO_SLOTS_PATTERN in self.html:
+ self.retry(wait_time = 300)
+ self.getFileInfo()
+ self.handleFree()
- def handleFree(self, pyfile):
- if pyfile.size > 576716800: self.fail("This file is too large for free download")
+ def handleFree(self):
+ if self.pyfile.size > 576716800: self.fail("This file is too large for free download")
# Reactivate passport if needed
found = re.search(self.REACTIVATE_PASSPORT_PATTERN, self.html)
@@ -119,8 +90,8 @@ class MegasharesCom(Hoster):
if not found: self.fail('Passport not found')
self.logInfo("Download passport: %s" % found.group(1))
data_left = float(found.group(2)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(3)]
- self.logInfo("Data left: %s %s (%d MB needed)" % (found.group(2), found.group(3), pyfile.size / 1048576))
- if pyfile.size > data_left:
+ self.logInfo("Data left: %s %s (%d MB needed)" % (found.group(2), found.group(3), self.pyfile.size / 1048576))
+ if self.pyfile.size > data_left:
found = re.search(self.PASSPORT_RENEW_PATTERN, self.html)
if not found: self.fail('Passport renew time not found')
renew = found.group(1) + 60 * (found.group(2) + 60 * found.group(3))
diff --git a/module/plugins/hoster/MultishareCz.py b/module/plugins/hoster/MultishareCz.py
index d8dfeaed9..ac35d93e1 100644
--- a/module/plugins/hoster/MultishareCz.py
+++ b/module/plugins/hoster/MultishareCz.py
@@ -17,67 +17,36 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- try:
- html = getURL(url, decode=True)
- except Exception:
- result.append((url, 0, 1, url))
- else:
- if re.search(MultishareCz.OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(MultishareCz.FILE_INFO_PATTERN, html)
- if found is not None:
- name = found.group(1)
- size = float(found.group(2))
- units = found.group(3)
-
- pow = {'KB': 1, 'MB': 2, 'GB': 3}[units]
- size = int(size * 1024 ** pow)
-
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(MultishareCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class MultishareCz(Hoster):
+class MultishareCz(SimpleHoster):
__name__ = "MultishareCz"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)?multishare.cz/stahnout/.*"
- __version__ = "0.3"
+ __version__ = "0.31"
__description__ = """MultiShare.cz"""
__author_name__ = ("zoidberg")
FILE_ID_PATTERN = r'/stahnout/(\d+)/'
FILE_INFO_PATTERN = ur'<ul class="no-padding"><li>Název: <strong>([^<]+)</strong></li><li>Velikost: <strong>([^&]+)&nbsp;([^<]+)</strong>'
- OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>'
-
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url, decode=True)
-
- if re.search(self.OFFLINE_PATTERN, self.html) is not None:
- self.offline()
+ FILE_OFFLINE_PATTERN = ur'<h1>Stáhnout soubor</h1><p><strong>Požadovaný soubor neexistuje.</strong></p>'
+ def handleFree(self):
found = re.search(self.FILE_ID_PATTERN, pyfile.url)
if found is None:
self.fail("Parse error (ID)")
file_id = found.group(1)
- found = re.search(self.FILE_INFO_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (NAME)")
- pyfile.name = found.group(1)
-
self.download("http://www.multishare.cz/html/download_free.php", get={
"ID": file_id
}) \ No newline at end of file
diff --git a/module/plugins/hoster/QuickshareCz.py b/module/plugins/hoster/QuickshareCz.py
index acfafaa53..4c82ff1a9 100644
--- a/module/plugins/hoster/QuickshareCz.py
+++ b/module/plugins/hoster/QuickshareCz.py
@@ -17,45 +17,23 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- try:
- html = getURL(url, decode=True)
-
- if re.search(QuickshareCz.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(QuickshareCz.VAR_PATTERN, html)
- if found is not None:
- name = found.group('ID3')
-
- found = re.search(QuickshareCz.FILE_SIZE_PATTERN, html)
- if found is not None:
- size = float(found.group(1))
- units = found.group(2)
-
- pow = {'kB': 1, 'MB': 2, 'GB': 3}[units]
- size = int(size * 1024 ** pow)
-
- result.append((name, size, 2, url))
- except:
- result.append((url, 0, 1, url))
-
+ file_info = parseFileInfo(QuickshareCz, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class QuickshareCz(Hoster):
+class QuickshareCz(SimpleHoster):
__name__ = "QuickshareCz"
__type__ = "hoster"
__pattern__ = r"http://.*quickshare.cz/stahnout-soubor/.*"
- __version__ = "0.5"
+ __version__ = "0.51"
__description__ = """Quickshare.cz"""
__author_name__ = ("zoidberg")
diff --git a/module/plugins/hoster/SendspaceCom.py b/module/plugins/hoster/SendspaceCom.py
index 1d65945c7..b28df29f9 100644
--- a/module/plugins/hoster/SendspaceCom.py
+++ b/module/plugins/hoster/SendspaceCom.py
@@ -17,67 +17,34 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(SendspaceCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(SendspaceCom.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(SendspaceCom.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if found or size > 0:
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(SendspaceCom, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class SendspaceCom(Hoster):
+class SendspaceCom(SimpleHoster):
__name__ = "SendspaceCom"
__type__ = "hoster"
__pattern__ = r"http://(www\.)?sendspace.com/file/.*"
- __version__ = "0.1"
+ __version__ = "0.12"
__description__ = """sendspace.com plugin - free only"""
__author_name__ = ("zoidberg")
DOWNLOAD_URL_PATTERN = r'<a id="download_button" href="([^"]+)"'
FILE_NAME_PATTERN = r'<h2 class="bgray">\s*<(?:b|strong)>([^<]+)</'
- FILE_SIZE_PATTERN = r'<div class="file_description reverse margin_center">\s*<b>File Size:</b>\s*([0-9.]+)(KB|MB|GB)\s*</div>'
+ FILE_SIZE_PATTERN = r'<div class="file_description reverse margin_center">\s*<b>File Size:</b>\s*([0-9.]+)([kKMG]i?B)\s*</div>'
FILE_OFFLINE_PATTERN = r'<div class="msg error" style="cursor: default">Sorry, the file you requested is not available.</div>'
CAPTCHA_PATTERN = r'<td><img src="(/captchas/captcha.php?captcha=([^"]+))"></td>'
USER_CAPTCHA_PATTERN = r'<td><img src="/captchas/captcha.php?user=([^"]+))"></td>'
-
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url, decode=True)
-
- if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None:
- self.offline()
-
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None: self.fail("Parse error (file name)")
- pyfile.name = found.group(1)
-
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if found is None: self.fail("Parse error (file size)")
- pyfile.size = float(found.group(1)) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[found.group(2)]
-
+
+ def handleFree(self):
params = {}
for i in range(3):
found = re.search(self.DOWNLOAD_URL_PATTERN, self.html)
@@ -100,7 +67,7 @@ class SendspaceCom(Hoster):
params = {'download': "Regular Download"}
self.logDebug(params)
- self.html = self.load(pyfile.url, post = params)
+ self.html = self.load(self.pyfile.url, post = params)
else:
self.fail("Download link not found")
diff --git a/module/plugins/hoster/ShareRapidCom.py b/module/plugins/hoster/ShareRapidCom.py
index 46818a84c..17c981b61 100644
--- a/module/plugins/hoster/ShareRapidCom.py
+++ b/module/plugins/hoster/ShareRapidCom.py
@@ -5,7 +5,7 @@ import re
from pycurl import HTTPHEADER
from module.network.RequestFactory import getRequest
from module.network.HTTPRequest import BadHeader
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
def getInfo(urls):
result = []
@@ -16,34 +16,18 @@ def getInfo(urls):
h.c.setopt(HTTPHEADER, ["Accept: text/html"])
html = h.load(url, cookies = True, decode = True)
- if re.search(ShareRapidCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(ShareRapidCom.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = found.groups()
- size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(ShareRapidCom.FILE_NAME_INFO_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if found or size > 0:
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(ShareRapidCom, url, getURL(url, decode=True))
+ result.append(file_info)
finally:
h.close()
yield result
-class ShareRapidCom(Hoster):
+class ShareRapidCom(SimpleHoster):
__name__ = "ShareRapidCom"
__type__ = "hoster"
__pattern__ = r"http://(?:www\.)?((share(-?rapid\.(biz|com|cz|info|eu|net|org|pl|sk)|-(central|credit|free|net)\.cz|-ms\.net)|(s-?rapid|rapids)\.(cz|sk))|(e-stahuj|mediatack|premium-rapidshare|rapidshare-premium|qiuck)\.cz|kadzet\.com|stahuj-zdarma\.eu|strelci\.net|universal-share\.com)/(stahuj/.+)"
- __version__ = "0.42"
+ __version__ = "0.44"
__description__ = """Share-rapid.com plugin - premium only"""
__author_name__ = ("MikyWoW", "zoidberg")
__author_mail__ = ("MikyWoW@seznam.cz", "zoidberg@mujmail.cz")
@@ -71,14 +55,12 @@ class ShareRapidCom(Hoster):
self.account.relogin(self.user)
self.retry(3, 0, str(e))
- size, units = re.search(self.FILE_SIZE_PATTERN, self.html).groups()
- pyfile.size = float(size) * 1024 ** {'kB': 1, 'MB': 2, 'GB': 3}[units]
+ self.getFileInfo()
found = re.search(self.DOWNLOAD_URL_PATTERN, self.html)
if found is not None:
link, pyfile.name = found.groups()
- self.logInfo("Downloading file: %s (%s %s)" % (pyfile.name, size, units))
- self.logInfo("Premium link: %s" % link)
+ self.logDebug("Premium link: %s" % link)
self.download(link)
else:
self.logError("Download URL not found")
diff --git a/module/plugins/hoster/StahnuTo.py b/module/plugins/hoster/StahnuTo.py
index 0413853dd..fb17fad7c 100644
--- a/module/plugins/hoster/StahnuTo.py
+++ b/module/plugins/hoster/StahnuTo.py
@@ -17,40 +17,23 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL("http://stahnu.to/?file=" + re.search(StahnuTo.__pattern__, url).group(3), decode=True)
- if re.search(StahnuTo.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- found = re.search(StahnuTo.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- found = re.search(StahnuTo.FILE_SIZE_PATTERN, html)
- if found is not None:
- size = float(found.group(1))
- units = found.group(2)
-
- pow = {'kB': 1, 'Mb': 2, 'Gb': 3}[units]
- size = int(size * 1024 ** pow)
-
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(StahnuTo, url, getURL("http://stahnu.to/?file=" + re.search(StahnuTo.__pattern__, url).group(3), decode=True))
+ result.append(file_info)
+
yield result
-
-class StahnuTo(Hoster):
+class StahnuTo(SimpleHoster):
__name__ = "StahnuTo"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)?stahnu.to/(files/get/|.*\?file=)([^/]+).*"
- __version__ = "0.1"
+ __version__ = "0.11"
__description__ = """stahnu.to"""
__author_name__ = ("zoidberg")
@@ -60,35 +43,15 @@ class StahnuTo(Hoster):
#FILE_OFFLINE_PATTERN = r'<h2 align="center">Tento soubor neexistuje nebo byl odstran&#283;n! </h2>'
CAPTCHA_PATTERN = r'<img src="captcha/captcha.php" id="captcha" /></td>'
-
def setup(self):
self.multiDL = True
def process(self, pyfile):
found = re.search(self.__pattern__, pyfile.url)
- if found is None:
- self.fail("Wrong URL")
file_id = found.group(3)
self.html = self.load("http://stahnu.to/?file=" + file_id, decode=True)
-
- if re.search(self.FILE_OFFLINE_PATTERN, self.html):
- self.offline()
-
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (NAME)")
- pyfile.name = found.group(1)
-
- """
- captcha = self.decryptCaptcha("http://stahnu.to/captcha/captcha.php", cookies=True)
-
- self.html = self.load("http://stahnu.to/?file=" + file_id, cookies=True, post={
- if re.search(self.CAPTCHA_PATTERN, self.html) is not None:
- self.invalidCaptcha()
- self.retry()
-
- """
+ self.getFileInfo()
self.download("http://stahnu.to/files/gen/" + file_id, post={
"file": file_id,
diff --git a/module/plugins/hoster/UlozTo.py b/module/plugins/hoster/UlozTo.py
index b16240ab7..b9ec4c5d7 100644
--- a/module/plugins/hoster/UlozTo.py
+++ b/module/plugins/hoster/UlozTo.py
@@ -17,7 +17,7 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
@@ -25,43 +25,19 @@ def getInfo(urls):
for url in urls:
try:
- html = getURL(url, decode=True)
-
- if re.search(UlozTo.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name = ''
- found = re.search(UlozTo.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
- else:
- found = re.search(UlozTo.LIVE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if name:
- found = re.search(UlozTo.FILE_SIZE_PATTERN, html)
- if found is not None:
- size = float(found.group(1))
- units = found.group(2)
-
- pow = {'kB': 1, 'MB': 2, 'GB': 3}[units]
- size = int(size * 1024 ** pow)
-
- result.append((name, size, 2, url))
- except Exception:
+ file_info = parseFileInfo(IfileIt, url, getURL(url, decode=True))
+ result.append(file_info)
+ except Exception, e:
+ self.logError(e)
result.append((url, 0, 1, url))
yield result
-
-class UlozTo(Hoster):
+class UlozTo(SimpleHoster):
__name__ = "UlozTo"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)?(uloz\.to|ulozto\.(cz|sk|net)|bagruj.cz|zachowajto.pl)/.*"
- __version__ = "0.7"
+ __version__ = "0.71"
__description__ = """uloz.to"""
__config__ = [("reuseCaptcha", "bool", "Reuse captcha", "True"),
("captchaUser", "str", "captcha_user", ""),
@@ -76,7 +52,7 @@ class UlozTo(Hoster):
PASSWD_PATTERN = r'<input type="password" class="text" name="file_password" id="frmfilepasswordForm-file_password" />'
LIVE_URL_PATTERN = r'<div id="flashplayer"[^>]*>\s*<a href="([^"]+)"'
LIVE_NAME_PATTERN = r'<a share_url="[^&]*&amp;t=([^"]+)"'
- FILE_SIZE_PATTERN = r'<div class="info_velikost" style="top:-55px;">\s*<div>[^<]*\s+([0-9.]+)\s(kB|MB|GB)\s*</div>\s*</div>'
+ FILE_SIZE_PATTERN = r'<div class="info_velikost" style="top:-55px;">\s*<div>[^<]*\s+([0-9.]+)\s([kKMG]i?B)\s*</div>\s*</div>'
VIPLINK_PATTERN = r'<a href="[^"]*\?disclaimer=1" class="linkVip">'
def setup(self):
@@ -84,10 +60,7 @@ class UlozTo(Hoster):
def process(self, pyfile):
self.html = self.load(pyfile.url, decode=True)
-
- #marks the file as "offline" when the pattern was found on the html-page
- if re.search(self.FILE_OFFLINE_PATTERN, self.html):
- self.offline()
+ self.getFileInfo()
if re.search(self.VIPLINK_PATTERN, self.html):
self.html = self.load(pyfile.url, get={"disclaimer": "1"})
diff --git a/module/plugins/hoster/UloziskoSk.py b/module/plugins/hoster/UloziskoSk.py
index e439a0f87..1fd15502d 100644
--- a/module/plugins/hoster/UloziskoSk.py
+++ b/module/plugins/hoster/UloziskoSk.py
@@ -17,84 +17,58 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(UloziskoSk.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(UloziskoSk.FILE_SIZE_PATTERN, html)
- if found is not None:
- size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- found = re.search(UloziskoSk.FILE_NAME_PATTERN, html)
- if found is not None:
- name = found.group(1)
-
- if found or size > 0:
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(UloziskoSk, url, getURL(url, decode=True))
+ result.append(file_info)
+
yield result
-
-class UloziskoSk(Hoster):
+class UloziskoSk(SimpleHoster):
__name__ = "UloziskoSk"
__type__ = "hoster"
__pattern__ = r"http://(\w*\.)?ulozisko.sk/.*"
- __version__ = "0.2"
+ __version__ = "0.22"
__description__ = """Ulozisko.sk"""
__author_name__ = ("zoidberg")
URL_PATTERN = r'<form name = "formular" action = "([^"]+)" method = "post">'
ID_PATTERN = r'<input type = "hidden" name = "id" value = "([^"]+)" />'
- FILE_NAME_PATTERN = r'<input type = "hidden" name = "name" value = "([^"]+)" />'
- FILE_SIZE_PATTERN = ur'Veľkosť súboru: <strong>([0-9.]+) (KB|MB|GB)</strong><br />'
+ FILE_NAME_PATTERN = r'<div class="down1">([^<]+)</div>'
+ FILE_SIZE_PATTERN = ur'Veľkosť súboru: <strong>([0-9.]+) ([kKMG]i?B)</strong><br />'
CAPTCHA_PATTERN = r'<img src="(/obrazky/obrazky.php\?fid=[^"]+)" alt="" />'
FILE_OFFLINE_PATTERN = ur'<span class = "red">Zadaný súbor neexistuje z jedného z nasledujúcich dôvodov:</span>'
-
- def setup(self):
- self.multiDL = False
+ IMG_PATTERN = ur'<strong>PRE ZVÄČŠENIE KLIKNITE NA OBRÁZOK</strong><br /><a href = "([^"]+)">'
def process(self, pyfile):
self.html = self.load(pyfile.url, decode=True)
+ self.getFileInfo()
+
+ found = re.search(self.IMG_PATTERN, self.html)
+ if found:
+ url = "http://ulozisko.sk" + found.group(1)
+ self.download(url)
+ else:
+ self.handleFree()
- if re.search(self.FILE_OFFLINE_PATTERN, self.html) is not None:
- self.offline()
-
+ def handleFree(self):
found = re.search(self.URL_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (URL)")
+ if found is None: raise PluginParseError('URL')
parsed_url = 'http://www.ulozisko.sk' + found.group(1)
- found = re.search(self.FILE_NAME_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (FILENAME)")
- pyfile.name = found.group(1)
-
- found = re.search(self.FILE_SIZE_PATTERN, self.html)
- if found is not None:
- size, units = found.groups()
- pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
found = re.search(self.ID_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (ID)")
+ if found is None: raise PluginParseError('ID')
id = found.group(1)
- self.logDebug('URL:' + parsed_url + ' NAME:' + pyfile.name + ' ID:' + id)
+ self.logDebug('URL:' + parsed_url + ' ID:' + id)
found = re.search(self.CAPTCHA_PATTERN, self.html)
- if found is None:
- self.fail("Parse error (CAPTCHA)")
+ if found is None: raise PluginParseError('CAPTCHA')
captcha_url = 'http://www.ulozisko.sk' + found.group(1)
captcha = self.decryptCaptcha(captcha_url, cookies=True)
@@ -104,6 +78,6 @@ class UloziskoSk(Hoster):
self.download(parsed_url, post={
"antispam": captcha,
"id": id,
- "name": pyfile.name,
+ "name": self.pyfile.name,
"but": "++++STIAHNI+S%DABOR++++"
- })
+ }) \ No newline at end of file
diff --git a/module/plugins/hoster/UploadkingCom.py b/module/plugins/hoster/UploadkingCom.py
index d29a06e48..a706e95bc 100644
--- a/module/plugins/hoster/UploadkingCom.py
+++ b/module/plugins/hoster/UploadkingCom.py
@@ -17,60 +17,34 @@
"""
import re
-from module.plugins.Hoster import Hoster
+from module.plugins.internal.SimpleHoster import SimpleHoster, parseFileInfo
from module.network.RequestFactory import getURL
def getInfo(urls):
result = []
for url in urls:
- html = getURL(url, decode=True)
- if re.search(UploadkingCom.FILE_OFFLINE_PATTERN, html):
- # File offline
- result.append((url, 0, 1, url))
- else:
- # Get file info
- name, size = url, 0
-
- found = re.search(UploadkingCom.FILE_INFO_PATTERN, html)
- if found is not None:
- name, size, units = found.groups()
- size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
- result.append((name, size, 2, url))
+ file_info = parseFileInfo(UploadkingCom, url, getURL(url, decode=False))
+ result.append(file_info)
+
yield result
-class UploadkingCom(Hoster):
+class UploadkingCom(SimpleHoster):
__name__ = "UploadkingCom"
__type__ = "hoster"
__pattern__ = r"http://(?:www\.)?uploadking\.com/\w{10}"
- __version__ = "0.1"
+ __version__ = "0.12"
__description__ = """UploadKing.com plugin - free only"""
__author_name__ = ("zoidberg")
__author_mail__ = ("zoidberg@mujmail.cz")
- FILE_INFO_PATTERN = r'<font style="font-size:\d*px;">File(?:name)?:\s*<(?:b|/font><font[^>]*)>([^<]+)(?:</b>)?</div></TD></TR><TR><TD[^>]*><font style="font-size:\d*px;">(?:Files|S)ize:\s*<(?:b|/font><font[^>]*)>([0-9.]+) (KB|MB|GB)</(?:b|font)>'
+ FILE_INFO_PATTERN = r'<font style="font-size:\d*px;">File(?:name)?:\s*<(?:b|/font><font[^>]*)>([^<]+)(?:</b>)?</div></TD></TR><TR><TD[^>]*><font style="font-size:\d*px;">(?:Files|S)ize:\s*<(?:b|/font><font[^>]*)>([0-9.]+) ([kKMG]i?B)</(?:b|font)>'
FILE_OFFLINE_PATTERN = r'<center><font[^>]*>Unfortunately, this file is unavailable</font></center>'
FILE_URL_PATTERN = r'id="dlbutton"><a href="([^"]+)"'
- def setup(self):
- self.multiDL = False
-
- def process(self, pyfile):
- self.html = self.load(pyfile.url, decode = True)
- self.getFileInfo(pyfile)
- self.handleFree(pyfile)
-
- def getFileInfo(self, pyfile):
- if re.search(self.FILE_OFFLINE_PATTERN, self.html): self.offline()
-
- found = re.search(self.FILE_INFO_PATTERN, self.html)
- if not found: self.fail("Parse error (file info)")
- pyfile.name, size, units = found.groups()
- pyfile.size = float(size) * 1024 ** {'KB': 1, 'MB': 2, 'GB': 3}[units]
-
- def handleFree(self, pyfile):
+ def handleFree(self):
found = re.search(self.FILE_URL_PATTERN, self.html)
- if not found: self.fail("Captcha key not found")
+ if not found: self.fail("Download URL not found")
url = found.group(1)
-
+ self.logDebug("DOWNLOAD URL: " + url)
self.download(url) \ No newline at end of file
diff --git a/module/plugins/internal/SimpleHoster.py b/module/plugins/internal/SimpleHoster.py
new file mode 100644
index 000000000..f4434d3f8
--- /dev/null
+++ b/module/plugins/internal/SimpleHoster.py
@@ -0,0 +1,107 @@
+# -*- 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
+ 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 General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, see <http://www.gnu.org/licenses/>.
+
+ @author: zoidberg
+"""
+
+from module.plugins.Hoster import Hoster
+from module.utils import html_unescape
+from re import search
+
+def parseFileInfo(self, url = '', html = ''):
+ if not html and hasattr(self, "html"): html = self.html
+ name, size, status, found = '', 0, 0, 0
+
+ if hasattr(self, "FILE_OFFLINE_PATTERN") and search(self.FILE_OFFLINE_PATTERN, html):
+ # File offline
+ status = 1
+ elif hasattr(self, "FILE_INFO_PATTERN"):
+ found = search(self.FILE_INFO_PATTERN, html)
+ if found:
+ name, size, units = found.groups()
+ else:
+ if hasattr(self, "FILE_NAME_PATTERN"):
+ found = search(self.FILE_NAME_PATTERN, html)
+ if found:
+ name = found.group(1)
+
+ if hasattr(self, "FILE_SIZE_PATTERN"):
+ found = search(self.FILE_SIZE_PATTERN, html)
+ if found:
+ size, units = found.groups()
+
+ if size:
+ # File online, return name and size
+ for r in self.SIZE_REPLACEMENTS:
+ size = size.replace(r, self.SIZE_REPLACEMENTS[r])
+ size = float(size) * 1024 ** self.SIZE_UNITS[units]
+ status = 2
+
+ if not name: name = url
+
+ return (name, size, status, url)
+
+class PluginParseError(Exception):
+ def __init__(self, msg):
+ self.value = 'Parse error (%s) - plugin may be out of date' % msg
+ def __str__(self):
+ return repr(self.value)
+
+class SimpleHoster(Hoster):
+ __name__ = "SimpleHoster"
+ __version__ = "0.1"
+ __pattern__ = None
+ __type__ = "hoster"
+ __description__ = """Base hoster plugin"""
+ __author_name__ = ("zoidberg")
+ __author_mail__ = ("zoidberg@mujmail.cz")
+
+ SIZE_UNITS = {'kB': 1, 'KB': 1, 'KiB': 1, 'MB': 2, 'MiB': 2, 'GB': 3, 'GiB': 3}
+ SIZE_REPLACEMENTS = {',': '', ' ': ''}
+
+ def setup(self):
+ self.resumeDownload = self.multiDL = True if self.account else False
+
+ def process(self, pyfile):
+ self.html = self.load(pyfile.url, decode = True)
+ self.getFileInfo()
+ if self.account:
+ self.handlePremium()
+ else:
+ self.handleFree()
+
+ def getFileInfo(self):
+ self.logDebug("URL: %s" % self.pyfile.url)
+ name, size, status, url = parseFileInfo(self)
+ if status == 1:
+ self.offline()
+ elif status == 0:
+ self.parseError('File info')
+
+ if not name:
+ name = html_unescape(urlparse(pyfile.url).path.split("/")[-1])
+
+ self.logDebug("FILE NAME: %s FILE SIZE: %s" % (name, size))
+ self.pyfile.name, self.pyfile.size = name, size
+
+ def handleFree(self):
+ self.fail("Free download not implemented")
+
+ def handlePremium(self):
+ self.fail("Premium download not implemented")
+
+ def parseError(self, msg):
+ raise PluginParseError(msg) \ No newline at end of file