def main():
    if not os.path.exists(path):
        os.makedirs(path)

    createTestFiles()
    service_file = os.path.join(path, "access_test.ts")
    print restriction.isAccessible(("VSR-12",))
    restriction.setToService(service_file, "VSR-0")
    restriction.setToService(service_file, "VSR-12")
    restriction.setToService(service_file, "VSR-19")
    restriction.setToService(service_file, "VSR-19", True)
Пример #2
0
    def getMovieList(self, sort_type, filter_tags=None, filter_description=None):
        if config.AdvancedMovieSelection.db_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"]:
                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.db_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
Пример #3
0
    def getMovieListPerMountDir(self,
                                sort_type,
                                filter_tags=None,
                                filter_description=None):
        print "getMovieListPerMountDir", str(sort_type), str(filter_tags), str(
            filter_description)
        l = []
        dirs = self.getDirectoryList(True)
        movie_count = 0
        for root in config.AdvancedMovieSelection.videodirs.value:
            root = os.path.realpath(root) + os.sep
            l1 = []
            for location in dirs:
                if not location.startswith(root):
                    continue
                item = self["db"][location]
                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, ))
                    movie_count += 1

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

            l.extend(l1)

        if not sort_type & SortProvider.SORT_WITH_DIRECTORIES:
            self.sortMovieList(l, sort_type)
        print "collected movies", str(movie_count)
        return l
Пример #4
0
    def getMovieListPerMountDir(self, sort_type, filter_tags=None, filter_description=None):
        print "getMovieListPerMountDir", str(sort_type), str(filter_tags), str(filter_description)
        l = []
        dirs = self.getDirectoryList(True)
        movie_count = 0
        for root in config.AdvancedMovieSelection.videodirs.value:
            root = os.path.realpath(root) + os.sep
            l1 = []
            for location in dirs:
                if not location.startswith(root):
                    continue
                item = self["db"][location]
                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,))
                    movie_count += 1
                
            if sort_type & SortProvider.SORT_WITH_DIRECTORIES:
                print "sorting", str(len(l1)), root
                self.sortMovieList(l1, sort_type)
                if len(l1) >= config.AdvancedMovieSelection.movielibrary_show_mark_cnt.value:
                    self.insertMarker(l1, root)

            l.extend(l1)

        if not sort_type & SortProvider.SORT_WITH_DIRECTORIES:
            self.sortMovieList(l, sort_type)
        print "collected movies", str(movie_count)
        return l