Esempio n. 1
0
    def search(self, media, quality):

        if self.isDisabled():
            return []

        # Login if needed
        if self.urls.get('login') and not self.login():
            log.error('Failed to login to: %s', self.getName())
            return []

        # Create result container
        imdb_results = hasattr(self, '_search')
        results = ResultList(self, media, quality, imdb_results = imdb_results)

        # Do search based on imdb id
        if imdb_results:
            self._search(media, quality, results)
        # Search possible titles
        else:
            media_title = fireEvent('library.query', media, include_year = False, single = True)

            for title in possibleTitles(media_title):
                self._searchOnTitle(title, media, quality, results)

        return results
Esempio n. 2
0
    def correctTitle(self, chain, media):
        root = fireEvent('library.root', media, single=True)

        if 'show_name' not in chain.info or not len(chain.info['show_name']):
            log.info('Wrong: missing show name in parsed result')
            return False

        # Get the lower-case parsed show name from the chain
        chain_words = [x.lower() for x in chain.info['show_name']]

        # Build a list of possible titles of the media we are searching for
        titles = root['info']['titles']

        # Add year suffix titles (will result in ['<name_one>', '<name_one> <suffix_one>', '<name_two>', ...])
        suffixes = [None, root['info']['year']]

        titles = [
            title + ((' %s' % suffix) if suffix else '') for title in titles
            for suffix in suffixes
        ]

        # Check show titles match
        # TODO check xem names
        for title in titles:
            for valid_words in [x.split(' ') for x in possibleTitles(title)]:

                if valid_words == chain_words:
                    return True

        return False
Esempio n. 3
0
    def correctTitle(self, chain, media):
        root_library = media['library']['root_library']

        if 'show_name' not in chain.info or not len(chain.info['show_name']):
            log.info('Wrong: missing show name in parsed result')
            return False

        # Get the lower-case parsed show name from the chain
        chain_words = [x.lower() for x in chain.info['show_name']]

        # Build a list of possible titles of the media we are searching for
        titles = root_library['info']['titles']

        # Add year suffix titles (will result in ['<name_one>', '<name_one> <suffix_one>', '<name_two>', ...])
        suffixes = [None, root_library['info']['year']]

        titles = [
            title + ((' %s' % suffix) if suffix else '')
            for title in titles
            for suffix in suffixes
        ]

        # Check show titles match
        # TODO check xem names
        for title in titles:
            for valid_words in [x.split(' ') for x in possibleTitles(title)]:

                if valid_words == chain_words:
                    return True

        return False
Esempio n. 4
0
    def search(self, media, quality):

        if self.isDisabled():
            return []

        # Login if needed
        if self.urls.get('login') and not self.login():
            log.error('Failed to login to: %s', self.getName())
            return []

        # Create result container
        imdb_results = hasattr(self, '_search')
        results = ResultList(self, media, quality, imdb_results=imdb_results)

        # Do search based on imdb id
        if imdb_results:
            self._search(media, quality, results)
        # Search possible titles
        else:
            media_title = fireEvent('library.query',
                                    media,
                                    include_year=False,
                                    single=True)

            for title in possibleTitles(media_title):
                self._searchOnTitle(title, media, quality, results)

        return results
Esempio n. 5
0
File: main.py Progetto: Arcylus/PBI
    def search(self, movie, quality):

        if self.isDisabled():
            return []

        results = []
        for title in possibleTitles(getTitle(movie['library'])):
            results.extend(self._search(title, movie, quality))

        return self.removeDuplicateResults(results)
Esempio n. 6
0
    def search(self, movie, quality):

        if self.isDisabled():
            return []

        results = []
        for title in possibleTitles(getTitle(movie['library'])):
            results.extend(self._search(title, movie, quality))

        return self.removeDuplicateResults(results)
Esempio n. 7
0
    def search(self, movie, quality):

        pre_releases = fireEvent("quality.pre_releases", single=True)
        if self.isDisabled() or quality["identifier"] in pre_releases:
            return []

        results = []
        for title in possibleTitles(getTitle(movie["library"])):
            results.extend(self._search(title, movie, quality))

        return self.removeDuplicateResults(results)
Esempio n. 8
0
    def search(self, movie, quality):

        pre_releases = fireEvent('quality.pre_releases', single=True)
        if self.isDisabled() or quality['identifier'] in pre_releases:
            return []

        results = []
        for title in possibleTitles(getTitle(movie['library'])):
            results.extend(self._search(title, movie, quality))

        return self.removeDuplicateResults(results)
    def _search(self, movie, quality, results):

		  # Cookie login
        #if not self.last_login_check and not self.login():
        #    pass
        #    return

        TitleStringReal = (getTitle(movie['info']) + ' ' + simplifyString(quality['identifier'] )).replace('-',' ').replace(' ',' ').replace(' ',' ').replace(' ',' ').encode("utf8")
        self._searchOnTitle(TitleStringReal, movie, quality, results)

        if not results:
            media_title = fireEvent('library.query', movie, include_year = False, single = True)

            for title in possibleTitles(media_title):
                self._searchOnTitle(title, movie, quality, results)
    def _search(self, movie, quality, results):

		  # Cookie login
        #if not self.last_login_check and not self.login():
        #    pass
        #    return

        TitleStringReal = (getTitle(movie['info']) + ' ' + simplifyString(quality['identifier'] )).replace('-',' ').replace(' ',' ').replace(' ',' ').replace(' ',' ').encode("utf8")
        self._searchOnTitle(TitleStringReal, movie, quality, results)

        if not results:
            media_title = fireEvent('library.query', movie, include_year = False, single = True)

            for title in possibleTitles(media_title):
                self._searchOnTitle(title, movie, quality, results)
Esempio n. 11
0
    def search(self, movie, quality):

        if self.isDisabled():
            return []

        # Login if needed
        if self.urls.get('login') and (not self.login_opener and not self.login()):
            log.error('Failed to login to: %s', self.getName())
            return []

        # Create result container
        imdb_results = hasattr(self, '_search')
        results = ResultList(self, movie, quality, imdb_results = imdb_results)

        # Do search based on imdb id
        if imdb_results:
            self._search(movie, quality, results)
        # Search possible titles
        else:
            for title in possibleTitles(getTitle(movie['library'])):
                self._searchOnTitle(title, movie, quality, results)

        return results
Esempio n. 12
0
    def search(self, movie, quality):

        if self.isDisabled():
            return []

        # Login if needed
        if self.urls.get('login') and not self.login():
            log.error('Failed to login to: %s', self.getName())
            return []

        # Create result container
        imdb_results = hasattr(self, '_search')
        results = ResultList(self, movie, quality, imdb_results=imdb_results)

        # Do search based on imdb id
        if imdb_results:
            self._search(movie, quality, results)
        # Search possible titles
        else:
            for title in possibleTitles(getTitle(movie['library'])):
                self._searchOnTitle(title, movie, quality, results)

        return results
Esempio n. 13
0
    def correctRelease(self, nzb = None, media = None, quality = None, **kwargs):

        if media.get('type') != 'movie': return

        media_title = fireEvent('searcher.get_search_title', media, single = True)

        imdb_results = kwargs.get('imdb_results', False)
        retention = Env.setting('retention', section = 'nzb')

        if nzb.get('seeders') is None and 0 < retention < nzb.get('age', 0):
            log.info2('Wrong: Outside retention, age is %s, needs %s or lower: %s', (nzb['age'], retention, nzb['name']))
            return False

        # Check for required and ignored words
        if not fireEvent('searcher.correct_words', nzb['name'], media, single = True):
            return False

        preferred_quality = quality if quality else fireEvent('quality.single', identifier = quality['identifier'], single = True)

        # Contains lower quality string
        contains_other = fireEvent('searcher.contains_other_quality', nzb, movie_year = media['info']['year'], preferred_quality = preferred_quality, single = True)
        if contains_other and isinstance(contains_other, dict):
            log.info2('Wrong: %s, looking for %s, found %s', (nzb['name'], quality['label'], [x for x in contains_other] if contains_other else 'no quality'))
            return False

        # Contains lower quality string
        if not fireEvent('searcher.correct_3d', nzb, preferred_quality = preferred_quality, single = True):
            log.info2('Wrong: %s, %slooking for %s in 3D', (nzb['name'], ('' if preferred_quality['custom'].get('3d') else 'NOT '), quality['label']))
            return False

        # File to small
        if nzb['size'] and tryInt(preferred_quality['size_min']) > tryInt(nzb['size']):
            log.info2('Wrong: "%s" is too small to be %s. %sMB instead of the minimal of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_min']))
            return False

        # File to large
        if nzb['size'] and tryInt(preferred_quality['size_max']) < tryInt(nzb['size']):
            log.info2('Wrong: "%s" is too large to be %s. %sMB instead of the maximum of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_max']))
            return False

        # Provider specific functions
        get_more = nzb.get('get_more_info')
        if get_more:
            get_more(nzb)

        extra_check = nzb.get('extra_check')
        if extra_check and not extra_check(nzb):
            return False


        if imdb_results:
            return True

        # Check if nzb contains imdb link
        if getImdb(nzb.get('description', '')) == getIdentifier(media):
            return True

        for raw_title in media['info']['titles']:
            for movie_title in possibleTitles(raw_title):
                movie_words = re.split('\W+', simplifyString(movie_title))

                if fireEvent('searcher.correct_name', nzb['name'], movie_title, single = True):
                    # if no IMDB link, at least check year range 1
                    if len(movie_words) > 2 and fireEvent('searcher.correct_year', nzb['name'], media['info']['year'], 1, single = True):
                        return True

                    # if no IMDB link, at least check year
                    if len(movie_words) <= 2 and fireEvent('searcher.correct_year', nzb['name'], media['info']['year'], 0, single = True):
                        return True

        log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'", (nzb['name'], media_title, media['info']['year']))
        return False
Esempio n. 14
0
    def correctRelease(self, nzb=None, media=None, quality=None, **kwargs):

        if media.get('type') != 'movie': return

        media_title = fireEvent('searcher.get_search_title',
                                media,
                                single=True)

        imdb_results = kwargs.get('imdb_results', False)
        retention = Env.setting('retention', section='nzb')

        if nzb.get('seeders') is None and 0 < retention < nzb.get('age', 0):
            log.info2(
                'Wrong: Outside retention, age is %s, needs %s or lower: %s',
                (nzb['age'], retention, nzb['name']))
            return False

        # Check for required and ignored words
        if not fireEvent(
                'searcher.correct_words', nzb['name'], media, single=True):
            return False

        preferred_quality = quality if quality else fireEvent(
            'quality.single', identifier=quality['identifier'], single=True)

        # Contains lower quality string
        contains_other = fireEvent('searcher.contains_other_quality',
                                   nzb,
                                   movie_year=media['info']['year'],
                                   preferred_quality=preferred_quality,
                                   single=True)
        if contains_other != False:
            log.info2(
                'Wrong: %s, looking for %s, found %s',
                (nzb['name'], quality['label'], [x for x in contains_other]
                 if contains_other else 'no quality'))
            return False

        # Contains lower quality string
        if not fireEvent('searcher.correct_3d',
                         nzb,
                         preferred_quality=preferred_quality,
                         single=True):
            log.info2(
                'Wrong: %s, %slooking for %s in 3D',
                (nzb['name'],
                 ('' if preferred_quality['custom'].get('3d') else 'NOT '),
                 quality['label']))
            return False

        # File to small
        if nzb['size'] and tryInt(preferred_quality['size_min']) > tryInt(
                nzb['size']):
            log.info2(
                'Wrong: "%s" is too small to be %s. %sMB instead of the minimal of %sMB.',
                (nzb['name'], preferred_quality['label'], nzb['size'],
                 preferred_quality['size_min']))
            return False

        # File to large
        if nzb['size'] and tryInt(preferred_quality['size_max']) < tryInt(
                nzb['size']):
            log.info2(
                'Wrong: "%s" is too large to be %s. %sMB instead of the maximum of %sMB.',
                (nzb['name'], preferred_quality['label'], nzb['size'],
                 preferred_quality['size_max']))
            return False

        # Provider specific functions
        get_more = nzb.get('get_more_info')
        if get_more:
            get_more(nzb)

        extra_check = nzb.get('extra_check')
        if extra_check and not extra_check(nzb):
            return False

        if imdb_results:
            return True

        # Check if nzb contains imdb link
        if getImdb(nzb.get('description', '')) == getIdentifier(media):
            return True

        for raw_title in media['info']['titles']:
            for movie_title in possibleTitles(raw_title):
                movie_words = re.split('\W+', simplifyString(movie_title))

                if fireEvent('searcher.correct_name',
                             nzb['name'],
                             movie_title,
                             single=True):
                    # if no IMDB link, at least check year range 1
                    if len(movie_words) > 2 and fireEvent(
                            'searcher.correct_year',
                            nzb['name'],
                            media['info']['year'],
                            1,
                            single=True):
                        return True

                    # if no IMDB link, at least check year
                    if len(movie_words) <= 2 and fireEvent(
                            'searcher.correct_year',
                            nzb['name'],
                            media['info']['year'],
                            0,
                            single=True):
                        return True

        log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'",
                 (nzb['name'], media_title, media['info']['year']))
        return False
Esempio n. 15
0
    def correctMovie(self, nzb = None, movie = None, quality = None, **kwargs):

        imdb_results = kwargs.get('imdb_results', False)
        retention = Env.setting('retention', section = 'nzb')

        if nzb.get('seeders') is None and 0 < retention < nzb.get('age', 0):
            log.info2('Wrong: Outside retention, age is %s, needs %s or lower: %s', (nzb['age'], retention, nzb['name']))
            return False

        movie_name = getTitle(movie['library'])
        movie_words = re.split('\W+', simplifyString(movie_name))
        nzb_name = simplifyString(nzb['name'])
        nzb_words = re.split('\W+', nzb_name)

        # Make sure it has required words
        required_words = splitString(self.conf('required_words').lower())
        req_match = 0
        for req_set in required_words:
            req = splitString(req_set, '&')
            req_match += len(list(set(nzb_words) & set(req))) == len(req)

        if self.conf('required_words') and req_match == 0:
            log.info2('Wrong: Required word missing: %s', nzb['name'])
            return False

        # Ignore releases
        ignored_words = splitString(self.conf('ignored_words').lower())
        ignored_match = 0
        for ignored_set in ignored_words:
            ignored = splitString(ignored_set, '&')
            ignored_match += len(list(set(nzb_words) & set(ignored))) == len(ignored)

        if self.conf('ignored_words') and ignored_match:
            log.info2("Wrong: '%s' contains 'ignored words'", (nzb['name']))
            return False

        # Ignore p**n stuff
        pron_tags = ['xxx', 'sex', 'anal', 't**s', 'f**k', 'p**n', 'orgy', 'milf', 'boobs', 'erotica', 'erotic']
        pron_words = list(set(nzb_words) & set(pron_tags) - set(movie_words))
        if pron_words:
            log.info('Wrong: %s, probably pr0n', (nzb['name']))
            return False

        preferred_quality = fireEvent('quality.single', identifier = quality['identifier'], single = True)

        # Contains lower quality string
        if self.containsOtherQuality(nzb, movie_year = movie['library']['year'], preferred_quality = preferred_quality):
            log.info2('Wrong: %s, looking for %s', (nzb['name'], quality['label']))
            return False


        # File to small
        if nzb['size'] and preferred_quality['size_min'] > nzb['size']:
            log.info2('Wrong: "%s" is too small to be %s. %sMB instead of the minimal of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_min']))
            return False

        # File to large
        if nzb['size'] and preferred_quality.get('size_max') < nzb['size']:
            log.info2('Wrong: "%s" is too large to be %s. %sMB instead of the maximum of %sMB.', (nzb['name'], preferred_quality['label'], nzb['size'], preferred_quality['size_max']))
            return False


        # Provider specific functions
        get_more = nzb.get('get_more_info')
        if get_more:
            get_more(nzb)

        extra_check = nzb.get('extra_check')
        if extra_check and not extra_check(nzb):
            return False


        if imdb_results:
            return True

        # Check if nzb contains imdb link
        if self.checkIMDB([nzb.get('description', '')], movie['library']['identifier']):
            return True

        for raw_title in movie['library']['titles']:
            for movie_title in possibleTitles(raw_title['title']):
                movie_words = re.split('\W+', simplifyString(movie_title))

                if self.correctName(nzb['name'], movie_title):
                    # if no IMDB link, at least check year range 1
                    if len(movie_words) > 2 and self.correctYear([nzb['name']], movie['library']['year'], 1):
                        return True

                    # if no IMDB link, at least check year
                    if len(movie_words) <= 2 and self.correctYear([nzb['name']], movie['library']['year'], 0):
                        return True

        log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'", (nzb['name'], movie_name, movie['library']['year']))
        return False
Esempio n. 16
0
    def correctMovie(self, nzb={}, movie={}, quality={}, **kwargs):

        imdb_results = kwargs.get('imdb_results', False)
        retention = Env.setting('retention', section='nzb')

        if nzb.get('seeders') is None and 0 < retention < nzb.get('age', 0):
            log.info2(
                'Wrong: Outside retention, age is %s, needs %s or lower: %s',
                (nzb['age'], retention, nzb['name']))
            return False

        movie_name = getTitle(movie['library'])
        movie_words = re.split('\W+', simplifyString(movie_name))
        nzb_name = simplifyString(nzb['name'])
        nzb_words = re.split('\W+', nzb_name)
        required_words = splitString(self.conf('required_words').lower())

        req_match = 0
        for req_set in required_words:
            req = splitString(req_set, '&')
            req_match += len(list(set(nzb_words) & set(req))) == len(req)

        if self.conf('required_words') and req_match == 0:
            log.info2("Wrong: Required word missing: %s" % nzb['name'])
            return False

        ignored_words = splitString(self.conf('ignored_words').lower())
        blacklisted = list(
            set(nzb_words) & set(ignored_words) - set(movie_words))
        if self.conf('ignored_words') and blacklisted:
            log.info2("Wrong: '%s' blacklisted words: %s" %
                      (nzb['name'], ", ".join(blacklisted)))
            return False

        pron_tags = [
            'xxx', 'sex', 'anal', 't**s', 'f**k', 'p**n', 'orgy', 'milf',
            'boobs', 'erotica', 'erotic'
        ]
        pron_words = list(set(nzb_words) & set(pron_tags) - set(movie_words))
        if pron_words:
            log.info('Wrong: %s, probably pr0n', (nzb['name']))
            return False

        #qualities = fireEvent('quality.all', single = True)
        preferred_quality = fireEvent('quality.single',
                                      identifier=quality['identifier'],
                                      single=True)

        # Contains lower quality string
        if self.containsOtherQuality(nzb,
                                     movie_year=movie['library']['year'],
                                     preferred_quality=preferred_quality):
            log.info2('Wrong: %s, looking for %s',
                      (nzb['name'], quality['label']))
            return False

        # File to small
        if nzb['size'] and preferred_quality['size_min'] > nzb['size']:
            log.info2(
                'Wrong: "%s" is too small to be %s. %sMB instead of the minimal of %sMB.',
                (nzb['name'], preferred_quality['label'], nzb['size'],
                 preferred_quality['size_min']))
            return False

        # File to large
        if nzb['size'] and preferred_quality.get('size_max') < nzb['size']:
            log.info2(
                'Wrong: "%s" is too large to be %s. %sMB instead of the maximum of %sMB.',
                (nzb['name'], preferred_quality['label'], nzb['size'],
                 preferred_quality['size_max']))
            return False

        # Provider specific functions
        get_more = nzb.get('get_more_info')
        if get_more:
            get_more(nzb)

        extra_check = nzb.get('extra_check')
        if extra_check and not extra_check(nzb):
            return False

        if imdb_results:
            return True

        # Check if nzb contains imdb link
        if self.checkIMDB([nzb.get('description', '')],
                          movie['library']['identifier']):
            return True

        for raw_title in movie['library']['titles']:
            for movie_title in possibleTitles(raw_title['title']):
                movie_words = re.split('\W+', simplifyString(movie_title))

                if self.correctName(nzb['name'], movie_title):
                    # if no IMDB link, at least check year range 1
                    if len(movie_words) > 2 and self.correctYear(
                        [nzb['name']], movie['library']['year'], 1):
                        return True

                    # if no IMDB link, at least check year
                    if len(movie_words) <= 2 and self.correctYear(
                        [nzb['name']], movie['library']['year'], 0):
                        return True

        log.info("Wrong: %s, undetermined naming. Looking for '%s (%s)'" %
                 (nzb['name'], movie_name, movie['library']['year']))
        return False
Esempio n. 17
0
    def _search(self, movie, quality, results):
        # Cookie login
        if not self.last_login_check and not self.login():
            return
        searchStrings = self.getSearchParams(movie, quality)
        lastsearch = 0
        searcher = Searcher()

        for searchString in searchStrings:
            actualtime = int(time.time())
            if actualtime - lastsearch < 10:
                timetosleep = 10 - (actualtime - lastsearch)
                time.sleep(timetosleep)
            URL = self.urls['search'] + searchString

            r = self.opener.open(URL)
            soup = BeautifulSoup(r, "html.parser")
            if soup.find('table', attrs={'class': 'results'}):
                resultdiv = soup.find('table', attrs={
                    'class': 'results'
                }).find('tbody')
            else:
                continue
            if resultdiv:
                try:
                    for result in resultdiv.findAll('tr'):
                        try:
                            categorie = result.findAll('td')[0].findAll('a')[
                                0]['href'][result.findAll('td')[0].
                                           findAll('a')[0]['href'].find('='):]
                            insert = 0

                            if categorie == '=631':
                                insert = 1
                            if categorie == '=455':
                                insert = 1
                            if categorie == '=634':
                                insert = 1

                            if insert == 1:

                                new = {}

                                idt = result.findAll('td')[2].findAll(
                                    'a')[0]['href'][1:].replace(
                                        'torrents/nfo/?id=', '')
                                name = result.findAll('td')[1].findAll(
                                    'a')[0]['title']
                                testname = searcher.correctName(
                                    name, movie['title'])
                                if not testname:
                                    continue
                                url = (self.urls['download'] % idt)
                                detail_url = (self.urls['detail'] % idt)
                                leecher = result.findAll('td')[8].text
                                size = result.findAll('td')[5].text
                                age = result.findAll('td')[4].text
                                seeder = result.findAll('td')[7].text

                                def extra_check(item):
                                    return True

                                new['id'] = idt
                                new['name'] = name + ' french'
                                new['url'] = url
                                new['detail_url'] = detail_url
                                new['size'] = self.parseSize(str(size))
                                new['age'] = self.ageToDays(str(age))
                                new['seeders'] = tryInt(seeder)
                                new['leechers'] = tryInt(leecher)
                                new['extra_check'] = extra_check
                                new['download'] = self.download

                                log.debug("url='%s'" % str(url))
                                results.append(new)

                        except:
                            log.error('Failed parsing T411: %s',
                                      traceback.format_exc())

                except AttributeError:
                    log.debug('No search results found.')
            else:
                log.debug('No search results found.')
        if not results:
            media_title = fireEvent('library.query',
                                    movie,
                                    include_year=False,
                                    single=True)

            for title in possibleTitles(media_title):
                self._searchOnTitle(title, movie, quality, results)
Esempio n. 18
0
    def correctRelease(self, nzb=None, media=None, quality=None, **kwargs):

        if media.get("type") != "movie":
            return

        media_title = fireEvent("searcher.get_search_title", media, single=True)

        imdb_results = kwargs.get("imdb_results", False)
        retention = Env.setting("retention", section="nzb")

        if nzb.get("seeders") is None and 0 < retention < nzb.get("age", 0):
            log.info2(
                "Wrong: Outside retention, age is %s, needs %s or lower: %s", (nzb["age"], retention, nzb["name"])
            )
            return False

        # Check for required and ignored words
        if not fireEvent("searcher.correct_words", nzb["name"], media, single=True):
            return False

        preferred_quality = (
            quality if quality else fireEvent("quality.single", identifier=quality["identifier"], single=True)
        )

        # Contains lower quality string
        contains_other = fireEvent(
            "searcher.contains_other_quality",
            nzb,
            movie_year=media["info"]["year"],
            preferred_quality=preferred_quality,
            single=True,
        )
        if contains_other != False:
            log.info2(
                "Wrong: %s, looking for %s, found %s",
                (nzb["name"], quality["label"], [x for x in contains_other] if contains_other else "no quality"),
            )
            return False

        # Contains lower quality string
        if not fireEvent("searcher.correct_3d", nzb, preferred_quality=preferred_quality, single=True):
            log.info2(
                "Wrong: %s, %slooking for %s in 3D",
                (nzb["name"], ("" if preferred_quality["custom"].get("3d") else "NOT "), quality["label"]),
            )
            return False

        # File to small
        if nzb["size"] and tryInt(preferred_quality["size_min"]) > tryInt(nzb["size"]):
            log.info2(
                'Wrong: "%s" is too small to be %s. %sMB instead of the minimal of %sMB.',
                (nzb["name"], preferred_quality["label"], nzb["size"], preferred_quality["size_min"]),
            )
            return False

        # File to large
        if nzb["size"] and tryInt(preferred_quality["size_max"]) < tryInt(nzb["size"]):
            log.info2(
                'Wrong: "%s" is too large to be %s. %sMB instead of the maximum of %sMB.',
                (nzb["name"], preferred_quality["label"], nzb["size"], preferred_quality["size_max"]),
            )
            return False

        # Provider specific functions
        get_more = nzb.get("get_more_info")
        if get_more:
            get_more(nzb)

        extra_check = nzb.get("extra_check")
        if extra_check and not extra_check(nzb):
            return False

        if imdb_results:
            return True

        # Check if nzb contains imdb link
        if getImdb(nzb.get("description", "")) == getIdentifier(media):
            return True

        for raw_title in media["info"]["titles"]:
            for movie_title in possibleTitles(raw_title):
                movie_words = re.split("\W+", simplifyString(movie_title))

                if fireEvent("searcher.correct_name", nzb["name"], movie_title, single=True):
                    # if no IMDB link, at least check year range 1
                    if len(movie_words) > 2 and fireEvent(
                        "searcher.correct_year", nzb["name"], media["info"]["year"], 1, single=True
                    ):
                        return True

                    # if no IMDB link, at least check year
                    if len(movie_words) <= 2 and fireEvent(
                        "searcher.correct_year", nzb["name"], media["info"]["year"], 0, single=True
                    ):
                        return True

        log.info(
            "Wrong: %s, undetermined naming. Looking for '%s (%s)'", (nzb["name"], media_title, media["info"]["year"])
        )
        return False
Esempio n. 19
0
    def correctMovie(self, nzb=None, movie=None, quality=None, **kwargs):

        imdb_results = kwargs.get("imdb_results", False)
        retention = Env.setting("retention", section="nzb")

        if nzb.get("seeders") is None and 0 < retention < nzb.get("age", 0):
            log.info2(
                "Wrong: Outside retention, age is %s, needs %s or lower: %s", (nzb["age"], retention, nzb["name"])
            )
            return False

        movie_name = getTitle(movie["library"])
        movie_words = re.split("\W+", simplifyString(movie_name))
        nzb_name = simplifyString(nzb["name"])
        nzb_words = re.split("\W+", nzb_name)

        # Make sure it has required words
        required_words = splitString(self.conf("required_words", section="searcher").lower())
        try:
            required_words = list(set(required_words + splitString(movie["category"]["required"].lower())))
        except:
            pass

        req_match = 0
        for req_set in required_words:
            req = splitString(req_set, "&")
            req_match += len(list(set(nzb_words) & set(req))) == len(req)

        if len(required_words) > 0 and req_match == 0:
            log.info2("Wrong: Required word missing: %s", nzb["name"])
            return False

        # Ignore releases
        ignored_words = splitString(self.conf("ignored_words", section="searcher").lower())
        try:
            ignored_words = list(set(ignored_words + splitString(movie["category"]["ignored"].lower())))
        except:
            pass

        ignored_match = 0
        for ignored_set in ignored_words:
            ignored = splitString(ignored_set, "&")
            ignored_match += len(list(set(nzb_words) & set(ignored))) == len(ignored)

        if len(ignored_words) > 0 and ignored_match:
            log.info2("Wrong: '%s' contains 'ignored words'", (nzb["name"]))
            return False

        # Ignore p**n stuff
        pron_tags = ["xxx", "sex", "anal", "t**s", "f**k", "p**n", "orgy", "milf", "boobs", "erotica", "erotic"]
        pron_words = list(set(nzb_words) & set(pron_tags) - set(movie_words))
        if pron_words:
            log.info("Wrong: %s, probably pr0n", (nzb["name"]))
            return False

        preferred_quality = fireEvent("quality.single", identifier=quality["identifier"], single=True)

        # Contains lower quality string
        if fireEvent(
            "searcher.contains_other_quality",
            nzb,
            movie_year=movie["library"]["year"],
            preferred_quality=preferred_quality,
            single=True,
        ):
            log.info2("Wrong: %s, looking for %s", (nzb["name"], quality["label"]))
            return False

        # File to small
        if nzb["size"] and preferred_quality["size_min"] > nzb["size"]:
            log.info2(
                'Wrong: "%s" is too small to be %s. %sMB instead of the minimal of %sMB.',
                (nzb["name"], preferred_quality["label"], nzb["size"], preferred_quality["size_min"]),
            )
            return False

        # File to large
        if nzb["size"] and preferred_quality.get("size_max") < nzb["size"]:
            log.info2(
                'Wrong: "%s" is too large to be %s. %sMB instead of the maximum of %sMB.',
                (nzb["name"], preferred_quality["label"], nzb["size"], preferred_quality["size_max"]),
            )
            return False

        # Provider specific functions
        get_more = nzb.get("get_more_info")
        if get_more:
            get_more(nzb)

        extra_check = nzb.get("extra_check")
        if extra_check and not extra_check(nzb):
            return False

        if imdb_results:
            return True

        # Check if nzb contains imdb link
        if getImdb(nzb.get("description", "")) == movie["library"]["identifier"]:
            return True

        for raw_title in movie["library"]["titles"]:
            for movie_title in possibleTitles(raw_title["title"]):
                movie_words = re.split("\W+", simplifyString(movie_title))

                if fireEvent("searcher.correct_name", nzb["name"], movie_title, single=True):
                    # if no IMDB link, at least check year range 1
                    if len(movie_words) > 2 and fireEvent(
                        "searcher.correct_year", nzb["name"], movie["library"]["year"], 1, single=True
                    ):
                        return True

                    # if no IMDB link, at least check year
                    if len(movie_words) <= 2 and fireEvent(
                        "searcher.correct_year", nzb["name"], movie["library"]["year"], 0, single=True
                    ):
                        return True

        log.info(
            "Wrong: %s, undetermined naming. Looking for '%s (%s)'", (nzb["name"], movie_name, movie["library"]["year"])
        )
        return False
Esempio n. 20
0
    def _search(self, movie, quality, results):
        # Cookie login
        if not self.last_login_check and not self.login():
            return
        searchStrings= self.getSearchParams(movie,quality)
        lastsearch=0
        searcher = Searcher()

        for searchString in searchStrings:
            actualtime=int(time.time())
            if actualtime-lastsearch<10:
                timetosleep= 10-(actualtime-lastsearch)
                time.sleep(timetosleep)
            URL = self.urls['search']+searchString
                
            r = self.opener.open(URL)   
            soup = BeautifulSoup( r, "html.parser" )
            if soup.find('table', attrs = {'class':'results'}):
                resultdiv = soup.find('table', attrs = {'class':'results'}).find('tbody')
            else:
                continue
            if resultdiv:
                try:   
                    for result in resultdiv.findAll('tr'):
                        try:
                            categorie = result.findAll('td')[0].findAll('a')[0]['href'][result.findAll('td')[0].findAll('a')[0]['href'].find('='):]
                            insert = 0
                        
                            if categorie == '=631':
                                insert = 1
                            if categorie == '=455':
                                insert = 1
                            if categorie == '=634':
                                insert = 1
                         
                            if insert == 1 :
                         
                                new = {}
        
                                idt = result.findAll('td')[2].findAll('a')[0]['href'][1:].replace('torrents/nfo/?id=','')
                                name = result.findAll('td')[1].findAll('a')[0]['title']
                                testname=searcher.correctName(name,movie['title'])
                                if not testname:
                                    continue
                                url = (self.urls['download'] % idt)
                                detail_url = (self.urls['detail'] % idt)
                                leecher = result.findAll('td')[8].text
                                size = result.findAll('td')[5].text
                                age = result.findAll('td')[4].text
                                seeder = result.findAll('td')[7].text
        
                                def extra_check(item):
                                    return True
        
                                new['id'] = idt
                                new['name'] = name + ' french'
                                new['url'] = url
                                new['detail_url'] = detail_url
                                new['size'] = self.parseSize(str(size))
                                new['age'] = self.ageToDays(str(age))
                                new['seeders'] = tryInt(seeder)
                                new['leechers'] = tryInt(leecher)
                                new['extra_check'] = extra_check
                                new['download'] = self.download

                                log.debug("url='%s'"%str(url))
                                results.append(new)
    
                        except:
                            log.error('Failed parsing T411: %s', traceback.format_exc())
    
                except AttributeError:
                    log.debug('No search results found.')
            else:
                log.debug('No search results found.')
        if not results:
            media_title = fireEvent('library.query', movie, include_year = False, single = True)

            for title in possibleTitles(media_title):
                self._searchOnTitle(title, movie, quality, results)