示例#1
0
 def _loadFromSettings(self):
     # Collect together all of the scheduled videos
     numScheduleEntries = Settings.getNumberOfScheduleRules()
     log("Schedule: Number of schedule entries is %d" % numScheduleEntries)
     itemNum = self.idOffset + 1
     while itemNum <= numScheduleEntries:
         videoFile = Settings.getRuleVideoFile(itemNum)
         if videoFile not in [None, ""]:
             # Support special paths like smb:// means that we can not just call
             # os.path.isfile as it will return false even if it is a file
             # (A bit of a shame - but that's the way it is)
             if videoFile.startswith("smb://") or os_path_isfile(videoFile):
                 overlayFile = Settings.getRuleOverlayFile(itemNum)
                 startTime = Settings.getRuleStartTime(itemNum)
                 endTime = Settings.getRuleEndTime(itemNum)
                 log("Schedule: Item %d (Start:%d, End:%d) contains video %s"
                     % (itemNum, startTime, endTime, videoFile))
                 details = {
                     'id': itemNum,
                     'start': startTime,
                     'end': endTime,
                     'video': videoFile,
                     'overlay': overlayFile
                 }
                 self.scheduleDetails.append(details)
             else:
                 log("Schedule: File does not exist: %s" % videoFile)
         else:
             log("Schedule: Video file not set for entry %d" % itemNum)
         itemNum = itemNum + 1
示例#2
0
    def _getUsablePath(self, rawPath):
        workingPath = rawPath

        # Start by removing the stack details
        if workingPath.startswith("stack://"):
            workingPath = workingPath.replace("stack://", "").split(" , ",
                                                                    1)[0]

        if Settings.isSmbEnabled() and not ('@' in workingPath):
            if workingPath.startswith("smb://"):
                log("### Try authentication share")
                workingPath = workingPath.replace(
                    "smb://", "smb://%s:%s@" %
                    (Settings.getSmbUser(), Settings.getSmbPassword()))
                log("### %s" % workingPath)
            # Also handle the apple format
            elif workingPath.startswith("afp://"):
                log("### Try authentication share")
                workingPath = workingPath.replace(
                    "afp://", "afp://%s:%s@" %
                    (Settings.getSmbUser(), Settings.getSmbPassword()))
                log("### %s" % workingPath)

        # handle episodes stored as rar files
        if workingPath.startswith("rar://"):
            workingPath = workingPath.replace("rar://", "")

        fileExt = None
        if os_path_isfile(workingPath):
            fileExt = os.path.splitext(workingPath)[1]
        # If this is a file, then get it's parent directory
        # Also limit file extensions to a maximum of 4 characters
        if fileExt is not None and fileExt != "" and len(fileExt) < 5:
            workingPath = os_path_split(workingPath)[0]

        # If the path currently ends in the directory separator
        # then we need to clear an extra one
        if (workingPath[-1] == os.sep) or (workingPath[-1] == os.altsep):
            workingPath = workingPath[:-1]

        return workingPath
示例#3
0
    def _getUsablePath(self, rawPath):
        workingPath = rawPath

        # Start by removing the stack details
        if workingPath.startswith("stack://"):
            workingPath = workingPath.replace("stack://", "").split(" , ", 1)[0]

        if Settings.isSmbEnabled() and not ('@' in workingPath):
            if workingPath.startswith("smb://"):
                log("### Try authentication share")
                workingPath = workingPath.replace("smb://", "smb://%s:%s@" % (Settings.getSmbUser(), Settings.getSmbPassword()))
                log("### %s" % workingPath)
            # Also handle the apple format
            elif workingPath.startswith("afp://"):
                log("### Try authentication share")
                workingPath = workingPath.replace("afp://", "afp://%s:%s@" % (Settings.getSmbUser(), Settings.getSmbPassword()))
                log("### %s" % workingPath)

        # handle episodes stored as rar files
        if workingPath.startswith("rar://"):
            workingPath = workingPath.replace("rar://", "")

        # Support special paths like smb:// means that we can not just call
        # os.path.isfile as it will return false even if it is a file
        # (A bit of a shame - but that's the way it is)
        fileExt = None
        if workingPath.startswith("smb://") or workingPath.startswith("afp://") or os_path_isfile(workingPath):
            fileExt = os.path.splitext(workingPath)[1]
        # If this is a file, then get it's parent directory
        # Also limit file extensions to a maximum of 4 characters
        if fileExt is not None and fileExt != "" and len(fileExt) < 5:
            workingPath = os_path_split(workingPath)[0]

        # If the path currently ends in the directory separator
        # then we need to clear an extra one
        if (workingPath[-1] == os.sep) or (workingPath[-1] == os.altsep):
            workingPath = workingPath[:-1]

        return workingPath
示例#4
0
 def _loadFromSettings(self):
     # Collect together all of the scheduled videos
     numScheduleEntries = Settings.getNumberOfScheduleRules()
     log("Schedule: Number of schedule entries is %d" % numScheduleEntries)
     itemNum = self.idOffset + 1
     while itemNum <= numScheduleEntries:
         videoFile = Settings.getRuleVideoFile(itemNum)
         if videoFile not in [None, ""]:
             # Support special paths like smb:// means that we can not just call
             # os.path.isfile as it will return false even if it is a file
             # (A bit of a shame - but that's the way it is)
             if videoFile.startswith("smb://") or os_path_isfile(videoFile):
                 overlayFile = Settings.getRuleOverlayFile(itemNum)
                 startTime = Settings.getRuleStartTime(itemNum)
                 endTime = Settings.getRuleEndTime(itemNum)
                 log("Schedule: Item %d (Start:%d, End:%d) contains video %s" % (itemNum, startTime, endTime, videoFile))
                 details = {'id': itemNum, 'start': startTime, 'end': endTime, 'video': videoFile, 'overlay': overlayFile}
                 self.scheduleDetails.append(details)
             else:
                 log("Schedule: File does not exist: %s" % videoFile)
         else:
             log("Schedule: Video file not set for entry %d" % itemNum)
         itemNum = itemNum + 1
示例#5
0
    def _loadFromFile(self):
        # Get the videos schedule that is stored in the file
        scheduleFileName = Settings.getScheduleFile()
        if scheduleFileName in [None, ""]:
            log("Schedule: No schedule file set")
            return

        log("Schedule: Searching for schedule file: %s" % scheduleFileName)

        # Return False if file does not exist
        if not xbmcvfs.exists(scheduleFileName):
            log("Schedule: No schedule file found: %s" % scheduleFileName)
            return

        # Save off the time this file was modified
        statFile = xbmcvfs.Stat(scheduleFileName)
        self.lastScheduleModified = statFile.st_mtime()
        log("Schedule: Reading in schedule file with modify time: %s" % str(self.lastScheduleModified))

        # The file exists, so start loading it
        try:
            # Need to first load the contents of the file into
            # a string, this is because the XML File Parse option will
            # not handle formats like smb://
            scheduleFile = xbmcvfs.File(scheduleFileName, 'r')
            scheduleFileStr = scheduleFile.read()
            scheduleFile.close()

            # Create an XML parser
            scheduleXml = ET.ElementTree(ET.fromstring(scheduleFileStr))
            rootElement = scheduleXml.getroot()

            log("Schedule: Root element is = %s" % rootElement.tag)

            # Check which format if being used
            if rootElement.tag == "schedule":
                log("Schedule: Schedule format file detected")
                #    <schedule>
                #        <rule start="14:24" end="14:37" video="video3.mkv" overlay="WindowFrame1.png" />
                #    </schedule>

                # Get the directory that the schedule file is in as this might be needed
                # if we have local paths in the XML file
                directory = os_path_split(scheduleFileName)[0]

                # There could be multiple rule entries, so loop through all of them
                itemNum = self.idOffset + 1
                for ruleElem in scheduleXml.findall('rule'):
                    if ruleElem is not None:
                        videoFile = ruleElem.get('video', None)
                        overlayFile = ruleElem.get('overlay', None)
                        startTime = self._convertTimeToMinutes(ruleElem.get('start', "00:00"))
                        endTime = self._convertTimeToMinutes(ruleElem.get('end', "00:00"))

                    if (videoFile not in [None, ""]) and (startTime not in [None, ""]) and (endTime not in [None, ""]):
                        # Make it a full path if it is not already
                        if videoFile.startswith('..') or (("/" not in videoFile) and ("\\" not in videoFile)):
                            videoFile = os_path_join(directory, videoFile)
                        if overlayFile not in [None, ""]:
                            if overlayFile.startswith('..') or (("/" not in overlayFile) and ("\\" not in overlayFile)):
                                overlayFile = os_path_join(directory, overlayFile)
                        log("Schedule File: Item %d (Start:%d, End:%d) contains video %s" % (itemNum, startTime, endTime, videoFile))

                        # Support special paths like smb:// means that we can not just call
                        # os.path.isfile as it will return false even if it is a file
                        # (A bit of a shame - but that's the way it is)
                        if videoFile.startswith("smb://") or os_path_isfile(videoFile):
                            details = {'id': itemNum, 'start': startTime, 'end': endTime, 'video': videoFile, 'overlay': overlayFile}
                            self.scheduleDetails.append(details)
                        else:
                            log("Schedule: File does not exist: %s" % videoFile)

                        itemNum = itemNum + 1
            else:
                log("Schedule: Unknown schedule file format")

            del scheduleXml
        except:
            log("Schedule: Failed to process schedule file: %s" % scheduleFileName, xbmc.LOGERROR)
            log("Schedule: %s" % traceback.format_exc(), xbmc.LOGERROR)
示例#6
0
    def _loadFromFile(self):
        # Get the videos schedule that is stored in the file
        scheduleFileName = Settings.getScheduleFile()
        if scheduleFileName in [None, ""]:
            log("Schedule: No schedule file set")
            return

        log("Schedule: Searching for schedule file: %s" % scheduleFileName)

        # Return False if file does not exist
        if not xbmcvfs.exists(scheduleFileName):
            log("Schedule: No schedule file found: %s" % scheduleFileName)
            return

        # Save off the time this file was modified
        statFile = xbmcvfs.Stat(scheduleFileName)
        self.lastScheduleModified = statFile.st_mtime()
        log("Schedule: Reading in schedule file with modify time: %s" %
            str(self.lastScheduleModified))

        # The file exists, so start loading it
        try:
            # Need to first load the contents of the file into
            # a string, this is because the XML File Parse option will
            # not handle formats like smb://
            scheduleFile = xbmcvfs.File(scheduleFileName, 'r')
            scheduleFileStr = scheduleFile.read()
            scheduleFile.close()

            # Create an XML parser
            scheduleXml = ET.ElementTree(ET.fromstring(scheduleFileStr))
            rootElement = scheduleXml.getroot()

            log("Schedule: Root element is = %s" % rootElement.tag)

            # Check which format if being used
            if rootElement.tag == "schedule":
                log("Schedule: Schedule format file detected")
                #    <schedule>
                #        <rule start="14:24" end="14:37" video="video3.mkv" overlay="WindowFrame1.png" />
                #    </schedule>

                # Get the directory that the schedule file is in as this might be needed
                # if we have local paths in the XML file
                directory = os_path_split(scheduleFileName)[0]

                # There could be multiple rule entries, so loop through all of them
                itemNum = self.idOffset + 1
                for ruleElem in scheduleXml.findall('rule'):
                    if ruleElem is not None:
                        videoFile = ruleElem.get('video', None)
                        overlayFile = ruleElem.get('overlay', None)
                        startTime = self._convertTimeToMinutes(
                            ruleElem.get('start', "00:00"))
                        endTime = self._convertTimeToMinutes(
                            ruleElem.get('end', "00:00"))

                    if (videoFile not in [None, ""]) and (startTime not in [
                            None, ""
                    ]) and (endTime not in [None, ""]):
                        # Make it a full path if it is not already
                        if videoFile.startswith('..') or (
                            ("/" not in videoFile) and
                            ("\\" not in videoFile)):
                            videoFile = os_path_join(directory, videoFile)
                        if overlayFile not in [None, ""]:
                            if overlayFile.startswith('..') or (
                                ("/" not in overlayFile) and
                                ("\\" not in overlayFile)):
                                overlayFile = os_path_join(
                                    directory, overlayFile)
                        log("Schedule File: Item %d (Start:%d, End:%d) contains video %s"
                            % (itemNum, startTime, endTime, videoFile))

                        # Support special paths like smb:// means that we can not just call
                        # os.path.isfile as it will return false even if it is a file
                        # (A bit of a shame - but that's the way it is)
                        if videoFile.startswith("smb://") or os_path_isfile(
                                videoFile):
                            details = {
                                'id': itemNum,
                                'start': startTime,
                                'end': endTime,
                                'video': videoFile,
                                'overlay': overlayFile
                            }
                            self.scheduleDetails.append(details)
                        else:
                            log("Schedule: File does not exist: %s" %
                                videoFile)

                        itemNum = itemNum + 1
            else:
                log("Schedule: Unknown schedule file format")

            del scheduleXml
        except:
            log(
                "Schedule: Failed to process schedule file: %s" %
                scheduleFileName, xbmc.LOGERROR)
            log("Schedule: %s" % traceback.format_exc(), xbmc.LOGERROR)