Esempio n. 1
0
    def _processQueue(self):
        self.common.log("")
        item = self._getNextItemFromQueue()
        if item:
            (filename, item) = item

            if item:
                if not self.dialog:
                    self.dialog = DialogDownloadProgress.DownloadProgress()
                    self.dialog.create(self.language(201), "")

                while item:
                    status = 500
                    self._setPaths(filename, item)

                    if not "url" in item:
                        self.common.log("URL missing : %s" % repr(item))
                    elif item["url"].find("ftp") > -1 or item["url"].find(
                            "http") > -1:
                        status = self._downloadURL(filename, item)
                    else:
                        self._detectStream(filename, item)
                        if "cmd_call" in item:
                            status = self._downloadStream(filename, item)
                        else:
                            self._showMessage(self.language(301), filename)

                    if status == 200:
                        if self.xbmcvfs.exists(item["path_incomplete"]):
                            self.common.log("Moving %s to %s" %
                                            (repr(item["path_incomplete"]),
                                             repr(item["path_complete"])))
                            self.xbmcvfs.rename(item["path_incomplete"],
                                                item["path_complete"])
                            self._showMessage(self.language(203), filename)
                        else:
                            self.common.log(
                                "Download complete, but file %s not found" %
                                repr(item["path_incomplete"]))
                            self._showMessage(self.language(204), "ERROR")
                    elif status != 300:
                        self.common.log("Failure: " + repr(item) + " - " +
                                        repr(status))
                        self._showMessage(self.language(204),
                                          self.language(302))

                    if status == 300:
                        item = False
                    else:
                        self._removeItemFromQueue(filename)
                        item = self._getNextItemFromQueue()
                        if item:
                            (filename, item) = item

                self.common.log("Finished download queue.")
                self.cache.set("StopQueue", "")
                if self.dialog:
                    self.dialog.close()
                    self.common.log("Closed dialog")
                self.dialog = u""
	def processQueue(self, params = {}):
		self.common.log("")
		videoid = self.storage.getNextVideoFromDownloadQueue()
		self.common.log("res: " + videoid)
		
		if videoid:
			if not self.dialog:
				self.dialog = DialogDownloadProgress.DownloadProgress()
	
			while videoid:
				params["videoid"] = videoid
				( video, status ) = self.player.getVideoObject(params)
				if status != 200:
					self.utils.showMessage(self.language(30625), video["apierror"])
					self.storage.removeVideoFromDownloadQueue(videoid)
					videoid = self.storage.getNextVideoFromDownloadQueue()
					continue
				item = video.get
				if item("stream_map"):
					self.utils.showMessage(self.language(30607), self.language(30619))
					self.storage.removeVideoFromDownloadQueue(videoid)
					videoid = self.storage.getNextVideoFromDownloadQueue()
					continue
				
				( video, status ) = self.downloadVideoURL(video)
				self.storage.removeVideoFromDownloadQueue(videoid)
				videoid = self.storage.getNextVideoFromDownloadQueue()

			self.common.log("Finished download queue.")
			self.dialog.close()
			self.dialog = ""
Esempio n. 3
0
    def _updateProgress(self, filename, item, params):
        self.common.log("", 3)
        get = params.get
        iget = item.get
        queue = False
        new_mark = time.time()

        if new_mark == get("mark"):
            speed = 0
        else:
            speed = int(
                (get("bytes_so_far") / 1024) / (new_mark - get("mark")))

        if new_mark - get("queue_mark") > 1.5:
            queue = self.cache.get("SimpleDownloaderQueue")
            self.queue = queue
        elif hasattr(self, "queue"):
            queue = self.queue

        self.common.log("eval queue", 2)

        try:
            items = eval(queue)
        except:
            items = {}

        if new_mark - get("queue_mark") > 1.5:
            heading = u"[%s] %sKb/s (%.2f%%)" % (len(items), speed,
                                                 item["percent"])
            self.common.log(
                "Updating %s - %s" % (heading, self.common.makeUTF8(filename)),
                2)
            params["queue_mark"] = new_mark

        if self.xbmc.Player().isPlaying() and self.xbmc.getCondVisibility(
                "VideoPlayer.IsFullscreen"):
            if self.dialog:
                self.dialog.close()
                self.dialog = u""
        else:
            if not self.dialog:
                self.dialog = DialogDownloadProgress.DownloadProgress()
                self.dialog.create(self.language(201), "")

            heading = u"[%s] %s - %.2f%%" % (len(items), self.language(202),
                                             item["percent"])

            if iget("Title"):
                self.dialog.update(percent=item["percent"],
                                   heading=heading,
                                   label=iget("Title"))
            else:
                self.dialog.update(percent=item["percent"],
                                   heading=heading,
                                   label=filename)
        self.common.log("Done", 3)