コード例 #1
0
def getDirectories(l, root, hidden=False):
    root = os.path.realpath(root) + os.sep
    if not autoNetwork.isMountOnline(root):
        print("not connected:", root)
        return
    if not os.path.exists(root):
        print("path not exists:", root)
        return
    if not root in l:
        l.append(root)
    for entry in os.listdir(root):
        try:
            if not hidden and entry.startswith('.'):
                continue
            dir_path = os.path.join(root, entry)
            if not os.path.isdir(dir_path):
                continue
            dir_path = os.path.realpath(dir_path) + os.sep
            # Skip excluded directories here
            if any(item.lower() in dir_path.lower() for item in SCAN_EXCLUDE):
                print("skip folder: \"%s\"" % (dir_path))
                continue
            dvd = detectDVDStructure(dir_path)
            bludisc = detectBludiscStructure(dir_path)
            if dvd or bludisc:
                continue
            if not dir_path in l:
                l.append(dir_path)
            getDirectories(l, dir_path, hidden)
        except:
            printStackTrace()
コード例 #2
0
def getDirectories(l, root, hidden=False):
    root = os.path.realpath(root) + os.sep
    if not autoNetwork.isMountOnline(root):
        print "not connected:", root
        return
    if not os.path.exists(root):
        print "path not exists:", root
        return
    if not root in l:
        l.append(root)
    for entry in os.listdir(root):
        try:
            if not hidden and entry.startswith('.'):
                continue
            dir_path = os.path.join(root, entry)
            if not os.path.isdir(dir_path):
                continue
            dir_path = os.path.realpath(dir_path) + os.sep
            # Skip excluded directories here
            if any(item.lower() in dir_path.lower() for item in SCAN_EXCLUDE):
                print "skip folder: \"%s\"" % (dir_path)
                continue
            dvd = detectDVDStructure(dir_path)
            bludisc = detectBludiscStructure(dir_path)
            if dvd or bludisc:
                continue
            if not dir_path in l:
                l.append(dir_path)
            getDirectories(l, dir_path, hidden)
        except:
            printStackTrace()
コード例 #3
0
    def scanForMovies(self, root):
        # print "[AdvancedMovieSelection] scan folder:", root

        scan_service = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + root)
        root_list = self.serviceHandler.list(scan_service)
        if root_list is None:
            print("listing of movies failed")
            return
        tags = set()
        l = []
        dirs = []
        while True:
            serviceref = root_list.getNext()
            if not serviceref.valid():
                break
            dvd = None
            # print serviceref.getPath()
            # dvd structure
            if serviceref.flags & eServiceReference.mustDescent:
                dvd = detectDVDStructure(serviceref.getPath())
                if dvd is not None:
                    if serviceref.getPath()[:-1].endswith(TRASH_NAME):
                        continue
                    serviceref = eServiceReferenceDvd(serviceref, True)
                bludisc = detectBludiscStructure(serviceref.getPath())
                if bludisc is not None:
                    if serviceref.getPath()[:-1].endswith(TRASH_NAME):
                        continue
                    serviceref = eServiceReferenceBludisc(serviceref, True)

                if not dvd and not bludisc:
                    continue

                if False:
                    # add folder dir
                    tempDir = serviceref.getPath()
                    parts = tempDir.split(os.sep)
                    dirName = parts[-2]
                    if self.movieConfig.isHidden(dirName):
                        continue
                    serviceref.setName(dirName)
                    dirs.append((serviceref, None, -1, -1))
                    continue

            # check hidden files
            temp = serviceref.getPath()
            parts = temp.split(os.sep)
            if self.movieConfig.isHidden(parts[-1]):
                continue

            ext = temp.split(".")[-1].lower()
            if ext in AUDIO_EXCLUDE:
                continue

            # check currently moving files
            if serviceUtil.isServiceMoving(serviceref):
                continue

            # check iso and img files
            extension = serviceref.getPath().split(".")[-1].lower()
            if extension == "iso" or extension == "img":
                serviceref = eServiceReferenceDvd(serviceref)

            info = self.serviceHandler.info(serviceref)

            # get begin time
            if dvd is not None:
                begin = int(os.stat(dvd).st_mtime)
            else:
                begin = info.getInfo(serviceref,
                                     iServiceInformation.sTimeCreate)

            # convert space-seperated list of tags into a set
            this_tags = info.getInfoString(
                serviceref, iServiceInformation.sTags).split(' ')
            if this_tags is None or this_tags == ['']:
                this_tags = []
            this_tags = set(this_tags)
            tags |= this_tags

            # add to list
            service_name = info.getName(serviceref)
            mi = MovieInfo(service_name, serviceref, info, begin)
            l.append(mi)

        # we always must add location to movielibrary
        dir_size = getDirSize(root)
        self.movielibrary.addMovieList(root, l, dir_size)
        self.movielibrary.addTags(tags)
コード例 #4
0
    def scanForMovies(self, root):
        # print "[AdvancedMovieSelection] scan folder:", root

        scan_service = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + root)
        root_list = self.serviceHandler.list(scan_service)
        if root_list is None:
            print "listing of movies failed"
            return
        tags = set()
        l = []
        dirs = []
        while 1:
            serviceref = root_list.getNext()
            if not serviceref.valid():
                break
            dvd = None
            # print serviceref.getPath()
            # dvd structure
            if serviceref.flags & eServiceReference.mustDescent:
                dvd = detectDVDStructure(serviceref.getPath())
                if dvd is not None:
                    if serviceref.getPath()[:-1].endswith(TRASH_NAME):
                        continue
                    serviceref = eServiceReferenceDvd(serviceref, True)
                bludisc = detectBludiscStructure(serviceref.getPath())
                if bludisc is not None:
                    if serviceref.getPath()[:-1].endswith(TRASH_NAME):
                        continue
                    serviceref = eServiceReferenceBludisc(serviceref, True)
                
                if not dvd and not bludisc:
                    continue
                
                if False:
                    # add folder dir
                    tempDir = serviceref.getPath()
                    parts = tempDir.split(os.sep)
                    dirName = parts[-2]
                    if self.movieConfig.isHidden(dirName):
                        continue
                    serviceref.setName(dirName)
                    dirs.append((serviceref, None, -1, -1))
                    continue
            
            # check hidden files
            temp = serviceref.getPath()
            parts = temp.split(os.sep)
            if self.movieConfig.isHidden(parts[-1]):
                continue
            
            ext = temp.split(".")[-1].lower()
            if ext in AUDIO_EXCLUDE:
                continue
            
            # check currently moving files
            if serviceUtil.isServiceMoving(serviceref):
                continue
            
            # check iso and img files
            extension = serviceref.getPath().split(".")[-1].lower()
            if extension == "iso" or extension == "img":
                serviceref = eServiceReferenceDvd(serviceref)

            info = self.serviceHandler.info(serviceref)

            # get begin time
            if dvd is not None:
                begin = long(os.stat(dvd).st_mtime)
            else:
                begin = info.getInfo(serviceref, iServiceInformation.sTimeCreate)

            # convert space-seperated list of tags into a set
            this_tags = info.getInfoString(serviceref, iServiceInformation.sTags).split(' ')
            if this_tags is None or this_tags == ['']:
                this_tags = []
            this_tags = set(this_tags)
            tags |= this_tags

            # add to list
            service_name = info.getName(serviceref)
            mi = MovieInfo(service_name, serviceref, info, begin)
            l.append(mi)

        # we always must add location to database
        dir_size = getDirSize(root)
        self.database.addMovieList(root, l, dir_size)
        self.database.addTags(tags)