Ejemplo n.º 1
0
    def getMovieList(self, sort_type, filter_tags=None, filter_description=None):
        if config.AdvancedMovieSelection.movielibrary_mark.value and sort_type & SortProvider.SORT_WITH_DIRECTORIES:
            return self.getMovieListPerMountDir(sort_type, filter_tags, filter_description)
        print "getMovieList", str(sort_type), str(filter_tags), str(filter_description)
        l = []
        dirs = self.getDirectoryList(True)
        for location in dirs:
            item = self["db"][location]
            l1 = []
            for i in item["movies"]:
                if config.AdvancedMovieSelection.hide_seen_movies.value and hasLastPosition(i.serviceref):
                    continue
                this_tags = i.getTags()
                if not accessRestriction.isAccessible(this_tags):
                    continue
                if filter_tags is not None and not set(this_tags).issuperset(filter_tags):
                    continue
                if filter_description:
                    descr = i.info.getInfoString(i.serviceref, iServiceInformation.sDescription)
                    if not filter_description.lower() in str(descr).lower():
                        continue 
                l1.append((i,))
            
            if sort_type & SortProvider.SORT_WITH_DIRECTORIES:
                print "sorting", str(len(l1)), location
                self.sortMovieList(l1, sort_type)
                if len(l1) >= config.AdvancedMovieSelection.movielibrary_show_mark_cnt.value:
                    self.insertMarker(l1, location)

            l.extend(l1)
        if not sort_type & SortProvider.SORT_WITH_DIRECTORIES:
            self.sortMovieList(l, sort_type)
        print "collected movies", str(len(l))
        return l
Ejemplo n.º 2
0
    def getMovieList(self, sort_type, filter_tags=None, filter_description=None):
        if config.AdvancedMovieSelection.movielibrary_mark.value and sort_type & SortProvider.SORT_WITH_DIRECTORIES:
            return self.getMovieListPerMountDir(sort_type, filter_tags, filter_description)
        print("getMovieList", str(sort_type), str(filter_tags), str(filter_description))
        l = []
        dirs = self.getDirectoryList(True)
        for location in dirs:
            item = self["db"][location]
            l1 = []
            for i in item["movies"]:
                if config.AdvancedMovieSelection.hide_seen_movies.value and hasLastPosition(i.serviceref):
                    continue
                this_tags = i.getTags()
                if not accessRestriction.isAccessible(this_tags):
                    continue
                if filter_tags is not None and not set(this_tags).issuperset(filter_tags):
                    continue
                if filter_description:
                    descr = i.info.getInfoString(i.serviceref, iServiceInformation.sDescription)
                    if not filter_description.lower() in str(descr).lower():
                        continue
                l1.append((i,))

            if sort_type & SortProvider.SORT_WITH_DIRECTORIES:
                print("sorting", str(len(l1)), location)
                self.sortMovieList(l1, sort_type)
                if len(l1) >= config.AdvancedMovieSelection.movielibrary_show_mark_cnt.value:
                    self.insertMarker(l1, location)

            l.extend(l1)
        if not sort_type & SortProvider.SORT_WITH_DIRECTORIES:
            self.sortMovieList(l, sort_type)
        print("collected movies", str(len(l)))
        return l
Ejemplo n.º 3
0
    def scanForMovies(self, root, addtolib=True):
        # 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 = []
        movie_seen = 0
        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)
            if hasLastPosition(serviceref):
                movie_seen += 1

        dir_size = 0
        # add location to movielibrary
        if addtolib:
            dir_size = getDirSize(root)
            self.movielibrary.addMovieList(root, l, dir_size, movie_seen)
            self.movielibrary.addTags(tags)
        return l, dir_size, movie_seen
Ejemplo n.º 4
0
 def updateItem(item):
     item_seen = 0
     for mi in item["movies"]:
         if hasLastPosition(mi.serviceref):
             item_seen += 1
     item["movie_seen"] = item_seen