def __init__(self, name, url, key='0', catIDs='5030,5040', search_mode='eponly',
                 search_fallback=False, enable_daily=True, enable_backlog=False):

        NZBProvider.__init__(self, name)

        self.url = url
        self.key = key

        self.search_mode = search_mode
        self.search_fallback = search_fallback
        self.enable_daily = enable_daily
        self.enable_backlog = enable_backlog

        # 0 in the key spot indicates that no key is needed
        self.needs_auth = self.key != '0'
        self.public = not self.needs_auth

        self.catIDs = catIDs if catIDs else '5030,5040'

        self.default = False

        self._caps = False
        self.use_tv_search = None
        self.cap_tv_search = None
        # self.cap_search = None
        # self.cap_movie_search = None
        # self.cap_audio_search = None

        self.cache = tvcache.TVCache(self, min_time=30)  # only poll newznab providers every 30 minutes max
示例#2
0
    def test__get_size(self):
        """
        Test _get_size
        """
        items_list = [
            None, {}, {'links': None}, {'links': []}, {'links': [{}]},
            {'links': [{'length': 1}, {'length': None}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': ''}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '0'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '123'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '12.3'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '-123'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '-12.3'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': 0}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': 123}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': 12.3}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': -123}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': -12.3}, {'length': 3}]},
        ]
        results_list = [
            -1, -1, -1, -1, -1, -1, -1, 0, 123, -1, -123, -1, 0, 123, 12, -123, -12
        ]

        unicode_items_list = [
            {'links': None}, {'links': []}, {'links': [{}]},
            {'links': [{'length': 1}, {'length': None}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': ''}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '0'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '123'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '12.3'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '-123'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': '-12.3'}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': 0}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': 123}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': 12.3}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': -123}, {'length': 3}]},
            {'links': [{'length': 1}, {'length': -12.3}, {'length': 3}]},
        ]
        unicode_results_list = [
            -1, -1, -1, -1, -1, 0, 123, -1, -123, -1, 0, 123, 12, -123, -12
        ]

        self.assertEqual(
            len(items_list), len(results_list),
            'Number of parameters ({0:d}) and results ({1:d}) does not match'.format(len(items_list), len(results_list))
        )

        self.assertEqual(
            len(unicode_items_list), len(unicode_results_list),
            'Number of parameters ({0:d}) and results ({1:d}) does not match'.format(
                len(unicode_items_list), len(unicode_results_list))
        )

        for (index, item) in enumerate(items_list):
            self.assertEqual(NZBProvider('Test Provider')._get_size(item), results_list[index])

        for (index, item) in enumerate(unicode_items_list):
            self.assertEqual(NZBProvider('Test Provider')._get_size(item), unicode_results_list[index])
示例#3
0
    def __init__(self):

        NZBProvider.__init__(self, 'BinSearch')

        self.url = 'https://www.binsearch.info'
        self.urls = {'rss': urljoin(self.url, 'rss.php')}

        self.public = True
        self.supports_backlog = False
        self.ability_status = self.PROVIDER_BROKEN

        self.cache = BinSearchCache(self, min_time=30)  # only poll Binsearch every 30 minutes max
示例#4
0
    def __init__(self):

        NZBProvider.__init__(self, 'BinSearch')

        self.url = 'https://www.binsearch.info'
        self.urls = {'rss': urljoin(self.url, 'rss.php')}

        self.public = True
        self.supports_backlog = False
        self.ability_status = self.PROVIDER_BROKEN

        self.cache = BinSearchCache(
            self, min_time=30)  # only poll Binsearch every 30 minutes max
示例#5
0
    def __init__(self):
        NZBProvider.__init__(self, 'OMGWTFNZBs')

        self.username = None
        self.api_key = None

        self.cache = OmgwtfnzbsCache(self)

        self.url = 'https://omgwtfnzbs.me/'
        self.urls = {
            'rss': 'https://rss.omgwtfnzbs.me/rss-download.php',
            'api': 'https://api.omgwtfnzbs.me/json/'
        }

        self.proper_strings = ['.PROPER.', '.REPACK.']
示例#6
0
    def test__get_storage_dir(self):
        """
        Test _get_storage_dir
        """
        test_cases = [
            None, 123, 12.3, '', os.path.join('some', 'path', 'to', 'folder')
        ]

        for nzb_dir in test_cases:
            sickbeard.NZB_DIR = nzb_dir

            self.assertEqual(NZBProvider('Test Provider')._get_storage_dir(), nzb_dir)
示例#7
0
    def test__get_storage_dir(self):
        """
        Test _get_storage_dir
        """
        test_cases = [
            None, 123, 12.3, "",
            os.path.join("some", "path", "to", "folder")
        ]

        for nzb_dir in test_cases:
            settings.NZB_DIR = nzb_dir

            assert NZBProvider("Test Provider")._get_storage_dir() == nzb_dir
示例#8
0
    def test_is_active(self):
        """
        Test is_active
        """
        test_cases = {
            (False, False): False,
            (False, None): False,
            (False, True): False,
            (None, False): False,
            (None, None): False,
            (None, True): False,
            (True, False): False,
            (True, None): False,
            (True, True): True,
        }

        for ((use_nzb, enabled), result) in six.iteritems(test_cases):
            sickbeard.USE_NZBS = use_nzb

            provider = NZBProvider('Test Provider')
            provider.enabled = enabled

            self.assertEqual(provider.is_active, result)
示例#9
0
    def test_is_active(self):
        """
        Test is_active
        """
        test_cases = {
            (False, False): False,
            (False, None): False,
            (False, True): False,
            (None, False): False,
            (None, None): False,
            (None, True): False,
            (True, False): False,
            (True, None): False,
            (True, True): True,
        }

        for ((use_nzb, enabled), result) in test_cases.items():
            settings.USE_NZBS = use_nzb

            provider = NZBProvider("Test Provider")
            provider.enabled = enabled

            assert provider.is_active == result
示例#10
0
 def test___init__(self):
     """
     Test __init__
     """
     self.assertEqual(NZBProvider('Test Provider').provider_type, GenericProvider.NZB)
示例#11
0
    def test__get_size(self):
        """
        Test _get_size
        """
        items_list = [
            None,
            {},
            {
                "links": None
            },
            {
                "links": []
            },
            {
                "links": [{}]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": None
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": ""
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "0"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "123"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "12.3"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "-123"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "-12.3"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": 0
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": 123
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": 12.3
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": -123
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": -12.3
                }, {
                    "length": 3
                }]
            },
        ]
        results_list = [
            -1, -1, -1, -1, -1, -1, -1, 0, 123, -1, -123, -1, 0, 123, 12, -123,
            -12
        ]

        unicode_items_list = [
            {
                "links": None
            },
            {
                "links": []
            },
            {
                "links": [{}]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": None
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": ""
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "0"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "123"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "12.3"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "-123"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": "-12.3"
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": 0
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": 123
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": 12.3
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": -123
                }, {
                    "length": 3
                }]
            },
            {
                "links": [{
                    "length": 1
                }, {
                    "length": -12.3
                }, {
                    "length": 3
                }]
            },
        ]
        unicode_results_list = [
            -1, -1, -1, -1, -1, 0, 123, -1, -123, -1, 0, 123, 12, -123, -12
        ]

        assert len(items_list) == len(
            results_list
        ), "Number of parameters ({0:d}) and results ({1:d}) does not match".format(
            len(items_list), len(results_list))

        assert len(unicode_items_list) == len(
            unicode_results_list
        ), "Number of parameters ({0:d}) and results ({1:d}) does not match".format(
            len(unicode_items_list), len(unicode_results_list))

        for (index, item) in enumerate(items_list):
            assert NZBProvider("Test Provider")._get_size(
                item) == results_list[index]

        for (index, item) in enumerate(unicode_items_list):
            assert NZBProvider("Test Provider")._get_size(
                item) == unicode_results_list[index]
示例#12
0
 def test___init__(self):
     """
     Test __init__
     """
     assert NZBProvider(
         "Test Provider").provider_type == GenericProvider.NZB