Beispiel #1
0
    def test_01(self):
        not_match_testcases = [
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game of Thrones S01E02 Winter Is Coming 1080p 5.1',
             RELEASE_NOT_MATCH_ERROR__SEASONEPS),
            ('Burnt.2015.1080p.BluRay.6CH.1.8GB.MkvCage',
             'Max.2015.1080p.BluRay.x264-MkvCage',
             RELEASE_NOT_MATCH_ERROR__TITLE),
        ]

        for release_name1, release_name2, error_code in not_match_testcases:
            release1 = parse_release_name(release_name1)
            release2 = parse_release_name(release_name2)
            try:
                check_match_release_info(release1, release2)
                self.assertTrue(
                    False,
                    msg="Expect ReleaseNotMatchError exception will be raised")
            except ReleaseNotMatchError as e:
                self.assertEqual(error_code, e.code)
Beispiel #2
0
    def test_01(self):
        testcases = [('Bad.Boys.II.2003.1080.BluRay.X264.YIFY', {
            'year': 2003,
            'title_query': 'bad boys ii'
        })]

        for release_name, expect_result in testcases:
            ret = parse_release_name(release_name)
            # print(ret)
            for field_name in expect_result:
                self.assertTrue(field_name in ret)
                self.assertEqual(expect_result[field_name], ret[field_name])
Beispiel #3
0
    def sort(self, release_name, releases):
        raw_release_info = parse_release_name(release_name)

        release_tokens = set(raw_release_info['release_tokens'])
        for release in releases:
            release_info = parse_release_name(release['name'])
            release.update(release_info)

            # Jaccard Index - https://en.wikipedia.org/wiki/Jaccard_index
            release['d'] = float(
                len(release_tokens.intersection(
                    release['release_tokens']))) / len(
                        release_tokens.union(release['release_tokens']))

        def movie_cmp(a, b):
            if a['title_query'] != b['title_query']:
                # The on has same title query (with raw_release_info) is better
                if a['title_query'] == raw_release_info['title_query']:
                    return -1
                elif b['title_query'] == raw_release_info['title_query']:
                    return 1

            if a['d'] > b['d']:
                # larger distances is better
                return -1
            elif a['d'] < b['d']:
                return 1

            if 'year' in a and 'year' in b:
                if a['year'] > b['year']:
                    # larger year is better
                    return -1
                elif a['year'] < b['year']:
                    return 1

            return 0

        releases.sort(key=cmp_to_key(movie_cmp))
Beispiel #4
0
    def test_02(self):
        match_testcases = [
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.of.Thrones.S01E01.Winter.Is.Coming.720p.BluRay.DTS.x264-HDC'
             ),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.Of.Thrones.S01E01.Winter.Is.Coming.HDTV.XviD-FEVER.HI'),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.Of.Thrones.S01E01.Winter.Is.Coming.HDTV.XviD-FEVER'),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.Of.Thrones.S01E01.Winter.Is.Coming.720p.HDTV.x264-CTU.HI'),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.Of.Thrones.S01E01.Winter.Is.Coming.720p.HDTV.x264-CTU'),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.Of.Thrones.S01E01.Winter.Is.Coming.720p.HDTV.x264-CTU'),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.of.Thrones.S01E01.Winter.Is.Coming.1080i.HDTV.DD5.1.MPEG2-CtrlHD'
             ),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game.Of.Thrones.S01E01.Winter.Is.Coming.HDTV.XviD-FEVER'),
            ('Game of Thrones S01E01 Winter Is Coming 1080p 5.1',
             'Game Of Thrones S01E01 Winter Is Coming'),
        ]

        for release_name1, release_name2 in match_testcases:
            release1 = parse_release_name(release_name1)
            release2 = parse_release_name(release_name2)
            try:
                check_match_release_info(release1, release2)
            except Exception as e:
                print(release_name1)
                print(release_name2)
                # self.assertTrue(False,
                #                 msg="Don't expect to have exception. Receive '{0}'".format(
                #                     e.__class__.__name__,
                #                 ))
                raise e
Beispiel #5
0
    def test_01(self):
        testcases = [
            ('Blade Runner (1982) Final Cut 1080p BluRay.x264 SUJAIDR', {
                'year': 1982
            }),
        ]

        for release_name, expected in testcases:
            actual = parse_release_name(release_name)
            # pprint(actual)
            for field in expected:
                self.assertEqual(
                    expected[field], actual.get(field),
                    "Field '{0}' in {1} does not match".format(
                        field, release_name))
Beispiel #6
0
    def build_data(self):
        movie_requests = self.sub_finder.build_download_requests_for_movie_dirs(self.config['src'], force=True)

        data = []
        for release_name, movie_dir, langs in movie_requests:
            item = {
                'name': release_name,
                'src': movie_dir,
                'languages': list(langs),
                'subtitles': self.sub_finder.stat_subtitle(release_name, movie_dir)
            }

            item.update(parse_release_name(item['name']))

            data.append(item)

        self.data = sorted(data, key=lambda x: x['name'])
Beispiel #7
0
    def check(self, release_name):
        item_info = parse_release_name(release_name)

        check_match_release_info(self.info, item_info)

        return item_info
Beispiel #8
0
    def __init__(self, name):
        self.name = name

        self.info = parse_release_name(name)
Beispiel #9
0
 def _get_movie_title_from_url(movie_url):
     title_in_url = movie_url[movie_url.rfind('/'):]
     # print(title_in_url)
     info = parse_release_name(title_in_url)
     # print(info)
     return info['title_query']