diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-07 18:47:34 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2010-10-07 18:47:34 +0200 |
commit | df0e93c878c2f6cf1c914516a7c754edfea7d3ce (patch) | |
tree | 11314814e60fe354f8b38fbd1bb04a59a778cb68 | |
parent | recycle sqlite connection (diff) | |
download | pyload-df0e93c878c2f6cf1c914516a7c754edfea7d3ce.tar.xz |
files.mail.ru closed #101
-rw-r--r-- | module/FileDatabase.py | 6 | ||||
-rw-r--r-- | module/ThreadManager.py | 18 | ||||
-rw-r--r-- | module/plugins/hoster/FilesMailRu.py | 50 |
3 files changed, 64 insertions, 10 deletions
diff --git a/module/FileDatabase.py b/module/FileDatabase.py index 4bcb63764..468d7c478 100644 --- a/module/FileDatabase.py +++ b/module/FileDatabase.py @@ -569,9 +569,9 @@ class FileDatabaseBackend(Thread): try: f, args, async = self.jobs.get() self.used += 1 - if f == "quit": return True - if self.used > 300: #recycle connection - self.recycleConnection() + #if f == "quit": return True + #if self.used > 300: #recycle connection + # self.recycleConnection() res = f(*args) if not async: self.res.put(res) except Exception, e: diff --git a/module/ThreadManager.py b/module/ThreadManager.py index 73e9efe56..6d7171222 100644 --- a/module/ThreadManager.py +++ b/module/ThreadManager.py @@ -165,19 +165,23 @@ class ThreadManager: pass + def cleanPyCurl(self): + if self.downloadingIds() or self.processingIds(): + return False + pycurl.global_cleanup() + pycurl.global_init(pycurl.GLOBAL_DEFAULT) + self.downloaded = 0 + self.log.debug("Cleaned up pycurl") + return True + #---------------------------------------------------------------------- def assignJob(self): """assing a job to a thread if possible""" if self.pause or not self.core.server_methods.is_time_download(): return - if self.downloaded > 20: - if self.downloadingIds() or self.processingIds(): - return - pycurl.global_cleanup() - pycurl.global_init(pycurl.GLOBAL_DEFAULT) - self.downloaded = 0 - self.log.debug("Cleaned up pycurl") + #if self.downloaded > 20: + # if not self.cleanPyCurl(): return free = [x for x in self.threads if not x.active] diff --git a/module/plugins/hoster/FilesMailRu.py b/module/plugins/hoster/FilesMailRu.py new file mode 100644 index 000000000..028fcc465 --- /dev/null +++ b/module/plugins/hoster/FilesMailRu.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import re +from module.plugins.Hoster import Hoster + +class FilesMailRu(Hoster): + __name__ = "FilesMailRu" + __type__ = "hoster" + __pattern__ = r"http://files\.mail\.ru/.*" + __version__ = "0.1" + __description__ = """Files.Mail.Ru One-Klick Hoster""" + __author_name__ = ("oZiRiz") + __author_mail__ = ("ich@oziriz.de") + + def process(self, pyfile): + self.html = self.load(pyfile.url) + self.url_pattern = '<a href="(.+?)" onclick="return Act\(this\, \'dlink\'\, event\)">(.+?)</a>' + + #marks the file as "offline" when the pattern was found on the html-page''' + if re.search(r'<div class="errorMessage mb10">', self.html) is not None: + self.offline() + + + #the filename that will be showed in the list (e.g. test.part1.rar)''' + pyfile.name = self.getFileName() + + #prepare and download''' + self.prepare() + self.download(self.getFileUrl()) + + + + + def prepare(self): + '''You have to wait some seconds. Otherwise you will get a 40Byte HTML Page instead of the file you expected''' + self.setWait(10) + self.wait() + return True + + def getFileUrl(self): + '''gives you the URL to the file. Extracted from the Files.mail.ru HTML-page stored in self.html''' + file_url = re.search(self.url_pattern, self.html).group(0).split('<a href="')[1].split('" onclick="return Act')[0] + return file_url + + + def getFileName(self): + '''gives you the Name for each file. Also extracted from the HTML-Page''' + file_name = re.search(self.url_pattern, self.html).group(0).split(', event)">')[1].split('</a>')[0] + return file_name |