Beispiel #1
0
def trashCleanSetup(dummyparam=None):
    try:
        global trashCleanCall
        if trashCleanCall is not None:
            trashCleanCall.cancel()

        if config.suomipoeka.movie_trashcan_clean.value is True:
            cltime = config.suomipoeka.movie_trashcan_ctime.value
            lotime = localtime()
            ltime = lotime[3] * 60 + lotime[4]
            ctime = cltime[0] * 60 + cltime[1]
            seconds = 60 * (ctime - ltime)
            if seconds < 0:
                seconds += 86400  # 24*60*60
            if seconds < 60:
                seconds = 60
            from MovieSelection import gMS
            trashCleanCall = DelayedFunction(1000 * seconds,
                                             gMS.purgeExpiredFromTrash)
            DelayedFunction(2000, gMS.purgeExpiredFromTrash)
            from SuomipoekaTasker import spDebugOut
            spDebugOut("Next trashcan cleanup in " + str(seconds) + " seconds")
    except Exception, e:
        from SuomipoekaTasker import spDebugOut
        spDebugOut("[sp] trashCleanSetup exception:\n" + str(e))
Beispiel #2
0
    def setAudioTrack(self):
        try:
            if not config.suomipoeka.autoaudio.value: return
            from Tools.ISO639 import LanguageCodes as langC
            service = self.session.nav.getCurrentService()
            tracks = service and service.audioTracks()
            nTracks = tracks and tracks.getNumberOfTracks() or 0
            if nTracks == 0: return
            trackList = []
            for i in range(nTracks):
                audioInfo = tracks.getTrackInfo(i)
                lang = audioInfo.getLanguage()
                if langC.has_key(lang):
                    lang = langC[lang][0]
                desc = audioInfo.getDescription()
                trackList += [str(lang) + " " + str(desc)]
#				spDebugOut("[spPlayer] audioTrack language: " + str(lang) + " " + str(desc))
            for audiolang in [
                    config.suomipoeka.audlang1.value,
                    config.suomipoeka.audlang2.value,
                    config.suomipoeka.audlang3.value
            ]:
                if self.tryAudioEnable(trackList, audiolang, tracks): break
        except Exception, e:
            spDebugOut("[spPlayer] audioTrack exception:\n" + str(e))
    def updateTitle(self):
        if self.selectIdx != -1:
            self.setTitle(_("*** Multiselection active ***"))
            return
        lotime = localtime()
        title = "[%02d:%02d] " % (lotime[3], lotime[4])
        if os.path.exists(self.currentPathSel + "/"):
            stat = os.statvfs(self.currentPathSel + "/")
            free = (stat.f_bavail if stat.f_bavail != 0 else
                    stat.f_bfree) * stat.f_bsize / 1048576
            if free >= 10240:  #unit in Giga bytes if more than 10 GB free
                title = "(%d GB) " % (free / 1024)
            else:
                title = "(%d MB) " % (free)

        title += self.currentPathSel + (self.currentPathSel == "") * "/"

        if not self["list"].currentSelIsDirectory() and not self.browsingVLC():
            try:
                service = self.getCurrent()
                if service is not None and config.suomipoeka.movie_descdis.value:
                    lenght = self["list"].getLenghtOfCurrent()
                    title += " <" + ("%d min, " % lenght) * (lenght > 0)
                    title += "%d MB>" % (os.path.getsize(service.getPath()) /
                                         1048576)
            except Exception, e:
                spDebugOut("[spMS] updateTitle exception:\n" + str(e))
Beispiel #4
0
def autostart(reason, **kwargs):
    if reason == 0:  # start
        if kwargs.has_key("session"):
            global gSession
            gSession = kwargs["session"]

            suomipoekaStartup(gSession)
            spTasker.Initialize(gSession)

            if not config.suomipoeka.ml_disable.value:
                try:
                    from Screens.InfoBar import InfoBar
                    value = config.suomipoeka.movie_launch.value
                    if value == "showMovies":
                        InfoBar.showMovies = showMoviesNew
                    elif value == "showTv":
                        InfoBar.showTv = showMoviesNew
                    elif value == "showRadio":
                        InfoBar.showRadio = showMoviesNew
                    elif value == "openQuickbutton":
                        InfoBar.openQuickbutton = showMoviesNew
                    elif value == "timeshiftStart":
                        InfoBar.startTimeshift = showMoviesNew
                except Exception, e:
                    spDebugOut(
                        "[spStartup] MovieList launch override exception:\n" +
                        str(e))

                try:
                    global gRecordings
                    from MovieSelection import MovieSelectionSP
                    gRecordings = gSession.instantiateDialog(MovieSelectionSP)
                except Exception, e:
                    spDebugOut("[spStartup] instantiateDialog exception:\n" +
                               str(e))
Beispiel #5
0
 def remoteInit(self, ip):
     try:
         if ip is not None:
             self.recFile = config.suomipoeka.folder.value + "/db_%s.rec" % str(
                 ip).replace(", ", ".")[1:-1]
     except Exception, e:
         spDebugOut("[spRC] remoteInit exception:\n" + str(e))
    def openScriptMenu(self):
        if self.browsingVLC(
        ):  #self["list"].getCurrentSelDir() == "VLC servers"
            self.session.open(MessageBox,
                              _("No script operation for VLC streams."),
                              MessageBox.TYPE_ERROR)
            return
        try:
            list = []
            paths = [
                "/usr/lib/enigma2/python/Plugins/Extensions/Suomipoeka/script/",
                "/etc/enigma2/suomipoeka/"
            ]

            for path in paths:
                for e in os.listdir(path):
                    if not os.path.isdir(path + e):
                        if e.endswith(".sh"):
                            list.append([e, path + e])
                        elif e.endswith(".py"):
                            list.append([e, path + e])

            if len(list) == 0:
                self.session.open(
                    MessageBox, paths[0] + "\n\n   or" + paths[1] + "\n\n" +
                    _("Does not contain any scripts."), MessageBox.TYPE_ERROR)
                return

            dlg = self.session.openWithCallback(self.scriptCB, ChoiceBox, " ",
                                                list)
            dlg.setTitle(_("Choose script"))
            dlg["list"].move(0, 30)

        except Exception, e:
            spDebugOut("[spMS] openScriptMenu exception:\n" + str(e))
 def moveRecCheck(self, serviceref, targetPath):
     try:
         path = serviceref.getPath()
         if self["list"].recControl.isRecording(path):
             self["list"].recControl.fixTimerPath(
                 path, path.replace(self.currentPathSel, targetPath))
     except Exception, e:
         spDebugOut("[spMS] moveRecCheck exception:\n" + str(e))
Beispiel #8
0
 def isRecording(self, filename):
     try:
         if filename[0] == "/": filename = os.path.split(filename)[1]
         if filename.endswith(".ts"): filename = filename[:-3]
         return filename in self.recList
     except Exception, e:
         spDebugOut("[spRC] isRecording exception:\n" + str(e))
         return False
Beispiel #10
0
 def tryAudioEnable(self, alist, match, tracks):
     index = 0
     for e in alist:
         if e.find(match) >= 0:
             spDebugOut("[spPlayer] audio track match: " + str(e))
             tracks.selectTrack(index)
             return True
         index += 1
     return False
Beispiel #11
0
 def recFileUpdate(self):
     try:
         if self.recFile is None: self.remoteInit(spNET.whatIsMyIP())
         if self.recFile is None: return  # was not able to get IP
         recf = open(self.recFile, "wb")
         pickle.dump(self.recList, recf)
         recf.close()
     except Exception, e:
         spDebugOut("[spRC] recFileUpdate exception:\n" + str(e))
 def bookmarkDirCB(self, path):
     try:
         if path.endswith("/"): path = path[:-1]
         bmfile = open(config.suomipoeka.folder.value + "/bookmarks.cfg",
                       "a")
         bmfile.write(path + "\n")
         bmfile.close()
     except Exception, e:
         spDebugOut("[spMM] bookmarkDirCB exception:\n" + str(e))
    def __init__(self, session, menumode, mlist, service, selections,
                 currentPath):
        Screen.__init__(self, session)
        self.mode = menumode
        self.mlist = mlist
        self.service = service
        self.selections = selections
        self.currentPathSel = currentPath

        self.menu = []
        if menumode == "normal":
            self["title"] = StaticText(_("Choose operation"))
            if config.suomipoeka.movie_bluefunc.value == "Movie home":
                self.menu.append(
                    (_("Play last"), boundFunction(self.close, "Play last")))
            else:
                self.menu.append(
                    (_("Movie home"), boundFunction(self.close, "Movie home")))

            if os.path.exists(config.suomipoeka.movie_trashpath.value):
                if self.service is not None:
                    self.menu.append((_("Delete permanently"),
                                      boundFunction(self.close, "delete")))
#				self.menu.append((_("Cleanup trashcan"), boundFunction(self.cleanTrash)))
                self.menu.append(
                    (_("Empty trashcan"), boundFunction(self.emptyTrash)))
                self.menu.append(
                    (_("Go to trashcan"), boundFunction(self.close, "trash")))
            self.menu.append(
                (_("Remove rogue files"), boundFunction(self.remRogueFiles)))
            self.menu.append(
                (_("Create link(s)"), boundFunction(self.createLinks)))
            self.menu.append(
                (_("Create directory"), boundFunction(self.createDir)))
            self.menu.append(
                (_("Bookmark directory"), boundFunction(self.bookmarkDir)))
            self.menu.append(
                (_("Bookmarks"), boundFunction(self.openBookmark)))
        elif menumode == "plugins":
            self["title"] = StaticText(_("Choose plugin"))
            if self.service is not None:
                for p in plugins.getPlugins(PluginDescriptor.WHERE_MOVIELIST):
                    self.menu.append(
                        (p.description, boundFunction(self.execPlugin, p)))
        elif menumode == "bookmarks":
            self["title"] = StaticText(_("Choose bookmark"))
            try:
                bmfile = open(
                    config.suomipoeka.folder.value + "/bookmarks.cfg", "r")
                #for x in bmfile.readline():
                #	self.menu.append((x, boundFunction(self.close, x)))
                for line in bmfile:
                    self.menu.append((line, boundFunction(self.close, line)))
                bmfile.close()
            except Exception, e:
                spDebugOut("[spMM] bookmarks mode exception:\n" + str(e))
Beispiel #14
0
 def trySubEnable(self, slist, match):
     for e in slist:
         if match == e[2]:
             spDebugOut("[spPlayer] subtitle match: " + str(e))
             if self.selected_subtitle != e[0]:
                 self.subtitles_enabled = False
                 self.selected_subtitle = e[0]
                 self.subtitles_enabled = True
                 return True
     return False
 def trashcanCreate(self, confirmed):
     try:
         os.makedirs(config.suomipoeka.movie_trashpath.value)
         self.reloadList()  # reload to show the trashcan
     except Exception, e:
         self.session.open(
             MessageBox,
             _("Trashcan create failed. Check mounts and permissions."),
             MessageBox.TYPE_ERROR)
         spDebugOut("[spMS] trashcanCreate exception:\n" + str(e))
 def lastPlayedCheck(self, service):
     global gLastPlayedMovies
     try:
         if gLastPlayedMovies is not None:
             if service in gLastPlayedMovies:
                 gLastPlayedMovies.remove(service)
             if len(gLastPlayedMovies) == 0:
                 gLastPlayedMovies = None
     except Exception, e:
         spDebugOut("[spMS] lastPlayedCheck exception:\n" + str(e))
Beispiel #17
0
 def cancel(self):
     try:
         global instanceTab
         instanceTab.remove(self)
         self.timer.stop()
         self.timer.timeout.get().remove(self.timerLaunch)
         self.timer = None
     except Exception, e:
         spDebugOut("[spDF] timer cancel exception:\n%s:%s" %
                    (str(self.function), str(e)))
 def stopRecordQ(self):
     try:
         filenames = ""
         for e in self.recsToStop:
             filenames += "\n" + e.split("/")[-1][:-3]
         self.session.openWithCallback(
             self.stopRecordConfirmation, MessageBox,
             _("Stop ongoing recording?\n") + filenames,
             MessageBox.TYPE_YESNO)
     except Exception, e:
         spDebugOut("[spMS] stopRecordQ exception:\n" + str(e))
 def redButton(self):
     if self.mode != "bookmarks": return
     self.menu.remove(self["menu"].getCurrent())
     self["menu"].setList(self.menu)
     try:
         bmfile = open(config.suomipoeka.folder.value + "/bookmarks.cfg",
                       "w")
         bmfile.writelines([x[0] for x in self.menu])
         bmfile.close()
     except Exception, e:
         spDebugOut("[spMM] redButton exception:\n" + str(e))
 def createDirCB(self, name):
     if name is not None:
         name = self.currentPathSel + "/" + name
         if os.path.exists(name):
             self.session.open(MessageBox,
                               _("Directory " + name + " already exists."),
                               MessageBox.TYPE_ERROR)
         else:
             try:
                 os.mkdir(name)
             except Exception, e:
                 spDebugOut("[spMM] createDir exception:\n" + str(e))
             self.close("reload")
Beispiel #21
0

        
Beispiel #22
0
 def timerLaunch(self):
     from SuomipoekaTasker import spDebugOut
     try:
         global instanceTab
         instanceTab.remove(self)
         self.timer.stop()
         self.timer.timeout.get().remove(self.timerLaunch)
         self.timer = None
         self.function(*self.params)
         #spDebugOut("[spDF] (%d) timerLaunch: %s" %(len(instanceTab), str(self.function)))
     except Exception, e:
         spDebugOut("[spDF] timerLaunch exception:\n%s:%s" %
                    (str(self.function), str(e)))
 def createLinksCB(self, targetPath):
     try:
         if self.currentPathSel == targetPath or targetPath == None: return
         cmd = ""
         for x in self.selections:
             name = self.mlist.getFileNameOfService(x)
             cmd += '; ln -s "' + self.currentPathSel + "/" + name + '" "' + targetPath + name + '"'
         if cmd != "":
             spTasker.shellExecute(
                 cmd[2:]
             )  # first move, then delete if expiration limit is 0
             self.close(None)
     except Exception, e:
         spDebugOut("[spMM] createLinks exception:\n" + str(e))
Beispiel #24
0
 def __del__(self):
     try:
         from MovieSelection import gMS
         global gStopped, gClosedByDelete, gPlayerOpenedList
         if gStopped:
             spDebugOut("[spPlayer] Player closed by user")
             if config.suomipoeka.movie_reopen.value:
                 DelayedFunction(
                     80, gMS.session.execDialog,
                     gMS)  # doesn't crash Enigma2 subtitle functionality
         elif gClosedByDelete:
             spDebugOut("[spPlayer] closed due to file delete")
             DelayedFunction(
                 80, gMS.session.execDialog,
                 gMS)  # doesn't crash Enigma2 subtitle functionality
         else:
             spDebugOut("[spPlayer] closed due to playlist EOF")
             if config.suomipoeka.movie_reopenEOF.value:
                 DelayedFunction(80, gMS.session.execDialog, gMS)
             if gPlayerOpenedList:  # did the player close while movie list was open?
                 DelayedFunction(
                     80, gMS.session.execDialog,
                     gMS)  # doesn't crash Enigma2 subtitle functionality
         movieListState(False)
     except Exception, e:
         spDebugOut("[spPlayer] __del__ exception:\n" + str(e))
 def updateEventInfo(self):
     if not config.suomipoeka.movie_descdis.value:
         try:
             if self["list"].currentSelIsDirectory(
             ) or self["list"].currentSelIsVlc():
                 self["FileSize"].setText("")
                 self["Service"].newService(None)
             else:
                 serviceref = self.getCurrent()
                 self["FileSize"].setText(
                     "(%d MB)" %
                     (os.path.getsize(serviceref.getPath()) / 1048576))
                 self["Service"].newService(serviceref)
         except Exception, e:
             spDebugOut("[spMS] updateEventInfo exception:\n" + str(e))
Beispiel #26
0
    def fixTimerPath(self, old, new):
        try:
            if old.endswith(".ts"): old = old[:-3]
            if new.endswith(".ts"): new = new[:-3]
            for timer in NavigationInstance.instance.RecordTimer.timer_list:
                if timer.isRunning(
                ) and not timer.justplay and timer.Filename == old:
                    timer.dirname = os.path.split(new)[0] + "/"
                    timer.fixMoveCmd = 'mv "' + timer.Filename + '."* "' + timer.dirname + '"'
                    timer.Filename = new
                    spDebugOut("[spRC] fixed path: " + new)
                    break

        except Exception, e:
            spDebugOut("[spRC] fixTimerPath exception:\n" + str(e))
Beispiel #27
0
    def recFilesRead(self):
        if self.recFile is None: self.recFileUpdate()
        if self.recFile is None: return
        self.recRemoteList = []
        try:
            for x in os.listdir(config.suomipoeka.folder.value):
                if x.endswith(".rec") and x != self.recFile.split("/")[-1]:
                    #					spDebugOut("[spRC] reading " + x)
                    recf = open(config.suomipoeka.folder.value + "/" + x, "rb")
                    self.recRemoteList += pickle.load(recf)
                    recf.close()
#				else:
#					spDebugOut("[spRC] skipped " + x)

        except Exception, e:
            spDebugOut("[spRC] recFilesRead exception:\n" + str(e))
 def vlcMovieSelected(self, entry):
     try:
         self.hide()
         #			from Plugins.Extensions.VlcPlayer.VlcPlayer import VlcPlayer
         #			dlg = self.session.open(VlcPlayer, self["list"].vlcServer, VlcFileListWrapper())
         #			dlg.playfile(entry[4], entry[3])
         try:  # v2.5
             self["list"].vlcServer.play(self, entry[4], entry[3],
                                         VlcFileListWrapper())
         except:  # v2.6
             self["list"].vlcServer.play(self.session, entry[4], entry[3],
                                         VlcFileListWrapper())
         self.wasClosed = True
         self.close()
     except Exception, e:
         spDebugOut("[spVLC] vlcMovieSelected exception:\n" + str(e))
Beispiel #29
0
 def __init__(self, delay, function, *params):
     from enigma import eTimer
     from SuomipoekaTasker import spDebugOut
     try:
         global instanceTab
         instanceTab.append(self)
         self.function = function
         self.params = params
         self.timer = None
         self.timer = eTimer()
         self.timer.timeout.get().append(self.timerLaunch)
         self.timer.start(delay, False)
         #spDebugOut("[spDF] initialized: " + str(self.function))
     except Exception, e:
         spDebugOut("[spDF] __init__ exception:\n%s:%s" %
                    (str(self.function), str(e)))
Beispiel #30
0
def suomipoekaStartup(session):
    if not os.path.exists(config.suomipoeka.folder.value):
        spTasker.shellExecute("mkdir " + config.suomipoeka.folder.value)
    spDebugOut("+++ Suomipoeka " + SuomipoekaVersion + " startup")

    if config.suomipoeka.epglang.value:
        eServiceEvent.setEPGLanguage(config.suomipoeka.epglang.value)
    setupKeyResponseValues()
    DelayedFunction(5000, trashCleanSetup)

    # Go into standby if the reason for restart was Suomipoeka auto-restart
    if os.path.exists(config.suomipoeka.folder.value +
                      "/suomipoeka_standby_flag.tmp"):
        spDebugOut("+++ Going into Standby mode after auto-restart")
        Notifications.AddNotification(Screens.Standby.Standby)
        spTasker.shellExecute("rm -f " + config.suomipoeka.folder.value +
                              "/suomipoeka_standby_flag.tmp")