def magnetToStream(self, magnet, args, pack_select): if 'episodeInfo' not in args: return self.movieMagnetToStream(magnet, args) episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args) showInfo = args['showInfo']['info'] try: folder_details = self.direct_download(magnet)['content'] if pack_select is not False and pack_select is not None: streamLink = self.user_select(folder_details) return streamLink streamLink = self.check_episode_string(folder_details, episodeStrings) except: import traceback traceback.print_exc() return return streamLink
def magnetToStream(self, magnet, args, pack_select): if 'episodeInfo' not in args: return self.movieMagnetToStream(magnet, args) episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args) try: folder_details = self.direct_download(magnet)['content'] if pack_select is not False and pack_select is not None: streamLink = self.user_select(folder_details) return streamLink streamLink = self.check_episode_string(folder_details, episodeStrings) except: import traceback traceback.print_exc() return try: if streamLink is not None and tools.getSetting( 'premiumize.addToCloud') == 'true': transfer = self.create_transfer(magnet) database.add_premiumize_transfer(transfer['id']) except: pass return streamLink
def realdebridWorker(self, torrent_list, info): try: cache_list = [] hash_list = [i['hash'] for i in torrent_list] if len(hash_list) == 0: return realDebridCache = real_debrid.RealDebrid().checkHash(hash_list) for i in torrent_list: try: if 'rd' in realDebridCache[i['hash']] and len( realDebridCache[i['hash']]['rd']) >= 1: if 'episodeInfo' in info: episodeStrings, seasonStrings = source_utils.torrentCacheStrings( info) for storage_variant in realDebridCache[ i['hash']]['rd']: if len(storage_variant) > 1: continue else: key = list(storage_variant.keys())[0] filename = storage_variant[key]['filename'] if any( source_utils.cleanTitle( episodeString) in source_utils.cleanTitle(filename) for episodeString in episodeStrings): if any(filename.lower().endswith( extension) for extension in source_utils. COMMON_VIDEO_EXTENSIONS): cache_list.append(i) cache_list[-1][ 'debrid_provider'] = 'real_debrid' break else: if len(realDebridCache[i['hash']]['rd']) == 1: i['debrid_provider'] = 'real_debrid' cache_list.append(i) except: pass self.realdebridCached = cache_list except: import traceback traceback.print_exc()
def resolve_magnet(self, magnet, args, torrent, pack_select=False): if 'showInfo' not in args: return self.movie_magnet_to_stream(magnet, args) magnet_id = self.upload_magnet(magnet) magnet_id = magnet_id['id'] episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args) try: folder_details = self.magnet_status(magnet_id) if folder_details['status'] != 'Ready': return folder_details = [{ 'link': key, 'filename': value } for key, value in folder_details['links'].items()] if 'extra' not in args['info']['title'] and 'extra' not in args['showInfo']['info']['tvshowtitle'] \ and int(args['info']['season']) != 0: folder_details = [ i for i in folder_details if 'extra' not in source_utils.cleanTitle( i['filename'].replace('&', ' ').lower()) ] if 'special' not in args['info']['title'] and 'special' not in args['showInfo']['info']['tvshowtitle'] \ and int(args['info']['season']) != 0: folder_details = [ i for i in folder_details if 'special' not in source_utils.cleanTitle( i['filename'].replace('&', ' ').lower()) ] streamLink = self.check_episode_string(folder_details, episodeStrings) if streamLink is None: return self.delete_magnet(magnet_id) return self.resolve_hoster(streamLink) except: import traceback traceback.print_exc() pass
def magnetToLink(self, torrent, args): try: if torrent['package'] == 'single': return self.singleMagnetToLink(torrent['magnet']) hash = str( re.findall(r'btih:(.*?)&', torrent['magnet'])[0].lower()) hashCheck = self.checkHash(hash) torrent = self.addMagnet(torrent['magnet']) episodeStrings, seasonStrings = source_utils.torrentCacheStrings( args) file_key = None for storage_variant in hashCheck[hash]['rd']: if len(storage_variant) > 1: continue else: key = list(storage_variant.keys())[0] filename = storage_variant[key]['filename'] if any( source_utils.cleanTitle(episodeString) in source_utils.cleanTitle(filename) for episodeString in episodeStrings): if any(filename.lower().endswith(extension) for extension in source_utils.COMMON_VIDEO_EXTENSIONS): file_key = key break if file_key == None: self.deleteTorrent(torrent['id']) return None self.torrentSelect(torrent['id'], file_key) link = self.torrentInfo(torrent['id']) link = self.unrestrict_link(link['links'][0]) 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
def resolve_magnet(self, magnet, args, torrent, pack_select): if 'showInfo' not in args: return self._single_magnet_resolve(magnet, args) episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args) try: folder_details = self.direct_download(magnet)['content'] if pack_select is not False and pack_select is not None: streamLink = self.user_select(folder_details) return streamLink if 'extra' not in args['info']['title'] and 'extra' not in args['showInfo']['info']['tvshowtitle'] \ and int(args['info']['season']) != 0: folder_details = [i for i in folder_details if 'extra' not in source_utils.cleanTitle(i['path'].split('/')[-1].replace('&', ' ').lower())] if 'special' not in args['info']['title'] and 'special' not in args['showInfo']['info']['tvshowtitle'] \ and int(args['info']['season']) != 0: folder_details = [i for i in folder_details if 'special' not in source_utils.cleanTitle(i['path'].split('/')[-1].replace('&', ' ').lower())] streamLink = self.check_episode_string(folder_details, episodeStrings) except: import traceback traceback.print_exc() return try: if streamLink is not None and tools.getSetting('premiumize.addToCloud') == 'true': transfer = self.create_transfer(magnet) database.add_premiumize_transfer(transfer['id']) except: pass return streamLink
def real_debrid_downloader(self, torrent_object, args): from resources.lib.common import source_utils tools.log('REAL DEBRID CACHE ASSIST STARTING') tools.showDialog.notification( tools.addonName, 'Cache Assist is attempting to build a torrent source') current_percent = 0 episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args) debrid = real_debrid.RealDebrid() magnet = debrid.addMagnet(torrent_object['magnet']) info = debrid.torrentInfo(magnet['id']) torrent_id = info['id'] file_key = None database.add_assist_torrent(torrent_id, 'real_debrid', 'queued', torrent_object['release_title'], str(current_percent)) for file in info['files']: filename = file['path'] key = file['id'] if any( source_utils.cleanTitle(episodeString) in source_utils.cleanTitle(filename) for episodeString in episodeStrings): if any(filename.lower().endswith(extension) for extension in source_utils.COMMON_VIDEO_EXTENSIONS): file_key = key break debrid.torrentSelect(torrent_id, file_key) downloading_status = ['queued', 'downloading'] current_percent = 0 timestamp = time.time() while not monitor.abortRequested(): if monitor.waitForAbort(120): break try: info = debrid.torrentInfo(torrent_id) if info['status'] == 'downloaded': tools.showDialog.notification( tools.addonName + ': %s' % self.title, 'New cached sources have been created for %s' % self.title, time=5000) database.add_assist_torrent( torrent_id, 'real_debrid', 'finished', torrent_object['release_title'], str(current_percent)) debrid.deleteTorrent(torrent_id) break if info['status'] in downloading_status: if info['progress'] == current_percent: if timestamp == (time.time() + 10800): database.add_assist_torrent( torrent_id, 'real_debrid', 'failed', torrent_object['release_title'], str(current_percent)) debrid.deleteTorrent(torrent_id) tools.showDialog.notification( tools.addonName, 'Cache assist for %s has failed due to no progress' % self.title) break continue else: database.add_assist_torrent( torrent_id, 'real_debrid', 'downloading', torrent_object['release_title'], str(current_percent)) current_percent = info['progress'] continue else: database.add_assist_torrent( torrent_id, 'real_debrid', 'failed', torrent_object['release_title'], str(current_percent)) debrid.deleteTorrent(torrent_id) tools.log( 'Could not create cache for magnet- %s' % torrent_object['magnet'], 'info') tools.showDialog.notification( tools.addonName, 'Cache assist for %s has failed according to Real Debrid' % self.title) break except: debrid.deleteTorrent(torrent_id)
def magnetToLink(self, torrent, args): try: if torrent['package'] == 'single': return self.singleMagnetToLink(torrent['magnet']) hash = str( re.findall(r'btih:(.*?)&', torrent['magnet'])[0].lower()) 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(): filename = storage_variant[key]['filename'] if not any( filename.endswith(extension) for extension in source_utils.COMMON_VIDEO_EXTENSIONS): bad_storage = True continue else: key_list.append(key) if any( source_utils.cleanTitle(episodeString) in source_utils.cleanTitle(filename) for episodeString in episodeStrings): file_inside = True if file_inside is False or bad_storage is True: 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]): if any( source_utils.cleanTitle(episodeString) in source_utils.cleanTitle(i['path'].split('/')[-1]) for episodeString in episodeStrings): file_index = idx if file_index is None: self.deleteTorrent(torrent['id']) return None link = link['links'][file_index] link = self.unrestrict_link(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
def magnetToStream(self, magnet, args, pack_select): if 'episodeInfo' not in args: return self.movieMagnetToStream(magnet, args) episodeStrings, seasonStrings = source_utils.torrentCacheStrings(args) showInfo = args['showInfo']['info'] showTitle = showInfo['tvshowtitle'] transfer = self.create_transfer(magnet) transfer_id = transfer['id'] database.add_premiumize_transfer(transfer_id) transfers = self.list_transfers() folder_id = None sub_folder_id = None try: for i in transfers['transfers']: if i['id'] == transfer_id: folder_id = i['folder_id'] if folder_id is None: raise Exception folder_details = self.list_folder(folder_id) if pack_select is not False and pack_select is not None: streamLink = self.user_select(folder_details, transfer_id) return streamLink streamLink = self.check_episode_string(folder_details, episodeStrings) if streamLink is None: for item in folder_details: # Check for old Usenet standards if source_utils.cleanTitle(item['name']) == source_utils.cleanTitle(showTitle): folder_details = self.list_folder(item['id']) for item in folder_details: if item['type'] != 'folder': continue for seasonStr in seasonStrings: if source_utils.cleanTitle(seasonStr)\ in source_utils.cleanTitle(item['name'].replace('&', ' ')): sub_folder_id = item['id'] if sub_folder_id is not None: folder_details = self.list_folder(sub_folder_id) if not pack_select == "True": streamLink = self.check_episode_string(folder_details, episodeStrings) else: name_list = [file['name'] for file in folder_details] selection = tools.showDialog.select(tools.addonName + ": Select Episode", name_list) streamLink = folder_details[selection]['link'] else: pass except: import traceback traceback.print_exc() self.delete_transfer(transfer_id) database.remove_premiumize_transfer(transfer_id) return if streamLink is None: self.delete_transfer(transfer_id) database.remove_premiumize_transfer(transfer_id) return streamLink
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