Commits

ranan  committed 2aa5287

improved plugins

  • Participants
  • Parent commits 0cf8f3e

Comments (0)

Files changed (8)

         return True
     
     def _test_print_status(self):
-        if len(self.thread_list.py_downloading)>0:
+        if self.thread_list.py_downloading:
                 
             for pyfile in self.thread_list.py_downloading:
                 if pyfile.status.type == 'downloading':

File Plugins/Plugin.py

     def __init__(self, parent):
         self.plugin_name = None
         self.plugin_pattern = None
-        self.plugin_type = ""
+        self.plugin_type = "hoster"
         pluginProp = {}
         pluginProp ['name'] = "Beispiel Plugin"
         pluginProp ['version'] = "0.1"
         self.html = None
         self.time_plus_wait = None #time() + wait in seconds
         self.want_reconnect = None
+	self.multi_dl = True
     
     def set_parent_status(self):
         """ sets all available Statusinfos about a File in self.parent.status
         """
         if self.html != None:
             self.download_html()
+	return self.parent.url
+
     
     def get_file_name(self):
         raise NotImplementedError

File Plugins/RapidshareCom.py

         self.plugin_pattern = r"http://(?:www.)?rapidshare.com/files/"
         self.plugin_type = "hoster"
         self.plugin_config = {}
-        pluginProp = {}
+	pluginProp = {}
         pluginProp ['name'] = "RapidshareCom"
         pluginProp ['version'] = "0.1"
         pluginProp ['format'] = "*.py"
         pluginProp ['description'] = """Rapidshare Plugin"""
         pluginProp ['author'] = "spoob"
         pluginProp ['author_email'] = "nn@nn.de"
-        self.pluginProp = pluginProp 
+	pluginProp ['multi_dl'] = False
+	self.pluginProp = pluginProp
         self.parent = parent
         self.html = [None, None]
         self.prehtml = None
         self.html_old = None         #time() where loaded the HTML
         self.time_plus_wait = None   #time() + wait in seconds
         self.want_reconnect = False
+	self.multi_dl = False
     
     def set_parent_status(self):
         """ sets all available Statusinfos about a File in self.parent.status

File Plugins/UploadedTo.py

         self.plugin_pattern = r"http://(www\.)?uploaded.to/"
         self.plugin_type = "hoster"
         self.plugin_config = {}
-        pluginProp = {}
+	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.pluginProp = pluginProp
         self.parent = parent
         self.html = None
         self.html_old = None         #time() where loaded the HTML
         self.time_plus_wait = None   #time() + wait in seconds
         self.want_reconnect = None
+	self.multi_dl = False
     
     def set_parent_status(self):
         """ sets all available Statusinfos about a File in self.parent.status

File Plugins/YoutubeCom.py

         self.plugin_pattern = r"http://(www\.)?(de\.)?\youtube\.com/watch\?v=(.*)"
         self.plugin_type = "hoster"
         self.plugin_config = {}
-        pluginProp = {}
+	pluginProp = {}
         pluginProp ['name'] = "YoutubeCom"
         pluginProp ['version'] = "0.1"
         pluginProp ['format'] = "*.py"
         pluginProp ['description'] = """Youtube Plugin"""
         pluginProp ['author'] = "spoob"
         pluginProp ['author_email'] = "spoob@pyload.org"
-        self.pluginProp = pluginProp 
+	self.pluginProp = pluginProp
         self.parent = parent
         self.html = None
         self.html_old = None         #time() where loaded the HTML
         """
         if self.html == None:
             self.download_html()
-        if not self.want_reconnect:
-            videoId = re.search(self.plugin_pattern, self.parent.url).group(3)
-            videoHash = re.search(r', "t": "([^"]+)"', self.html).group(1)
-            file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + '&fmt=18'
-            return file_url
-        else:
-            return False
+
+        videoId = re.search(self.plugin_pattern, self.parent.url).group(3)
+        videoHash = re.search(r', "t": "([^"]+)"', self.html).group(1)
+        file_url = 'http://youtube.com/get_video?video_id=' + videoId + '&t=' + videoHash + '&fmt=18'
+        return file_url
         
     def get_file_name(self):
         if self.html == None:
             self.download_html()
-        if not self.want_reconnect:
-            file_name_pattern = r"<title>YouTube - (.*)</title>"
-            return re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.mp4'
-        else:
-            return self.parent.url
+
+         file_name_pattern = r"<title>YouTube - (.*)</title>"
+         return re.search(file_name_pattern, self.html).group(1).replace("/", "") + '.mp4'
         
     def file_exists(self):
         """ returns True or False 

File module/Py_Load_File.py

             if re.match(plugin_pattern, self.url) != None:
                 return plugin
         #logger: kein plugin gefunden # was soll passieren wenn nichts gefunden wird?!?
-        return None
+        return "Plugin"
     
     def prepareDownload(self):
         self.status.exists = self.plugin.file_exists()

File module/download_thread.py

             if self.parent.py_load_files:
                 self.loadedPyFile = self.parent.get_job()
                 if self.loadedPyFile:
-                    self.download(self.loadedPyFile)
+		    try:
+                    	self.download(self.loadedPyFile)
+		    except Exception, e:
+			print "Error:", e
+			#catch up all error here
+		    finally:
+			self.parent.job_finished(self.loadedPyFile)
             sleep(0.5)
         if self.shutdown:
             sleep(1)
         status = pyfile.status
         pyfile.prepareDownload()
 
-        if status.exists:
+	if not status.exists:
+	    raise "FileDontExists" #i know its deprecated, who cares^^
+
             
-            if status.want_reconnect:
-                print "handle reconnect"
+        if status.want_reconnect:
+            print "handle reconnect"
         
-            while (time() < status.waituntil):
-                status.type = "waiting"
-                sleep(1) #eventuell auf genaue zeit warten
-
-
-            status.type = "downloading"
+        while (time() < status.waituntil):
+            status.type = "waiting"
+            sleep(1) #eventuell auf genaue zeit warten
+        
+        try:
+	    status.type = "downloading"
             print status.url , status.filename
-        
-            try:
-                pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename)
-                status.type = "finished"
-            except:
-                status.type = "failed"
-        
-        self.parent.job_finished(pyfile)
+            
+	    pyfile.plugin.req.download(status.url, pyfile.download_folder + "/" + status.filename)
+            status.type = "finished"
+        except:
+            status.type = "failed"
 
         #startet downloader
         #urllib.urlretrieve(status.url, pyfile.download_folder + "/" + status.filename, status)        

File module/thread_list.py

     def remove_thread(self, thread):
         self.threads.remove(thread)
     
-    def status(self):
-        if not self.status_queue.empty():
-            while not self.status_queue.empty():
-                status = self.status_queue.get()
-                self.py_load_files[status.id].status = status
+#    def status(self):
+#        if not self.status_queue.empty():
+#            while not self.status_queue.empty():
+#                status = self.status_queue.get()
+#                self.py_load_files[status.id].status = status
 
     def get_job(self):
         # return job if suitable, otherwise send thread idle
 
 	if pyfile:	
 		self.py_downloading.append(pyfile)	
-		self.occ_plugins.append(pyfile.modul.__name__)
+		if not pyfile.plugin.multi_dl:
+	            self.occ_plugins.append(pyfile.modul.__name__)
 	
 	self.lock.release()
         return pyfile