def premiumize_transfer_cleanup(): from resources.lib.debrid import premiumize from resources.lib.modules import database premiumize = premiumize.PremiumizeBase() fair_usage = int(premiumize.account_info()['limit_used'] * 100) threshold = int(tools.getSetting('premiumize.threshold')) if fair_usage < threshold: tools.log('Premiumize Fair Usage below threshold, no cleanup required') return seren_transfers = database.get_premiumize_transfers() if len(seren_transfers) == 0: tools.log('No Premiumize transfers have been created') return tools.log('Premiumize Fair Usage is above threshold, cleaning up Seren transfers') for i in seren_transfers: premiumize.delete_transfer(i['transfer_id']) database.remove_premiumize_transfer(i['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