Ejemplo n.º 1
0
    def test_filter_none(self):
        f = MovieAttributeFilter(Services())
        m1 = build_item('Some movie (1998).avi', type='movie')
        m2 = build_item('Some movie.avi', type='movie')

        self.assertTrue(f.filter('movie-year', '1998', m1))
        self.assertFalse(f.filter('movie-year', '1998', m2))
Ejemplo n.º 2
0
    def test_proper(self):
        s = BasicSorter(Services())

        i1 = build_item('series x s01e01.mp4')
        i2 = build_item('series x s01e01.proper.mp4')

        r = s.sort([i1, i2])
        self.assertTrue(r[0] == i2)
Ejemplo n.º 3
0
    def test_by_ratio(self):
        s = BasicSorter(Services())

        i1 = build_item('the.movie', seeds=100, leechers=5)
        i2 = build_item('the.movie', seeds=100, leechers=200)
        i3 = build_item('the.movie', seeds=100, leechers=50)

        r = s.sort([i1, i2, i3])
        self.assertTrue(r == [i1, i3, i2])
Ejemplo n.º 4
0
    def test_age(self):
        now = int(time.time())
        f = SourceAttributeFilter(Services())
        i = build_item('Series A S01E01', created=now - 100)

        self.assertTrue(f.filter('age-min', 50, i))
        self.assertFalse(f.filter('age-min', 200, i))

        self.assertTrue(f.filter('age-max', 200, i))
        self.assertFalse(f.filter('age-max', 50, i))
Ejemplo n.º 5
0
    def test_eq_func(self):
        f = SourceAttributeFilter(Services())
        i = build_item('Series A S01E01', size=100, provider='prov1')

        # Test strings
        self.assertTrue(f.filter('name', 'Series A S01E01', i))
        self.assertFalse(f.filter('name', 'xxx', i))

        # Test integers
        self.assertTrue(f.filter('size', 100, i))
        self.assertFalse(f.filter('size', 200, i))
Ejemplo n.º 6
0
    def __init__(
        self,
        settings_path: str,
        database_path: str,
        log_level: int = logging.WARNING,
    ):
        # Setup logging
        handler = logging.StreamHandler()
        handler.setFormatter(LogFormatter(defaults.LOG_FORMAT))

        logger = logging.getLogger(defaults.APP_NAME)
        logger.setLevel(log_level)
        logger.addHandler(handler)

        # Setup filepaths
        touch(database_path)
        touch(settings_path)

        network_cache_path = appdirs.user_cache_dir() + "/arroyo/network"
        os.makedirs(network_cache_path, exist_ok=True)

        # Setup core
        self.srvs = Services(
            logger=logger,
            db=database.Database("sqlite:///" + database_path),
            settings=Settings(
                ConfigFileStorage(settings_path, root=defaults.APP_NAME)),
            loader=loader.ClassLoader(defaults.PLUGINS),
        )

        if self.srvs.settings.get("cache.enabled"):
            self.srvs.cache = cache.DiskCache(
                basedir=network_cache_path,
                delta=self.srvs.settings.get("cache.delta"),
            )

        # Setup engines
        self.scraper = scraper.Engine(self.srvs)
        self.filters = query.Engine(self.srvs)
        self.downloads = downloads.Downloads(self.srvs)
Ejemplo n.º 7
0
    def test_alias_filter(self):
        f = EpisodeAttributeFilter(Services())
        i = build_item('Series A (2017) S02E03')

        self.assertTrue(f.filter('series-year', '2017', i))
Ejemplo n.º 8
0
    def test_basic_attribute_match(self):
        f = EpisodeAttributeFilter(Services())
        i = build_item('Series A S02E03')

        self.assertTrue(f.filter('series', 'Series A', i))
        self.assertFalse(f.filter('series', 'Series B', i))
Ejemplo n.º 9
0
    def test_since(self):
        f = SourceAttributeFilter(Services())
        i = build_item('Foo', created=1577833200)  # 2020-01-01

        self.assertTrue(f.filter('since', '2019', i))
        self.assertFalse(f.filter('since', '2021', i))
Ejemplo n.º 10
0
    def test_type(self):
        f = SourceAttributeFilter(Services())
        i = build_item('Series A S01E01', size=100, provider='prov1')

        self.assertTrue(f.filter('type', 'episode', i))
        self.assertFalse(f.filter('type', 'movie', i))
Ejemplo n.º 11
0
 def test_min_func(self):
     f = SourceAttributeFilter(Services())
     i = build_item('Series A S01E01', size=100, provider='prov1')
     self.assertTrue(f.filter('size-min', 100, i))
     self.assertFalse(f.filter('size-min', 101, i))
Ejemplo n.º 12
0
    def setUp(self):
        self.srvs = Services(loader=ClassLoader(dict([self.DOWNLOADER_SPEC])))
        self.srvs.settings.set('downloader',
                               self.DOWNLOADER_SPEC[0].split('.')[-1])

        self.downloads = Downloads(self.srvs)
Ejemplo n.º 13
0
    def test_like_func(self):
        f = SourceAttributeFilter(Services())
        i = build_item('Series A S01E01', size=100, provider='prov1')

        self.assertTrue(f.filter('name-like', r'Series [AB] S01E01', i))
        self.assertFalse(f.filter('name-like', r'Series [CD] S01E01', i))
Ejemplo n.º 14
0
    def test_glob_func(self):
        f = SourceAttributeFilter(Services())
        i = build_item('Series A S01E01', size=100, provider='prov1')

        self.assertTrue(f.filter('name-glob', 'Series * S01E01', i))
        self.assertFalse(f.filter('name-glob', 'Foo *', i))
Ejemplo n.º 15
0
    def test_alias_filter_with_modifier(self):
        f = MovieAttributeFilter(Services())
        i = build_item("My.Friend.Flicka.1943.1080p.AMZN.WEBRip.DDP2.0.x264")

        self.assertTrue(f.filter('movie-year-max', '1950', i))
Ejemplo n.º 16
0
 def _get_provider(self):
     return self._get_provider_cls()(Services())
Ejemplo n.º 17
0
    def test_in_func(self):
        f = SourceAttributeFilter(Services())
        i = build_item('Series A S01E01', size=100, provider='prov1')

        self.assertTrue(f.filter('provider-in', 'prov1, prov2', i))