示例#1
0
def sessionStart(reason, session):
    GlobalSession.setSession(session)
    # saving active downloads to session
    if not hasattr(session, 'archivCZSKdownloads'):
        session.archivCZSKdownloads = []
    if DownloadManager.getInstance() is None:
        DownloadManager(session.archivCZSKdownloads)
示例#2
0
    def __init__(self, session):
        BaseArchivCZSKMenuListScreen.__init__(self, session)
        DownloadListScreen.instance = self
        self["key_red"] = Button(_("Cancel"))
        self["key_green"] = Button(_("Play"))
        self["key_yellow"] = Button(_("Remove"))
        self["key_blue"] = Button("")

        from Plugins.Extensions.archivCZSK.engine.player.player import Player
        self.player = Player(session, self.workingFinished)

        self.lst_items = []
        self.title = "ArchivyCZSK" + " - " + _("Recent downloads")
        self.onClose.append(self.__onClose)

        self["actions"] = NumberActionMap(["archivCZSKActions"],
            {
                "ok": self.ok,
                "cancel": self.cancel,
                "red": self.askCancelDownload,
                "green": self.askPlayDownload,
                "yellow": self.askRemoveDownload,
                "up": self.up,
                "down": self.down,
            }, -2)

        self.lst_items = DownloadManager.getInstance().download_lst
        self.onShown.append(self.setWindowTitle)
示例#3
0
    def __init__(self, session):
        BaseArchivCZSKMenuListScreen.__init__(self, session)
        ArchivCZSKDownloadListScreen.instance = self
        self["key_red"] = Button(_("Cancel"))
        self["key_green"] = Button(_("Play"))
        self["key_yellow"] = Button(_("Remove"))
        self["key_blue"] = Button("")

        from Plugins.Extensions.archivCZSK.engine.player.player import Player
        self.player = Player(session, self.workingFinished)

        self.lst_items = []
        self.title = "ArchivyCZSK" + " - " + _("Recent downloads")
        self.onClose.append(self.__onClose)

        self["actions"] = NumberActionMap(["archivCZSKActions"],
            {
                "ok": self.ok,
                "cancel": self.cancel,
                "red": self.askCancelDownload,
                "green": self.askPlayDownload,
                "yellow": self.askRemoveDownload,
                "up": self.up,
                "down": self.down,
            }, -2)

        self.lst_items = DownloadManager.getInstance().download_lst
        self.onShown.append(self.setWindowTitle)
示例#4
0
    def overrideDownloadCB(download):
        session = GlobalSession.getSession()
        dManager = DownloadManager.getInstance()
        dInstance = None
        for d in dManager.download_lst:
            if download.local == d.local:
                dInstance = d
                break

        def renameCB(callback=None):
            if callback and len(callback) > 0:
                dpath = os.path.join(download.destDir, callback)
                if download.filename == callback:
                    session.open(
                        MessageBox,
                        _("You've to change download filename. Try again.."),
                        type=MessageBox.TYPE_WARNING)
                elif os.path.isfile(dpath):
                    message = "%s: %s %s\n%s" % (
                        _("The file"), callback, _("already exists"),
                        _("Try to use another name..."))
                    session.open(MessageBox,
                                 message,
                                 type=MessageBox.TYPE_WARNING)
                else:
                    download.filename = callback
                    download.local = dpath
                    dManager.addDownload(download)

        def askOverrideCB(callback=None):
            if callback:
                if callback[1] == "override":
                    try:
                        if dInstance:
                            dManager.removeDownload(dInstance)
                        else:
                            os.remove(download.local)
                        dManager.addDownload(download)
                    except OSError as e:
                        print e
                elif callback[1] == "rename":
                    session.openWithCallback(renameCB,
                                             VirtualKeyBoard,
                                             _("Rename filename"),
                                             text=download.filename)

        if download is not None:
            if dInstance and dInstance.running:
                message = _("Download is already running")
                session.open(MessageBox, message, type=MessageBox.TYPE_INFO)
            else:
                dfname = download.filename
                message = "%s: %s %s" % (_("The file"), dfname,
                                         _("already exist"))
                choices = [(_("Override existing file"), "override"),
                           (_("Rename file"), "rename")]
                session.openWithCallback(askOverrideCB, ChoiceBox, message,
                                         choices)
示例#5
0
 def ok(self):
     if not self.working and len(self.lst_items) > 0:
         it = self.getSelectedItem()
         download = DownloadManager.getInstance().findDownloadByIT(it)
         if download is not None and download.running:
             self.player.playDownload(download)
         else:
             self.player.setMediaItem(it)
             self.player.play()
示例#6
0
 def ok(self):
     if not self.working and len(self.lst_items) > 0:
         it = self.getSelectedItem()
         download = DownloadManager.getInstance().findDownloadByIT(it)
         if download is not None and download.running:
             self.player.playDownload(download)
         else:
             self.player.setMediaItem(it)
             self.player.play()
示例#7
0
    def overrideDownloadCB(download):
        session = GlobalSession.getSession()
        dManager = DownloadManager.getInstance()
        dInstance = None
        for d in dManager.download_lst:
            if download.local == d.local:
                dInstance = d
                break

        def renameCB(callback=None):
            if callback and len(callback) > 0:
                dpath = os.path.join(download.destDir, callback)
                if download.filename == callback:
                    session.open(MessageBox, _("You've to change download filename. Try again.."), type=MessageBox.TYPE_WARNING)
                elif os.path.isfile(dpath):
                    message = "%s: %s %s\n%s" % (_("The file"), callback, _("already exists"), _("Try to use another name..."))
                    session.open(MessageBox, message, type=MessageBox.TYPE_WARNING)
                else:
                    download.filename = callback
                    download.local = dpath
                    dManager.addDownload(download)

        def askOverrideCB(callback=None):
            if callback:
                if callback[1] == "override":
                    try:
                        if dInstance:
                            dManager.removeDownload(dInstance)
                        else:
                            os.remove(download.local)
                        dManager.addDownload(download)
                    except OSError as e:
                        print e
                elif callback[1] == "rename":
                    session.openWithCallback(renameCB, VirtualKeyBoard, _("Rename filename"), text=download.filename)

        if download is not None:
            if dInstance and dInstance.running:
                message = _("Download is already running")
                session.open(MessageBox, message, type=MessageBox.TYPE_INFO)
            else:
                dfname = download.filename
                message = "%s: %s %s" % (_("The file") , dfname, _("already exist"))
                choices = [(_("Override existing file"),"override"),
                                     (_("Rename file"), "rename")]
                session.openWithCallback(askOverrideCB, ChoiceBox, message, choices)
示例#8
0
 def removeDownload(self, callback=None):
     if callback:
         download = self.getSelectedItem()
         DownloadManager.getInstance().removeDownload(download)
         self.refreshList()
示例#9
0
 def refreshList(self):
     self.lst_items = DownloadManager.getInstance().download_lst
     self.updateMenuList()
示例#10
0
		def saveDownload(callback=None):
			if not callback:
				from Plugins.Extensions.archivCZSK.engine.downloader import DownloadManager
				DownloadManager.getInstance().removeDownload(self.download)
示例#11
0
 def removeDownload(self, callback=None):
     if callback:
         download = self.getSelectedItem()
         DownloadManager.getInstance().removeDownload(download)
         self.refreshList()
示例#12
0
 def refreshList(self):
     self.lst_items = DownloadManager.getInstance().download_lst
     self.updateMenuList()
示例#13
0
		def saveDownload(callback=None):
			if not callback:
				from Plugins.Extensions.archivCZSK.engine.downloader import DownloadManager
				DownloadManager.getInstance().removeDownload(self.download)