summaryrefslogtreecommitdiffstats
path: root/Plugins/UploadedTo.py
diff options
context:
space:
mode:
authorGravatar spoob <spoob@gmx.de> 2009-05-14 18:04:09 +0200
committerGravatar spoob <spoob@gmx.de> 2009-05-14 18:04:09 +0200
commitefd6b47d534a99986e56a1a347339019e63b387e (patch)
tree95358724350e24c16772d5b61de0e96d3ae92f90 /Plugins/UploadedTo.py
parentPy_load_File in own file (diff)
downloadpyload-efd6b47d534a99986e56a1a347339019e63b387e.tar.xz
new plugin system in Core
Diffstat (limited to 'Plugins/UploadedTo.py')
-rw-r--r--Plugins/UploadedTo.py75
1 files changed, 75 insertions, 0 deletions
diff --git a/Plugins/UploadedTo.py b/Plugins/UploadedTo.py
new file mode 100644
index 000000000..0a3b7ef71
--- /dev/null
+++ b/Plugins/UploadedTo.py
@@ -0,0 +1,75 @@
+#!/usr/bin/env python
+
+import urllib2
+import re
+from Plugin import Plugin
+
+class UploadedTo(Plugin):
+
+ def __init__(self, parent):
+ self.plugin_name = "Uploaded.to"
+ self.plugin_pattern = r"http://(www\.)?uploaded.to/"
+ self.plugin_type = "hoster"
+ self.plugin_config = {}
+ pluginProp = {}
+ pluginProp ['name'] = "UploadedTo"
+ pluginProp ['version'] = "0.1"
+ pluginProp ['format'] = "*.py"
+ pluginProp ['description'] = """Uploaded Plugin"""
+ pluginProp ['author'] = "spoob"
+ pluginProp ['author_email'] = "spoob@gmx.de"
+ self.pluginProp = pluginProp
+ self.parent = parent
+ self.html = ""
+ self.html_old = None #time() where loaded the HTML
+ self.time_plus_wait = None #time() + wait in seconds
+
+ def set_parent_status(self):
+ """ sets all available Statusinfos about a File in self.parent.status
+ """
+ if self.html == None:
+ self.download_html()
+ self.parent.status.filename = self.get_file_name()
+ self.parent.status.url = self.get_file_url()
+ self.parent.status.wait = self.wait_until()
+
+ def download_html(self):
+ url = self.parent.url
+ html = urllib2.urlopen(url).read()
+ try:
+ wait_minutes = re.search(r"Or wait (\d+) minutes", self.html).group(1)
+ self.time_plus_wait = time() + 60 * wait_minutes
+ except:
+ self.time_plus_wait = 0
+
+ def get_file_url(self):
+ """ returns the absolute downloadable filepath
+ """
+ if self.html == None:
+ self.download_html()
+ file_url_pattern = r".*<form name=\"download_form\" method=\"post\" action=\"(.*)\">"
+ return re.search(file_url_pattern, self.html).group(1)
+
+ def get_file_name(self):
+ if self.html == None:
+ self.download_html()
+ file_name_pattern = r"<title>\s*(.*?)\s+\.\.\."
+ return re.search(file_name_pattern, self.html).group(1)
+
+ def file_exists(self):
+ """ returns True or False
+ """
+ if self.html == None:
+ self.download_html()
+ if re.search(r"(File doesn't exist .*)", self.html) != None:
+ return False
+ else:
+ return True
+
+ def wait_until(self):
+ if self.html == None:
+ self.download_html()
+ return self.time_plus_wait
+
+ def __call__(self):
+ return self.plugin_name