예제 #1
0
    def _finalise_identified_items(self, items):
        for item in items:
            item.update({
                'quality':
                source_utils.get_quality(item['release_title']),
                'language':
                self.language,
                'provider':
                'Cloud',
                'type':
                'cloud',
                'info':
                source_utils.get_info(item['release_title']),
                'debrid_provider':
                self.debrid_provider,
            })

        return items
예제 #2
0
    def _process_provider_torrent(self, torrent, provider_name, info):
        torrent['type'] = 'torrent'

        if not torrent.get('info'):
            torrent['info'] = source_utils.get_info(torrent['release_title'])

        torrent['quality'] = torrent.get('quality', '')
        if torrent['quality'] not in approved_qualities:
            torrent['quality'] = source_utils.get_quality(torrent['release_title'])

        torrent['hash'] = torrent.get('hash', self.hash_regex.findall(torrent['magnet'])[0]).lower()
        torrent['size'] = torrent.get('size', 0)
        torrent['size'] = self._torrent_filesize(torrent, info)

        if 'provider_name_override' in torrent:
            torrent['provider'] = torrent['provider_name_override']
        else:
            torrent['provider'] = provider_name
예제 #3
0
    def resolve_magnet(self, magnet, args, torrent, pack_select=False):
        try:
            if torrent['package'] == 'single' or 'showInfo' not in args:
                return self._single_magnet_resolve(torrent)

            try:
                hash = str(re.findall(r'btih:(.*?)(?:&|$)', torrent['magnet'])[0].lower())
            except:
                hash = torrent['hash']

            hashCheck = self.checkHash(hash)
            torrent = self.addMagnet(torrent['magnet'])
            episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args)
            key_list = []

            for storage_variant in hashCheck[hash]['rd']:
                file_inside = False
                key_list = []
                bad_storage = False

                for key, value in storage_variant.items():
                    file_name = storage_variant[key]['filename']

                    if not any(file_name.endswith(extension) for extension in
                               source_utils.COMMON_VIDEO_EXTENSIONS):
                        bad_storage = True
                        break

                    else:
                        file_name = file_name.replace(source_utils.get_quality(file_name), '')
                        file_name = source_utils.cleanTitle(file_name)
                        key_list.append(key)
                        if any(episodeString in source_utils.cleanTitle(file_name) for
                               episodeString in episodeStrings):
                            file_inside = True

                if not file_inside or bad_storage:
                    continue
                else:
                    break

            if len(key_list) == 0:
                self.deleteTorrent(torrent['id'])
                return None

            key_list = ','.join(key_list)

            self.torrentSelect(torrent['id'], key_list)

            link = self.torrentInfo(torrent['id'])

            file_index = None

            for idx, i in enumerate([i for i in link['files'] if i['selected'] == 1]):
                file_name = i['path'].split('/')[-1]
                file_name = file_name.replace(source_utils.get_quality(file_name), '')
                file_name = source_utils.cleanTitle(file_name)

                if any(source_utils.cleanTitle(episodeString) in file_name for
                       episodeString in episodeStrings):
                        file_index = idx
                        break

            if file_index is None:
                self.deleteTorrent(torrent['id'])
                return None

            link = link['links'][file_index]
            link = self.resolve_hoster(link)

            if link.endswith('rar'):
                link = None

            if tools.getSetting('rd.autodelete') == 'true':
                self.deleteTorrent(torrent['id'])
            return link
        except:
            import traceback
            traceback.print_exc()
            self.deleteTorrent(torrent['id'])
            return None