Exemplo n.º 1
0
    def search(self, task, entry, config=None):
        """
        Search for name from fuzer.
        """
        self.rss_key = config['rss_key']
        self.user_id = config['user_id']

        self.cookies = {
            'fzr2lastactivity': '0',
            'fzr2lastvisit': '',
            'fzr2password': config['cookie_password'],
            'fzr2sessionhash': '',
            'fzr2userid': str(self.user_id)
        }

        category = config.get('category', [0])
        # Make sure categories is a list
        if not isinstance(category, list):
            category = [category]

        # If there are any text categories, turn them into their id number
        categories = [
            c if isinstance(c, int) else CATEGORIES[c] for c in category
        ]
        c_list = ['c{}={}'.format(quote_plus('[]'), c) for c in categories]

        entries = []
        if entry.get('imdb_id'):
            log.debug("imdb_id '%s' detected, using in search.",
                      entry['imdb_id'])
            soup = self.get_fuzer_soup(entry['imdb_id'], c_list)
            entries = self.extract_entry_from_soup(soup)
            if entries:
                for e in list(entries):
                    e['imdb_id'] = entry.get('imdb_id')
        else:
            for search_string in entry.get('search_strings', [entry['title']]):
                query = normalize_scene(search_string)
                text = quote_plus(query.encode('windows-1255'))
                soup = self.get_fuzer_soup(text, c_list)
                entries += self.extract_entry_from_soup(soup)
        return sorted(entries,
                      reverse=True,
                      key=lambda x: x.get('search_sort')) if entries else []
Exemplo n.º 2
0
    def search(self, task, entry, config=None):
        """
        Search for name from fuzer.
        """
        self.rss_key = config['rss_key']
        self.user_id = config['user_id']

        self.cookies = {
            'fzr2lastactivity': '0',
            'fzr2lastvisit': '',
            'fzr2password': config['cookie_password'],
            'fzr2sessionhash': '',
            'fzr2userid': str(self.user_id)
        }

        category = config.get('category', [0])
        # Make sure categories is a list
        if not isinstance(category, list):
            category = [category]

        # If there are any text categories, turn them into their id number
        categories = [c if isinstance(c, int) else CATEGORIES[c] for c in category]
        c_list = ['c{}={}'.format(quote_plus('[]'), c) for c in categories]

        entries = []
        if entry.get('imdb_id'):
            log.debug("imdb_id '%s' detected, using in search.", entry['imdb_id'])
            soup = self.get_fuzer_soup(entry['imdb_id'], c_list)
            entries = self.extract_entry_from_soup(soup)
            if entries:
                for e in list(entries):
                    e['imdb_id'] = entry.get('imdb_id')
        else:
            for search_string in entry.get('search_strings', [entry['title']]):
                query = normalize_scene(search_string)
                text = quote_plus(query.encode('windows-1255'))
                soup = self.get_fuzer_soup(text, c_list)
                entries += self.extract_entry_from_soup(soup)
        return sorted(entries, reverse=True, key=lambda x: x.get('search_sort')) if entries else []
Exemplo n.º 3
0
    def search(self, task, entry, config):
        """
            Search for entries on RarBG
        """

        categories = config.get('category', 'all')
        # Ensure categories a list
        if not isinstance(categories, list):
            categories = [categories]
        # Convert named category to its respective category id number
        categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]
        category_url_fragment = ';'.join(str(c) for c in categories)

        entries = set()

        params = {'mode': 'search', 'ranked': int(config['ranked']),
                  'min_seeders': config['min_seeders'], 'min_leechers': config['min_leechers'],
                  'sort': config['sorted_by'], 'category': category_url_fragment, 'format': 'json_extended',
                  'app_id': 'flexget'}

        for search_string in entry.get('search_strings', [entry['title']]):
            params.pop('search_string', None)
            params.pop('search_imdb', None)
            params.pop('search_tvdb', None)

            if entry.get('movie_name') and entry.get('imdb_id'):
                params['search_imdb'] = entry.get('imdb_id')
            else:
                query = normalize_scene(search_string)
                query_url_fragment = query.encode('utf8')
                params['search_string'] = query_url_fragment
                if config['use_tvdb']:
                    plugin.get_plugin_by_name('thetvdb_lookup').instance.lazy_series_lookup(entry, 'en')
                    params['search_tvdb'] = entry.get('tvdb_id')
                    log.debug('Using tvdb id %s', entry.get('tvdb_id'))

            response = self.get(params=params)
            if not response:
                continue

            # error code 10 and 20 just mean no results were found
            if response.get('error_code') in [10, 20]:
                searched_string = params.get('search_string') or 'imdb={0}'.format(params.get('search_imdb')) or \
                    'tvdb={0}'.format(params.get('tvdb_id'))
                log.debug('No results found for %s. Message from rarbg: %s', searched_string, response.get('error'))
                continue
            elif response.get('error'):
                log.error('Error code %s: %s', response.get('error_code'), response.get('error'))
                continue
            else:
                for result in response.get('torrent_results'):
                    e = Entry()

                    e['title'] = result.get('title')
                    e['url'] = result.get('download')
                    e['torrent_seeds'] = int(result.get('seeders'))
                    e['torrent_leeches'] = int(result.get('leechers'))
                    e['content_size'] = int(result.get('size')) / 1024 / 1024
                    episode_info = result.get('episode_info')
                    if episode_info:
                        e['imdb_id'] = episode_info.get('imdb')
                        e['tvdb_id'] = episode_info.get('tvdb')
                        e['tvrage_id'] = episode_info.get('tvrage')

                    entries.add(e)

        return entries
Exemplo n.º 4
0
    def search(self, task, entry, config):
        """Freshon.tv search plugin

        Config example:
        tv_search_freshon:
            discover:
              what:
                 - trakt_list:
                     username: xxxxxxx
                     password: xxxxxxx
                     list: somelist
                     type: shows
                  from:
                    - freshon:
                        username: xxxxxx
                        password: xxxxxx
                        passkey: xxxxx
                  interval: 1 day
                  ignore_estimations: yes

        Category is one of:
            all
            hd
            webdl

        Freeleech is one of:
            all
            free
            half
        """
        self.config = config

        if not task.requests.cookies:
            self.login(task)

        freeleech = LEECHSTATUS[config['freeleech']]

        entries = set()
        for search_string in entry.get('search_strings', [entry['title']]):
            query = normalize_scene(search_string)
            params = {
                'search': query,
                'tab': config['category'],
                'incldead': freeleech,
                'page': None
            }
            url = "%s/%s" % (BASE_URL, SEARCH_PAGE)
            log.debug('Search : %s %s', url, params)
            try:
                page = task.requests.get(url, params=params).content
            except RequestsException:
                log.error('Could not get page %s, %s, skipping', url, params)
                continue
            soup = get_soup(page)
            if soup.findAll(text=re.compile('Nothing found. Try again with '
                                            'a refined search string.')):
                log.debug('Search returned no results')
            else:
                page_number = self.get_page_number(soup)

                # pages are 0 based
                nextpage = 0
                while (nextpage < page_number):
                    if (nextpage > 0):
                        params['page'] = nextpage
                        log.debug('-----> NEXT PAGE : %s %s', url, params)
                        try:
                            f1 = task.requests.get(url, params=params).content
                        except RequestsException:
                            log.error('Could not get page %s, %s, skipping',
                                      url, params)
                            continue
                        soup = get_soup(f1)
                    results = soup.findAll(
                        'tr', {'class': re.compile('torrent_[0-9]*')})
                    for res in results:
                        entry = self.parse_entry(res)
                        if entry:
                            entries.add(entry)

                    nextpage += 1

        return entries
Exemplo n.º 5
0
    def search(self, task, entry, config):
        """
            Search for entries on RarBG
        """

        categories = config.get('category', 'all')
        # Ensure categories a list
        if not isinstance(categories, list):
            categories = [categories]
        # Convert named category to its respective category id number
        categories = [
            c if isinstance(c, int) else CATEGORIES[c] for c in categories
        ]
        category_url_fragment = ';'.join(str(c) for c in categories)

        entries = set()

        token = self.get_token()
        if not token:
            log.error('Could not retrieve token. Abandoning search.')
            return entries

        params = {
            'mode': 'search',
            'token': token,
            'ranked': int(config['ranked']),
            'min_seeders': config['min_seeders'],
            'min_leechers': config['min_leechers'],
            'sort': config['sorted_by'],
            'category': category_url_fragment,
            'format': 'json_extended',
            'app_id': 'flexget'
        }

        for search_string in entry.get('search_strings', [entry['title']]):
            params.pop('search_string', None)
            params.pop('search_imdb', None)
            params.pop('search_tvdb', None)

            if entry.get('movie_name'):
                params['search_imdb'] = entry.get('imdb_id')
            else:
                query = normalize_scene(search_string)
                query_url_fragment = query.encode('utf8')
                params['search_string'] = query_url_fragment
                if config['use_tvdb']:
                    plugin.get_plugin_by_name(
                        'thetvdb_lookup').instance.lazy_series_lookup(entry)
                    params['search_tvdb'] = entry.get('tvdb_id')
                    log.debug('Using tvdb id %s', entry.get('tvdb_id'))
            try:
                page = requests.get(self.base_url, params=params)
                log.debug('requesting: %s', page.url)
            except RequestException as e:
                log.error('RarBG request failed: %s' % e.args[0])
                continue
            r = page.json()
            # error code 20 just means no results were found
            if r.get('error_code') == 20:
                searched_string = params.get('search_string') or 'imdb={0}'.format(params.get('search_imdb')) or \
                                  'tvdb={0}'.format(params.get('tvdb_id'))
                log.debug('No results found for %s', searched_string)
                continue
            elif r.get('error'):
                log.error('Error code %s: %s', r.get('error_code'),
                          r.get('error'))
                continue
            else:
                for result in r.get('torrent_results'):
                    e = Entry()

                    e['title'] = result.get('title')
                    e['url'] = result.get('download')
                    e['torrent_seeds'] = int(result.get('seeders'))
                    e['torrent_leeches'] = int(result.get('leechers'))
                    e['content_size'] = int(result.get('size')) / 1024 / 1024
                    episode_info = result.get('episode_info')
                    if episode_info:
                        e['imdb_id'] = episode_info.get('imdb')
                        e['tvdb_id'] = episode_info.get('tvdb')
                        e['tvrage_id'] = episode_info.get('tvrage')

                    entries.add(e)

        return entries
Exemplo n.º 6
0
    def search(self, task, entry, config):
        """
            Search for entries on RarBG
        """

        categories = config.get('category', 'all')
        # Ensure categories a list
        if not isinstance(categories, list):
            categories = [categories]
        # Convert named category to its respective category id number
        categories = [c if isinstance(c, int) else CATEGORIES[c] for c in categories]
        category_url_fragment = ';'.join(str(c) for c in categories)

        entries = set()

        token = self.get_token()
        if not token:
            log.error('Could not retrieve token. Abandoning search.')
            return entries

        params = {'mode': 'search', 'token': token, 'ranked': int(config['ranked']),
                  'min_seeders': config['min_seeders'], 'min_leechers': config['min_leechers'],
                  'sort': config['sorted_by'], 'category': category_url_fragment, 'format': 'json_extended',
                  'app_id': 'flexget'}

        for search_string in entry.get('search_strings', [entry['title']]):
            params.pop('search_string', None)
            params.pop('search_imdb', None)
            params.pop('search_tvdb', None)

            if entry.get('movie_name'):
                params['search_imdb'] = entry.get('imdb_id')
            else:
                query = normalize_scene(search_string)
                query_url_fragment = query.encode('utf8')
                params['search_string'] = query_url_fragment
                if config['use_tvdb']:
                    plugin.get_plugin_by_name('thetvdb_lookup').instance.lazy_series_lookup(entry)
                    params['search_tvdb'] = entry.get('tvdb_id')
                    log.debug('Using tvdb id %s', entry.get('tvdb_id'))
            try:
                page = requests.get(self.base_url, params=params)
                log.debug('requesting: %s', page.url)
            except RequestException as e:
                log.error('RarBG request failed: %s' % e.args[0])
                continue
            r = page.json()
            # error code 20 just means no results were found
            if r.get('error_code') == 20:
                searched_string = params.get('search_string') or 'imdb={0}'.format(params.get('search_imdb')) or \
                                  'tvdb={0}'.format(params.get('tvdb_id'))
                log.debug('No results found for %s', searched_string)
                continue
            elif r.get('error'):
                log.error('Error code %s: %s', r.get('error_code'), r.get('error'))
                continue
            else:
                for result in r.get('torrent_results'):
                    e = Entry()

                    e['title'] = result.get('title')
                    e['url'] = result.get('download')
                    e['torrent_seeds'] = int(result.get('seeders'))
                    e['torrent_leeches'] = int(result.get('leechers'))
                    e['content_size'] = int(result.get('size')) / 1024 / 1024
                    episode_info = result.get('episode_info')
                    if episode_info:
                        e['imdb_id'] = episode_info.get('imdb')
                        e['tvdb_id'] = episode_info.get('tvdb')
                        e['tvrage_id'] = episode_info.get('tvrage')

                    entries.add(e)

        return entries
Exemplo n.º 7
0
    def search(self, task, entry, config):
        """
            Search for releases
        """

        entries = set()

        for search_string in entry.get('search_strings', [entry['title']]):

            try:
                params = { 'q': normalize_scene(search_string) }
                resp = task.requests.get(self.base_url + 'search', params=params)
                log.debug('Requesting: %s', resp.url)
                response = resp.json()
            except RequestException as e:
                log.error('Argenteam request failed: %s', e)
                return

            if not response:
                log.debug('Empty response from Argenteam')
                continue

            if not response.get('total'):
                log.debug('No results found for %s', search_string)
                continue

            results = response.get('results')
            if results[0]['type'] == 'tvshow':
              log.error('Argenteam type tvshow not supported yet.')
              continue

            url = '{}{}?id={}'.format(self.base_url, results[0]['type'], results[0]['id'])
            try:
                resp = task.requests.get(url)
                log.debug('Requesting releases for: %s', url)
                response = resp.json()
            except RequestException as e:
                log.error('Argenteam request failed: %s', e)
                return

            for release in response['releases']:
                for torrent in release['torrents']:
                    if config.get('force_subtitles') and release['subtitles'] or not config.get('force_subtitles'):
                        e = Entry()

                        e['title'] = ' '.join((search_string, release['source'], release['codec'], release['team'], release['tags']))
                        e['url'] = torrent['uri']

                        # Save aRGENTeaM subtitle URL for this release
                        if 'subtitles' in release:
                            e['argenteam_subtitle'] = release['subtitles'][0]['uri']
                            log.debug('Argenteam subtitle found: %s', e['argenteam_subtitle'])

                        if 'tvdb' in response:
                            e['tvdb_id'] = response['tvdb']
                        if 'info' in response and 'imdb' in response['info']:
                            e['imdb_id'] = response['info']['imdb']

                        entries.add(e)

        return entries