Beispiel #1
0
    def test_is_ignored(self):
        test_data = [[
            True, 'Homeland.S02.HDTV.x264-EVOLVE', {
                'title': 'Homeland',
                'season': 2
            }
        ],
                     [
                         False, 'Homeland.S02E11.HDTV.x264-EVOLVE', {
                             'title': 'Homeland',
                             'episode': 11,
                             'season': 2
                         }
                     ]]
        for params in test_data:
            release_info = parser.ReleaseInfo.from_internal_parser(
                params[1], **params[2])
            self.assertEqual(params[0], parser.is_ignored(release_info))

        rls = parser.ReleaseInfo.from_internal_parser(
            'The.Mentalist.S05E10.720p.HDTV.X264-DIMENSION', **{
                'title': 'The.Mentalist',
                'episode': 10,
                'season': 2
            })
        config.set("filter_ignore", "string10", "test")
        self.assertFalse(parser.is_ignored(rls))
        config.set("filter_ignore", "string11", "mental")
        self.assertTrue(parser.is_ignored(rls))
Beispiel #2
0
 def test_valid_movie(self):
     release_info_1 = parser.ReleaseInfo.from_internal_parser(
         "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC",
         **{'title': 'teen.wolf', 'media_type': constants.MEDIA_MOVIE}
     )
     section_name = "section_movie"
     config.set(section_name, "year_min", 0)
     config.set(section_name, "year_max", 0)
     self.assertTrue(parser.valid_movie(release_info_1))
Beispiel #3
0
 def test_valid_movie(self):
     release_info_1 = parser.ReleaseInfo.from_internal_parser(
         "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC",
         **{'title': 'teen.wolf', 'media_type': constants.MEDIA_MOVIE}
     )
     section_name = "section_movie"
     config.set(section_name, "year_min", 0)
     config.set(section_name, "year_max", 0)
     self.assertTrue(parser.valid_movie(release_info_1))
Beispiel #4
0
    def test_valid_size(self):
        t = Torrent.from_file(get_fixture("linux-iso.torrent"))
        section_name = "section_movie"
        config.set(section_name, "size_min", 1)
        config.set(section_name, "size_max", 10000)
        self.assertTrue(parser.valid_size(t, section_name))

        config.set(section_name, "size_max", 400)
        self.assertFalse(parser.valid_size(t, section_name))

        config.set(section_name, "size_min", 7000)
        config.set(section_name, "size_max", 10000)
        self.assertFalse(parser.valid_size(t, section_name))
Beispiel #5
0
    def test_valid_size(self):
        t = Torrent.from_file(get_fixture("linux-iso.torrent"))
        section_name = "section_movie"
        config.set(section_name, "size_min", 1)
        config.set(section_name, "size_max", 10000)
        self.assertTrue(parser.valid_size(t, section_name))

        config.set(section_name, "size_max", 400)
        self.assertFalse(parser.valid_size(t, section_name))

        config.set(section_name, "size_min", 7000)
        config.set(section_name, "size_max", 10000)
        self.assertFalse(parser.valid_size(t, section_name))
Beispiel #6
0
def save(service):
    try:
        for k, v in request.values.items():
            config.set(service, k.replace(service + "_", ""), v)
    except (KeyError, TypeError):
        logger.warning("Malformed request received")
        abort(httplib.BAD_REQUEST)
    else:
        if config.save():
            flash("Saved configuration successfully")
        else:
            flash("There was an error saving your config")
        return redirect(url_for(".index"))
Beispiel #7
0
    def test_validate_section(self):
        test_data = [
            ["section_tv", self.release_a, {'title': 'The.Mentalist', 'episode': 10, 'season': 2}],
            ["section_tv", self.release_c, {'title': 'Falcon', 'episode': 4, 'season': 1}],
            [False, "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC", {'title': 'Teen.Wolf', 'year': 1985}],
            [False, self.release_b, {'title': 'Homeland', 'episode': 11, 'season': 2}],
            [False, self.release_d, {'title': 'Easy.Money', 'year': 2010}],

        ]
        config.set("filter_ignore", "string11", "blahhh") # fix other test causing this to fail, fix later
        for params in test_data:
            release_info = parser.ReleaseInfo.from_internal_parser(params[1], **params[2])
            found_section = parser.validate_section(release_info)
            self.assertEqual(params[0], found_section, "{} -> {}".format(params[1], found_section))
Beispiel #8
0
    def test_validate_section(self):
        test_data = [
            ["section_tv", self.release_a, {'title': 'The.Mentalist', 'episode': 10, 'season': 2}],
            ["section_tv", self.release_c, {'title': 'Falcon', 'episode': 4, 'season': 1}],
            [False, "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC", {'title': 'Teen.Wolf', 'year': 1985}],
            [False, self.release_b, {'title': 'Homeland', 'episode': 11, 'season': 2}],
            [False, self.release_d, {'title': 'Easy.Money', 'year': 2010}],

        ]
        config.set("filter_ignore", "string11", "blahhh") # fix other test causing this to fail, fix later
        for params in test_data:
            release_info = parser.ReleaseInfo.from_internal_parser(params[1], **params[2])
            found_section = parser.validate_section(release_info)
            self.assertEqual(params[0], found_section, "{} -> {}".format(params[1], found_section))
Beispiel #9
0
    def test_is_ignored(self):
        test_data = [
            [True, 'Homeland.S02.HDTV.x264-EVOLVE', {'title': 'Homeland', 'season': 2}],
            [False, 'Homeland.S02E11.HDTV.x264-EVOLVE', {'title': 'Homeland', 'episode': 11, 'season': 2}]
        ]
        for params in test_data:
            release_info = parser.ReleaseInfo.from_internal_parser(params[1], **params[2])
            self.assertEqual(params[0], parser.is_ignored(release_info))

        rls = parser.ReleaseInfo.from_internal_parser(
            'The.Mentalist.S05E10.720p.HDTV.X264-DIMENSION',
            **{'title': 'The.Mentalist', 'episode': 10, 'season': 2})
        config.set("filter_ignore", "string10", "test")
        self.assertFalse(parser.is_ignored(rls))
        config.set("filter_ignore", "string11", "mental")
        self.assertTrue(parser.is_ignored(rls))
Beispiel #10
0
def save():
    """ Save the settings for the posted config section

    :return: Save status response
    :rtype: dict
    """
    for name, value in request.values.items():
        section, key = name.split("__")
        if value == "on":
            value = "true"
        elif value == "off":
            value = "false"
        config.set(section, key, value)
    if config.save():
        status = api.STATUS_OK
        msg = "Saved settings successfully"
    else:
        status = api.STATUS_FAIL
        msg = "Error saving settings"
    return {"msg": msg, "status": status}
Beispiel #11
0
def save():
    """ Save the settings for the posted config section

    :return: Save status response
    :rtype: dict
    """
    for name, value in list(request.values.items()):
        section, key = name.split("__")
        if value == "on":
            value = "true"
        elif value == "off":
            value = "false"
        config.set(section, key, value)
    if config.save():
        status = api.STATUS_OK
        msg = "Saved settings successfully"
    else:
        status = api.STATUS_FAIL
        msg = "Error saving settings"
    return {'msg': msg, 'status': status}
Beispiel #12
0
def create():
    """ Create a new RSS feed over XHR

    :return: Feed creation status response
    :rtype: Response
    """
    status = api.STATUS_FAIL

    feed = "rss_{0}".format(re.sub('[^0-9a-zA-Z]+', '_', request.values['feed'].lower()))
    if config.has_section(feed):
        msg = "Duplicate feed name"
    else:
        config.add_section(feed)
        try:
            config.set(feed, "url", request.values['url'])
            config.set(feed, "interval", request.values['interval'])
            config.set(feed, "enabled", request.values['enabled'])
            if config.save():
                msg = "Feed {0} saved successfully, reloading page.".format(request.values['feed'])
                status = api.STATUS_OK
            else:
                msg = "Error saving config to disk."
        except KeyError:
            msg = "Failed to save config. Malformed request: {0}".format(feed)
    log.error(msg) if status == api.STATUS_FAIL else log.info(msg)
    return dict(msg=msg, status=status)
Beispiel #13
0
def create():
    """ Create a new RSS feed over XHR

    :return: Feed creation status response
    :rtype: Response
    """
    status = api.STATUS_FAIL

    feed = "rss_{0}".format(re.sub('[^0-9a-zA-Z]+', '_', request.values['feed'].lower()))
    if config.has_section(feed):
        msg = "Duplicate feed name"
    else:
        config.add_section(feed)
        try:
            config.set(feed, "url", request.values['url'])
            config.set(feed, "interval", request.values['interval'])
            config.set(feed, "enabled", request.values['enabled'])
            if config.save():
                msg = "Feed {0} saved successfully, reloading page.".format(request.values['feed'])
                status = api.STATUS_OK
            else:
                msg = "Error saving config to disk."
        except KeyError:
            msg = "Failed to save config. Malformed request: {0}".format(feed)
    log.error(msg) if status == api.STATUS_FAIL else log.info(msg)
    return dict(msg=msg, status=status)
Beispiel #14
0
def create():
    status = 1
    try:
        feed = "rss_{0}".format(request.values['new_short_name'])
        if config.has_section(feed):
            raise KeyError()
        else:
            config.add_section(feed)
    except KeyError:
        msg = "Duplicate feed name"
    else:
        try:
            config.set(feed, "url", request.values['new_url'])
            config.set(feed, "interval", request.values['new_interval'])
            config.set(feed, "enabled", request.values['new_enabled'])

            if config.save():
                msg = "RSS Feed saved successfully: {0}".format(request.values['new_short_name'])
                status = 0
            else:
                msg = "Error saving config to disk."
        except KeyError:
            msg = "Failed to save config. Malformed request: {0}".format(feed)
    if status == 1:
        logger.error(msg)
    else:
        logger.info(msg)
    return redirect(url_for(".index"))
Beispiel #15
0
def save(provider):
    """ Save a providers configuration

    TODO Use PUT?

    :param provider: Provider key/name
    :type provider: unicode
    :return: Redirect response
    :rtype: Response
    """
    try:
        for k, v in request.values.items():
            config.set(provider, k.replace(provider + "_", ""), v)
    except (KeyError, TypeError):
        log.warning("Malformed request received")
        abort(httplib.BAD_REQUEST)
    else:
        if config.save():
            flash("Saved configuration successfully")
        else:
            flash("There was an error saving your provider config")
        return redirect(url_for(".index"))
Beispiel #16
0
def save(provider):
    """ Save a providers configuration

    TODO Use PUT?

    :param provider: Provider key/name
    :type provider: unicode
    :return: Redirect response
    :rtype: Response
    """
    try:
        for k, v in request.values.items():
            config.set(provider, k.replace(provider + "_", ""), v)
    except (KeyError, TypeError):
        log.warning("Malformed request received")
        abort(httplib.BAD_REQUEST)
    else:
        if config.save():
            flash("Saved configuration successfully")
        else:
            flash("There was an error saving your provider config")
        return redirect(url_for(".index"))
Beispiel #17
0
def save():
    status = 1
    try:
        feed = "rss_{0}".format(request.values['feed'])
        if not config.has_section(feed):
            raise KeyError()
    except KeyError:
        msg = "Invalid feed name"
    else:
        try:
            config.set(feed, "url", request.values['url'])
            config.set(feed, "interval", request.values['interval'])
            config.set(feed, "enabled", request.values['enabled'])
            msg = "RSS Feed saved successfully: {0}".format(request.values['feed'])
            status = 0
        except KeyError:
            msg = "Failed to save config. Malformed request: {0}".format(feed)
    return dumps({'msg': msg, 'status': status})
Beispiel #18
0
def save():
    """ Save the new config values of an existing feed over XHR

    :return: Save status response
    :rtype: dict
    """
    status = api.STATUS_FAIL

    feed = "rss_{0}".format(request.values['feed'])
    if not config.has_section(feed):
        msg = "Invalid feed name"
    else:
        try:
            config.set(feed, "url", request.values['url'])
            config.set(feed, "interval", request.values['interval'])
            config.set(feed, "enabled", request.values['enabled'])
            config.save()
            msg = "RSS Feed saved successfully: {0}".format(request.values['feed'])
            status = api.STATUS_OK
        except KeyError:
            msg = "Failed to save config. Malformed request: {0}".format(feed)
    return dict(msg=msg, status=status)
Beispiel #19
0
def save():
    """ Save the new config values of an existing feed over XHR

    :return: Save status response
    :rtype: dict
    """
    status = api.STATUS_FAIL

    feed = "rss_{0}".format(request.values['feed'])
    if not config.has_section(feed):
        msg = "Invalid feed name"
    else:
        try:
            config.set(feed, "url", request.values['url'])
            config.set(feed, "interval", request.values['interval'])
            config.set(feed, "enabled", request.values['enabled'])
            config.save()
            msg = "RSS Feed saved successfully: {0}".format(request.values['feed'])
            status = api.STATUS_OK
        except KeyError:
            msg = "Failed to save config. Malformed request: {0}".format(feed)
    return dict(msg=msg, status=status)
Beispiel #20
0
    def test_valid_year(self):
        release_info = parser.ReleaseInfo.from_internal_parser(
            "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC",
            **{'title': 'teen.wolf', 'year': 1985, 'media_type': constants.MEDIA_MOVIE}
        )
        section_name = "section_movie"
        config.set(section_name, "year_min", 1985)
        self.assertTrue(parser.valid_year(release_info, section_name=section_name))

        config.set(section_name, "year_min", 1986)
        self.assertFalse(parser.valid_year(release_info, section_name=section_name))

        config.set(section_name, "year_min", 1965)
        config.set(section_name, "year_max", 1985)
        self.assertTrue(parser.valid_year(release_info, section_name=section_name))

        config.set(section_name, "year_max", 1984)
        self.assertFalse(parser.valid_year(release_info, section_name=section_name))

        release_info_2 = parser.ReleaseInfo.from_internal_parser(
            "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC",
            **{'title': 'teen.wolf', 'media_type': constants.MEDIA_MOVIE}
        )
        config.set(section_name, "year_min", date.today().year)
        config.set(section_name, "year_max", 0)
        self.assertTrue(parser.valid_year(release_info_2, section_name=section_name))

        config.set(section_name, "year_min", date.today().year+1)
        self.assertFalse(parser.valid_year(release_info_2, section_name=section_name))

        self.assertFalse(parser.valid_year(release_info_2, section_name=section_name, none_is_cur_year=False))
Beispiel #21
0
    def test_valid_year(self):
        release_info = parser.ReleaseInfo.from_internal_parser(
            "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC",
            **{'title': 'teen.wolf', 'year': 1985, 'media_type': constants.MEDIA_MOVIE}
        )
        section_name = "section_movie"
        config.set(section_name, "year_min", 1985)
        self.assertTrue(parser.valid_year(release_info, section_name=section_name))

        config.set(section_name, "year_min", 1986)
        self.assertFalse(parser.valid_year(release_info, section_name=section_name))

        config.set(section_name, "year_min", 1965)
        config.set(section_name, "year_max", 1985)
        self.assertTrue(parser.valid_year(release_info, section_name=section_name))

        config.set(section_name, "year_max", 1984)
        self.assertFalse(parser.valid_year(release_info, section_name=section_name))

        release_info_2 = parser.ReleaseInfo.from_internal_parser(
            "Teen.Wolf.1985.720P.BRRIP.XVID.AC3-MAJESTiC",
            **{'title': 'teen.wolf', 'media_type': constants.MEDIA_MOVIE}
        )
        config.set(section_name, "year_min", date.today().year)
        config.set(section_name, "year_max", 0)
        self.assertTrue(parser.valid_year(release_info_2, section_name=section_name))

        config.set(section_name, "year_min", date.today().year+1)
        self.assertFalse(parser.valid_year(release_info_2, section_name=section_name))

        self.assertFalse(parser.valid_year(release_info_2, section_name=section_name, none_is_cur_year=False))