def movieMagnetToStream(self, magnet, args): transfer = self.create_transfer(magnet) id = transfer['id'] database.add_premiumize_transfer(id) transfers = self.list_transfers() folder_id = None try: for i in transfers['transfers']: if i['id'] == id: folder_id = i['folder_id'] if folder_id is None: raise Exception folder_details = self.list_folder(folder_id) selectedFile = folder_details[0] for file in folder_details: if file['type'] == 'file': if source_utils.filterMovieTitle(file['name'], args['title'], args['year']): if any(file['link'].endswith(ext) for ext in source_utils.COMMON_VIDEO_EXTENSIONS): selectedFile = file except: self.delete_transfer(id) return return selectedFile['link']
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 movieMagnetToStream(self, magnet, args): selectedFile = None folder_details = self.direct_download(magnet)['content'] folder_details = sorted(folder_details, key=lambda i: int(i['size']), reverse=True) folder_details = [ tfile for tfile in folder_details if any(tfile['link'].endswith(ext) for ext in source_utils.COMMON_VIDEO_EXTENSIONS) ] for torrent_file in folder_details: if source_utils.filter_movie_title( torrent_file['path'].split('/')[-1], args['title'], args['year']): selectedFile = torrent_file break if selectedFile is None: folder_details = [ tfile for tfile in folder_details if 'sample' not in tfile['path'].lower() ] folder_details = [ tfile for tfile in folder_details if source_utils.cleanTitle(args['title']) in source_utils.cleanTitle(tfile['path'].lower()) ] if len(folder_details) == 1: selectedFile = folder_details[0] else: return if tools.getSetting('premiumize.transcoded') == 'true': if selectedFile['transcode_status'] == 'finished': try: if selectedFile[ 'stream_link'] is not None and tools.getSetting( 'premiumize.addToCloud') == 'true': transfer = self.create_transfer(magnet) database.add_premiumize_transfer(transfer['id']) except: pass return selectedFile['stream_link'] else: pass try: if selectedFile['link'] is not None and tools.getSetting( 'premiumize.addToCloud') == 'true': transfer = self.create_transfer(magnet) database.add_premiumize_transfer(transfer['id']) except: pass return selectedFile['link']
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 premiumize_downloader(self, torrent_object): current_percent = 0 debrid = premiumize.PremiumizeFunctions() try: transfer_id = debrid.create_transfer( torrent_object['magnet'])['id'] tools.showDialog.notification(tools.addonName, tools.lang(32072).encode('utf-8')) database.add_assist_torrent(transfer_id, 'premiumize', 'queued', torrent_object['release_title'], str(current_percent)) except: tools.log('Failed to start premiumize debrid transfer', 'error') return timestamp = time.time() while not monitor.abortRequested(): try: if monitor.waitForAbort(120): break transfer_status = [ i for i in debrid.list_transfers()['transfers'] if i['id'] == transfer_id ][0] current_percent = transfer_status['progress'] if transfer_status['status'] == 'finished': database.add_assist_torrent( transfer_id, 'premiumize', transfer_status['status'], torrent_object['release_title'], str(current_percent)) if self.notified == False: tools.showDialog.notification( tools.addonName + ': %s' % self.title, 'New cached sources have been created for %s' % self.title, time=5000) debrid.delete_transfer(transfer_id) database.add_premiumize_transfer(transfer_id) from resources.lib.common import maintenance maintenance.premiumize_transfer_cleanup() break if current_percent == transfer_status['progress']: if timestamp == (time.time() + 10800): database.add_assist_torrent( transfer_id, 'premiumize', 'failed', torrent_object['release_title'], str(current_percent)) debrid.delete_transfer(transfer_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( transfer_id, 'premiumize', transfer_status['status'], torrent_object['release_title'], str(current_percent)) except: database.add_assist_torrent(transfer_id, 'premiumize', 'failed', torrent_object['release_title'], str(current_percent)) debrid.delete_transfer(transfer_id) break return
def _handle_add_to_cloud(self, magnet): if tools.getSetting('premiumize.addToCloud') == 'true': transfer = self.create_transfer(magnet) database.add_premiumize_transfer(transfer['id'])
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