Added stop and delete one or all in instant recording screen
authorlittlesat <littlesat99@yahoo.com>
Fri, 13 Mar 2015 18:16:17 +0000 (19:16 +0100)
committerlittlesat <littlesat99@yahoo.com>
Fri, 13 Mar 2015 18:16:17 +0000 (19:16 +0100)
Thanks Tension
added stop and delete one or all current recordings.

lib/python/Screens/InfoBarGenerics.py
lib/python/Screens/MovieSelection.py

index a00285c..9d224ce 100644 (file)
@@ -1043,7 +1043,7 @@ class InfoBarEPG:
        def showEventInfoPlugins(self):
                pluginlist = self.getEPGPluginList()
                if pluginlist:
-                       self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list=pluginlist, skin_name="EPGExtensionsList", reorderConfig="eventinfo_order")
+                       self.session.openWithCallback(self.EventInfoPluginChosen, ChoiceBox, title=_("Please choose an extension..."), list = pluginlist, skin_name = "EPGExtensionsList")
                else:
                        self.openSingleServiceEPG()
 
@@ -2011,7 +2011,7 @@ class InfoBarExtensions:
                list.extend([(x[0](), x) for x in extensionsList])
 
                keys += [""] * len(extensionsList)
-               self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list=list, keys=keys, skin_name="ExtensionsList", reorderConfig="extension_order")
+               self.session.openWithCallback(self.extensionCallback, ChoiceBox, title=_("Please choose an extension..."), list = list, keys = keys, skin_name = "ExtensionsList")
 
        def extensionCallback(self, answer):
                if answer is not None:
@@ -2226,11 +2226,32 @@ class InfoBarInstantRecord:
                        if InfoBarInstance:
                                self.recording = InfoBarInstance.recording
 
+       def moveToTrash(self, entry):
+               print "instantRecord stop and delete recording: ", entry.name
+               trash = "/hdd/movie/.Trash"
+               if not os.path.isdir(trash):
+                       import Tools.Trashcan
+                       trash = Tools.Trashcan.createTrashFolder(entry.Filename)
+               from MovieSelection import moveServiceFiles
+               moveServiceFiles(os.path.realpath(entry.Filename), trash, entry.name, allowCopy=False)                          
+
        def stopCurrentRecording(self, entry = -1):
                if entry is not None and entry != -1:
                        self.session.nav.RecordTimer.removeEntry(self.recording[entry])
+                       if self.deleteRecording:
+                               self.moveToTrash(self.recording[entry])
                        self.recording.remove(self.recording[entry])
 
+       def stopAllCurrentRecordings(self, list):
+               msg = ''
+               for entry in list:
+                       msg += entry[0].name + "\n"
+                       self.session.nav.RecordTimer.removeEntry(entry[0])
+                       self.recording.remove(entry[0])
+                       if self.deleteRecording:
+                               self.moveToTrash(entry[0])
+               self.session.open(MessageBox, _("Stopped recordings:") + "\n" + msg, MessageBox.TYPE_INFO, timeout=5)
+
        def getProgramInfoAndEvent(self, info, name):
                info["serviceref"] = hasattr(self, "SelectedInstantServiceRef") and self.SelectedInstantServiceRef or self.session.nav.getCurrentlyPlayingServiceOrGroup()
 
@@ -2331,6 +2352,7 @@ class InfoBarInstantRecord:
                        elif x.dontSave and x.isRunning():
                                list.append((x, False))
 
+               self.deleteRecording = False
                if answer[1] == "changeduration":
                        if len(self.recording) == 1:
                                self.changeDuration(0)
@@ -2345,7 +2367,21 @@ class InfoBarInstantRecord:
                        import TimerEdit
                        self.session.open(TimerEdit.TimerEditList)
                elif answer[1] == "stop":
-                       self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
+                       if len(self.recording) == 1:
+                               self.stopCurrentRecording(0)
+                       else:
+                               self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
+               elif answer[1] == "stopdelete":
+                       self.deleteRecording = True
+                       if len(self.recording) == 1:
+                               self.stopCurrentRecording(0)
+                       else:
+                               self.session.openWithCallback(self.stopCurrentRecording, TimerSelection, list)
+               elif answer[1] == "stopall":
+                       self.stopAllCurrentRecordings(list)
+               elif answer[1] == "stopdeleteall":
+                       self.deleteRecording = True
+                       self.stopAllCurrentRecordings(list)
                elif answer[1] in ( "indefinitely" , "manualduration", "manualendtime", "event"):
                        self.startInstantRecording(limitEvent = answer[1] in ("event", "manualendtime") or False)
                        if answer[1] == "manualduration":
@@ -2425,9 +2461,16 @@ class InfoBarInstantRecord:
                        common = ()
                if self.isInstantRecordRunning():
                        title =_("A recording is currently running.\nWhat do you want to do?")
-                       list = ((_("Stop recording"), "stop"),) + common + \
+                       list = common + \
                                ((_("Change recording (duration)"), "changeduration"),
                                (_("Change recording (endtime)"), "changeendtime"),)
+                       list += ((_("Stop recording"), "stop"),)
+                       if config.usage.movielist_trashcan.value:
+                               list += ((_("Stop and delete recording"), "stopdelete"),)
+                       if len(self.recording) > 1:
+                               list += ((_("Stop all current recordings"), "stopall"),)
+                               if config.usage.movielist_trashcan.value:
+                                       list += ((_("Stop and delete all current recordings"), "stopdeleteall"),)
                        if self.isTimerRecordRunning():
                                list += ((_("Stop timer recording"), "timer"),)
                        list += ((_("Do nothing"), "no"),)
index cfb025f..027564f 100644 (file)
@@ -138,14 +138,14 @@ def canCopy(item):
 
 def createMoveList(serviceref, dest):
        #normpath is to remove the trailing '/' from directories
-       src = os.path.normpath(serviceref.getPath())
+       src = isinstance(serviceref, str) and serviceref + ".ts" or os.path.normpath(serviceref.getPath())
        srcPath, srcName = os.path.split(src)
        if os.path.normpath(srcPath) == dest:
                # move file to itself is allowed, so we have to check it
                raise Exception, "Refusing to move to the same directory"
        # Make a list of items to move
        moveList = [(src, os.path.join(dest, srcName))]
-       if not serviceref.flags & eServiceReference.mustDescent:
+       if serviceref.flags & eServiceReference.mustDescent or isinstance(serviceref, str):
                # Real movie, add extra files...
                srcBase = os.path.splitext(src)[0]
                baseName = os.path.split(srcBase)[1]