def login(plugin): method = Dialog().yesno("Login", "Select Login Method", yeslabel="Keyboard", nolabel="WEB") if method == 1: login_type = Dialog().yesno("Login", "Select Login Type", yeslabel="OTP", nolabel="Password") if login_type == 1: mobile = keyboard("Enter your Jio mobile number") error = sendOTP(mobile) if error: Script.notify("Login Error", error) return otp = keyboard("Enter OTP", hidden=True) ULogin(mobile, otp, mode="otp") elif login_type == 0: username = keyboard("Enter your Jio mobile number or email") password = keyboard("Enter your password", hidden=True) ULogin(username, password) elif method == 0: pDialog = DialogProgress() pDialog.create( 'JioTV', 'Visit [B]http://%s:48996/[/B] to login' % socket.gethostbyname(socket.gethostname())) for i in range(120): sleep(1) with PersistentDict("headers") as db: headers = db.get("headers") if headers or pDialog.iscanceled(): break pDialog.update(i) pDialog.close()
def run(self, remove_entry=None, search=False, first_load=False, **extras): """List all saved searches.""" # Create session hash from givin arguments session_hash = hash_params(extras) self.session_data = session_data = self.search_db.setdefault( session_hash, []) # Remove search term from saved searches if remove_entry and remove_entry in session_data: session_data.remove(remove_entry) self.update_listing = True self.search_db.flush() # Show search dialog if search argument is True, or if there is no search term saved # First load is used to only allow auto search to work when first loading the saved search container. # Fixes an issue when there is no saved searches left after removing them. elif search or (first_load is True and not session_data): search_term = keyboard(self.localize(ENTER_SEARCH_STRING)) if search_term: return self.redirect_search(search_term, extras) elif not session_data: return False else: self.update_listing = True # List all saved search terms return self.list_terms(extras)
def search_dialog(self): """Show dialog for user to enter a new search term.""" search_term = keyboard(self.localize(ENTER_SEARCH_STRING)) if search_term and search_term not in self.search_db: self.search_db.append(search_term) self.search_db.flush() # Return True if text was returned return bool(search_term)
def login(plugin): isKeyboard = Dialog().yesno("Login", "Select Login Type", yeslabel="Keyboard", nolabel="WEB") if isKeyboard: username = keyboard("Enter your Jio mobile number or email") password = keyboard("Enter your password", hidden=True) ULogin(username, password) else: pDialog = DialogProgress() pDialog.create( 'JioTV', 'Visit [B]http://%s:48996/web/login[/B] to login' % socket.gethostbyname(socket.gethostname())) for i in range(120): sleep(1) with PersistentDict("headers") as db: headers = db.get("headers") if headers or pDialog.iscanceled(): break pDialog.update(i) pDialog.close()
def rename_favourite_item(plugin, item_hash): """ Callback function called when the user click on 'rename' from a favourite item context menu """ item_label = utils.keyboard(plugin.localize(LABELS['Favorite name']), xbmc.getInfoLabel('ListItem.Label')) # If user aborded do not edit this item if item_label == '': return False with storage.PersistentDict("favourites.pickle") as db: db[item_hash]['label'] = item_label xbmc.executebuiltin('XBMC.Container.Refresh()')
def rename_favourite_item(plugin, item_hash): """Callback function of the 'Rename' favourite item context menu Args: plugin (codequick.script.Script) item_hash (str): Item hash of the favourite item to rename """ item_label = utils.keyboard(plugin.localize(30801), xbmc.getInfoLabel('ListItem.Label')) # If user aborded do not edit this item if item_label == '': return False fav_dict = get_fav_dict_from_json() fav_dict[item_hash]['label'] = item_label fav_dict[item_hash]['params']['_title_'] = item_label fav_dict[item_hash]['info']['title'] = item_label save_fav_dict_in_json(fav_dict) xbmc.executebuiltin('Container.Refresh()')
def saved_searches(plugin, remove_entry=None, search=False, first_load=False, **extras): """ Callback used to list all saved searches for the addon that called it. Useful to add search support to addon and will also keep track of previous searches. Also contains option via context menu to remove old search terms. :param Route plugin: Tools related to Route callbacks. :param remove_entry: [opt] Search term to remove from history. :param search: [opt] When set to True the search input box will appear. :param first_load: Only True when callback is called for the first time, allowes for search box to appear on load. :param extras: Any extra params to farward on to the next callback :returns: A list of search terms or the search results if loaded for the first time. """ searchdb = Search(plugin, extras) # Remove search term from saved searches if remove_entry and remove_entry in searchdb: searchdb.remove(remove_entry) plugin.update_listing = True # Show search dialog if search argument is True, or if there is no search term saved # First load is used to only allow auto search to work when first loading the saved search container. # Fixes an issue when there is no saved searches left after removing them. elif search or (first_load and not searchdb): search_term = keyboard(plugin.localize(ENTER_SEARCH_STRING)) if search_term: return redirect_search(plugin, searchdb, search_term, extras) elif not searchdb: return False else: plugin.update_listing = True # List all saved search terms return list_terms(plugin, searchdb, extras)
def add_item_to_favourites(plugin, is_playable=False, item_infos={}): """Callback function of the 'Add to add-on favourites' item context menu Args: plugin (codequick.script.Script) is_playable (bool): If 'item' is playable item_infos (dict) """ # Need to use same keywords as # https://scriptmodulecodequick.readthedocs.io/en/latest/_modules/codequick/listing.html#Listitem.from_dict # in order to be able to directly use `Listitem.from_dict` later item_dict = {} # --> subtitles (TODO) # item_dict['subtitles'] = list(item.subtitles) # --> art item_dict['art'] = get_selected_item_art() # --> info item_dict['info'] = get_selected_item_info() # --> stream item_dict['stream'] = get_selected_item_stream() # --> context (TODO) item_dict['context'] = [] # --> properties (TODO) item_dict['properties'] = {} # --> params item_dict['params'] = get_selected_item_params() # --> label item_dict['label'] = get_selected_item_label() if item_infos: # This item comes from tv_guide_menu # We need to remove guide TV related # elements item_id = item_dict['params']['item_id'] item_dict['label'] = get_item_label(item_id, item_infos) item_dict['art']["thumb"] = '' if 'thumb' in item_infos: item_dict['art']["thumb"] = get_item_media_path( item_infos['thumb']) item_dict['art']["fanart"] = '' if 'fanart' in item_infos: item_dict['art']["fanart"] = get_item_media_path( item_infos['fanart']) item_dict['info']['plot'] = '' # Extract the callback item_path = xbmc.getInfoLabel('ListItem.Path') item_dict['callback'] = item_path.replace( 'plugin://plugin.video.catchuptvandmore', '') s = mem_storage.MemStorage('fav') prefix = '' try: prefix = s['prefix'] except KeyError: pass label_proposal = item_dict['label'] if prefix != '': label_proposal = prefix + ' - ' + label_proposal # Ask the user to edit the label label = utils.keyboard(plugin.localize(30801), label_proposal) # If user aborded do not add this item to favourite if label == '': return False item_dict['label'] = label item_dict['params']['_title_'] = label item_dict['info']['title'] = label item_dict['params']['is_playable'] = is_playable item_dict['params']['is_folder'] = not is_playable # Compute fav hash item_hash = md5(str(item_dict).encode('utf-8')).hexdigest() # Add this item to favourites json file fav_dict = get_fav_dict_from_json() item_dict['params']['order'] = len(fav_dict) fav_dict[item_hash] = item_dict # Save json file with new fav_dict save_fav_dict_in_json(fav_dict) Script.notify(Script.localize(30033), Script.localize(30805), display_time=7000)
def add_item_to_favourites(plugin, item_dict={}, **kwargs): """ Callback function called when the user click on 'add item to favourite' from an item context menu """ if 'channel_infos' in kwargs and \ kwargs['channel_infos'] is not None: # This item come from tv_guide_menu # We need to remove guide TV related # elements item_id = item_dict['params']['item_id'] label = item_id if item_id in LABELS: label = LABELS[item_id] if isinstance(label, int): label = Script.localize(label) item_dict['label'] = label if 'thumb' in kwargs['channel_infos']: item_dict['art']["thumb"] = common.get_item_media_path( kwargs['channel_infos']['thumb']) if 'fanart' in kwargs['channel_infos']: item_dict['art']["fanart"] = common.get_item_media_path( kwargs['channel_infos']['fanart']) item_dict['info'] = {} # Extract the callback item_path = xbmc.getInfoLabel('ListItem.Path') item_dict['callback'] = item_path.replace( 'plugin://plugin.video.catchuptvandmore', '') s = mem_storage.MemStorage('fav') prefix = '' try: prefix = s['prefix'] except KeyError: pass label_proposal = item_dict['label'] if prefix != '': label_proposal = prefix + ' - ' + label_proposal # Ask the user to edit the label item_dict['label'] = utils.keyboard( plugin.localize(LABELS['Favorite name']), label_proposal) # If user aborded do not add this item to favourite if item_dict['label'] == '': return False # Add this item to favourite db with storage.PersistentDict("favourites.pickle") as db: # Compute hash value used as key in the DB item_hash = md5(str(item_dict)).hexdigest() item_dict['params']['order'] = len(db) db[item_hash] = item_dict Script.notify(Script.localize(30033), Script.localize(30805), display_time=7000)
def login(plugin): username = Settings.get_string("username") or keyboard( "Username (MobileNo / Email)") password = Settings.get_string("password") or keyboard("Password", hidden=True) ULogin(username, password)
def test_keyboard(self): with testing.mock_keyboard("Testing input"): ret = utils.keyboard("Test") self.assertEqual(ret, "Testing input")
def do_input_page(plugin, url, base_url): input_query = utils.keyboard("Input data:") return open_page(plugin, url, search_query=input_query, base_url=base_url)
def sub_menu(plugin, profile_id, profile_type, is_master, pin): if profile_type == 'KID': plugin.log('Creating Kids Menu', lvl=plugin.WARNING) # get kids user id yield Listitem.from_dict(LIVE_TV, bold(plugin.localize(30101)), params={ 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.from_dict(BROWSE_TVSHOWS, bold(plugin.localize(30102)), params={ "genreId": "", "productSubType": "SERIES", "page": 0, 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.from_dict(BROWSE_TVSHOWS, bold(plugin.localize(30103)), params={ "genreId": "", "productSubType": "PROGRAM", "page": 0, 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.from_dict(BROWSE_MOVIES, bold(plugin.localize(30104)), params={ 'genreId': '', 'page': 0, 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.search(SEARCH_CONTENT, profile_id=profile_id, profile_type=profile_type, is_master=is_master) else: if MODE_KIDS: user_input = keyboard("Enter your PIN Code", "", True) if user_input != pin: plugin.notify(plugin.localize(30202), plugin.localize(30201), display_time=5000, sound=True) yield False return plugin.log('Creating Main Menu', lvl=plugin.WARNING) yield Listitem.from_dict(LIVE_TV, bold(plugin.localize(30101)), params={ 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.from_dict(CATEGORIES, bold(plugin.localize(30102)), params={ "productSubType": "SERIES", 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.from_dict(CATEGORIES, bold(plugin.localize(30103)), params={ "productSubType": "PROGRAM", 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.from_dict(CATEGORIES_M, bold(plugin.localize(30104)), params={ 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) if EMAIL and PASSWORD: yield Listitem.from_dict(MY_LIST, bold(plugin.localize(30105)), params={ 'profile_id': profile_id, 'profile_type': profile_type, 'is_master': is_master }) yield Listitem.search(SEARCH_CONTENT, profile_id=profile_id, profile_type=profile_type, is_master=is_master)