From d15f1d61c74dec1b566eb5d8b312f0b2c9eefd99 Mon Sep 17 00:00:00 2001 From: mkaay Date: Thu, 12 Nov 2009 23:33:28 +0100 Subject: config includes max download time --- module/download_thread.py | 1 + module/network/Request.py | 6 +++++- module/plugins/FourChan.py | 41 ----------------------------------------- module/plugins/FourChanOrg.py | 41 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 42 deletions(-) delete mode 100644 module/plugins/FourChan.py create mode 100644 module/plugins/FourChanOrg.py (limited to 'module') diff --git a/module/download_thread.py b/module/download_thread.py index 158d40147..6a31030ca 100644 --- a/module/download_thread.py +++ b/module/download_thread.py @@ -119,6 +119,7 @@ class Download_Thread(threading.Thread): pyfile.init_download() pyfile.plugin.prepare(self) + pyfile.plugin.req.set_timeout(self.parent.parent.config['general']['max_download_time']) if status.url == "": status.url = pyfile.plugin.get_file_url() diff --git a/module/network/Request.py b/module/network/Request.py index 37837fcaa..985abe8e9 100755 --- a/module/network/Request.py +++ b/module/network/Request.py @@ -49,6 +49,8 @@ class Request: self.lastURL = None self.auth = False + + self.timeout = 5*3600 try: if pycurl: self.curl = True @@ -81,6 +83,8 @@ class Request: ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"), ("Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7")] + def set_timeout(self, timeout): + self.timeout = timeout def init_curl(self): self.rep = StringIO() @@ -89,7 +93,7 @@ class Request: self.pycurl = pycurl.Curl() self.pycurl.setopt(pycurl.FOLLOWLOCATION, 1) self.pycurl.setopt(pycurl.MAXREDIRS, 5) - self.pycurl.setopt(pycurl.TIMEOUT, 5*3600) + self.pycurl.setopt(pycurl.TIMEOUT, self.timeout) self.pycurl.setopt(pycurl.CONNECTTIMEOUT, 30) self.pycurl.setopt(pycurl.NOSIGNAL, 1) self.pycurl.setopt(pycurl.NOPROGRESS, 0) diff --git a/module/plugins/FourChan.py b/module/plugins/FourChan.py deleted file mode 100644 index 840274457..000000000 --- a/module/plugins/FourChan.py +++ /dev/null @@ -1,41 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -import re - -from Plugin import Plugin - -class FourChan(Plugin): - - def __init__(self, parent): - Plugin.__init__(self, parent) - props = {} - props['name'] = "FourChan" - props['type'] = "container" - props['pattern'] = r"http://(www\.)?(img\.)?(zip\.)?4chan.org/\w+/(res/|imgboard\.html)" - props['version'] = "0.1" - props['description'] = """4chan.org Thread Download Plugin""" - props['author_name'] = ("Spoob") - props['author_mail'] = ("Spoob@pyload.org") - self.props = props - self.parent = parent - self.html = None - - def file_exists(self): - """ returns True or False - """ - return True - - def proceed(self, url, location): - url = self.parent.url - html = self.req.load(url) - link_pattern = "" - temp_links = [] - if "imagebord.html" in url: - link_pattern = '[Reply]' - temp_links = re.findall(link_pattern, html) - for link in re.findall(link_pattern, html): - temp_links.append(link) - else: - temp_links = re.findall('File :