def show_add_library_title_dialog(self, original_title):
"""
Asks the user for an alternative title for the show/movie that
gets exported to the local library
:param original_title: Original title of the show
:type original_title: str
:returns: str - Title to persist
"""
if self.custom_export_name == 'true':
return original_title
dlg = xbmcgui.Dialog()
custom_title = dlg.input(
heading=self.get_local_string(string_id=30031),
defaultt=original_title,
type=xbmcgui.INPUT_ALPHANUM) or original_title
return original_title or custom_title
python类INPUT_ALPHANUM的实例源码
def on_keyboard_input(self, title, default='', hidden=False):
# fallback for Frodo
if self._context.get_system_version().get_version() <= (12, 3):
keyboard = xbmc.Keyboard(default, title, hidden)
keyboard.doModal()
if keyboard.isConfirmed() and keyboard.getText():
text = utils.to_unicode(keyboard.getText())
return True, text
else:
return False, u''
# Starting with Gotham (13.X > ...)
dialog = xbmcgui.Dialog()
result = dialog.input(title, utils.to_unicode(default), type=xbmcgui.INPUT_ALPHANUM)
if result:
text = utils.to_unicode(result)
return True, text
return False, u''
def init_session():
email = xbmcgui.Dialog().input(translation(30001), addon.getSetting('email'), xbmcgui.INPUT_ALPHANUM)
if email == '': return False
addon.setSetting('email', email)
clave = xbmcgui.Dialog().input(translation(30002), '', xbmcgui.INPUT_ALPHANUM, xbmcgui.ALPHANUM_HIDE_INPUT)
if clave == '': return False
url = '{0}/auth/login'.format(ID_URL)
response = requests.post(url, {'email': email, 'password': clave}, headers=get_headers())
data, errmsg = decode_json(response)
if data:
addon.setSetting('token', data['token'])
return True
else:
xbmcgui.Dialog().ok(translation(30003), errmsg)
return False
def search_video(self, search_string=None, page=1):
if search_string is None:
search_string = xbmcgui.Dialog().input(
'Search term',
type=xbmcgui.INPUT_ALPHANUM)
result = self.eyny.search_video(search_string, page=page)
self._add_video_items(result['videos'], result['current_url'])
if page < int(result['last_page']):
self._add_page_item(
page + 1,
result['last_page'],
'search',
search_string=search_string
)
xbmcplugin.endOfDirectory(self.addon_handle)
def on_keyboard_input(self, title, default='', hidden=False):
# fallback for Frodo
if self._context.get_system_version().get_version() <= (12, 3):
keyboard = xbmc.Keyboard(default, title, hidden)
keyboard.doModal()
if keyboard.isConfirmed() and keyboard.getText():
text = utils.to_unicode(keyboard.getText())
return True, text
else:
return False, u''
pass
# Starting with Gotham (13.X > ...)
dialog = xbmcgui.Dialog()
result = dialog.input(title, utils.to_unicode(default), type=xbmcgui.INPUT_ALPHANUM)
if result:
text = utils.to_unicode(result)
return True, text
return False, u''
def search():
dlg = xbmcgui.Dialog()
term = dlg.input('Suchbegriff', type=xbmcgui.INPUT_ALPHANUM)
if term == '':
return
term = term.replace(' ', '+')
url = 'https://www.skygo.sky.de/SILK/services/public/search/web?searchKey=' + term + '&version=12354&platform=web&product=SG'
r = skygo.session.get(url)
data = json.loads(r.text[3:len(r.text)-1])
listitems = []
for item in data['assetListResult']:
url = common.build_url({'action': 'playVod', 'vod_id': item['id']})
listitems.append({'type': 'searchresult', 'label': item['title'], 'url': url, 'data': item})
# if data['assetListResult']['hasNext']:
# url = common.build_url({'action': 'listPage', 'path': ''})
# listitems.append({'type': 'path', 'label': 'Mehr...', 'url': url})
listAssets(listitems)
def login_dialog():
username = dialog.input(u'???:', type=xbmcgui.INPUT_ALPHANUM)
password = dialog.input(u'??:', type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)
if username and password:
cookie,tokens = get_auth.run(username,password)
if tokens:
save_user_info(username,password,cookie,tokens)
homemenu = plugin.get_storage('homemenu')
homemenu.clear()
dialog.ok('',u'????', u'???????????')
items = [{'label': u'<< ????', 'path': plugin.url_for('main_menu')}]
return plugin.finish(items, update_listing=True)
else:
dialog.ok('Error',u'??????????')
return None
def start(twitterhash=None, standalone=False):
if not twitterhash:
userInput = True
if os.path.exists(tweet_file):
twitter_data = json.loads(FileIO.fileread(tweet_file))
twitterhash = twitter_data["hash"]
twitter_mediafile = twitter_data["file"]
if twitter_mediafile == xbmc.getInfoLabel('Player.Filenameandpath'):
userInput = False
else:
userInput = False
if userInput:
dialog = xbmcgui.Dialog()
twitterhash = dialog.input(translate(32046), type=xbmcgui.INPUT_ALPHANUM)
if len(twitterhash) != 0:
twitterhash = twitterhash.replace("#","")
else:
xbmcgui.Dialog().ok(translate(32000), translate(32047))
mainmenu.start()
if twitterhash:
#Save twitter hashtag
if twitter_history_enabled == 'true':
tweet.add_hashtag_to_twitter_history(twitterhash)
if xbmc.getCondVisibility("Player.HasMedia") and save_hashes_during_playback == 'true':
tweet.savecurrenthash(twitterhash)
main = TwitterDialog('script-matchcenter-Twitter.xml', addon_path, getskinfolder(), '', hash=twitterhash, standalone=standalone)
main.doModal()
del main
def show_password_dialog(self):
"""
Shows password input
:returns: string - Password characters
"""
dlg = xbmcgui.Dialog()
return dlg.input(
self.utils.get_local_string(string_id=32004),
type=xbmcgui.INPUT_ALPHANUM,
option=xbmcgui.ALPHANUM_HIDE_INPUT)
def show_email_dialog(self):
"""
Shows email input
:returns: string - Email characters
"""
dlg = xbmcgui.Dialog()
return dlg.input(
self.utils.get_local_string(string_id=32005),
type=xbmcgui.INPUT_ALPHANUM)
def show_search_term_dialog(self):
"""
Asks the user for a term to query the netflix search for
:returns: str - Term to search for
"""
dlg = xbmcgui.Dialog()
term = dlg.input(
heading=self.get_local_string(string_id=30003),
type=xbmcgui.INPUT_ALPHANUM)
if len(term) == 0:
term = None
return term
def show_password_dialog(self):
"""
Asks the user for its Netflix password
:returns: str - Netflix password
"""
dlg = xbmcgui.Dialog()
dialog = dlg.input(
heading=self.get_local_string(string_id=30004),
type=xbmcgui.INPUT_ALPHANUM,
option=xbmcgui.ALPHANUM_HIDE_INPUT)
return dialog
def show_email_dialog(self):
"""
Asks the user for its Netflix account email
:returns: str - Netflix account email
"""
dlg = xbmcgui.Dialog()
dialog = dlg.input(
heading=self.get_local_string(string_id=30005),
type=xbmcgui.INPUT_ALPHANUM)
return dialog
def renamePlaylistDialog(self, playlist):
dialog = xbmcgui.Dialog()
title = dialog.input(_T(30233), playlist.title, type=xbmcgui.INPUT_ALPHANUM)
ok = False
if title:
description = dialog.input(_T(30234), playlist.description, type=xbmcgui.INPUT_ALPHANUM)
ok = self.rename_playlist(playlist, title, description)
return ok
def newPlaylistDialog(self):
dialog = xbmcgui.Dialog()
title = dialog.input(_T(30233), type=xbmcgui.INPUT_ALPHANUM)
item = None
if title:
description = dialog.input(_T(30234), type=xbmcgui.INPUT_ALPHANUM)
item = self.create_playlist(title, description)
return item
def onClick(self, controlId):
if controlId == self.C_CAT_CATEGORY:
cList = self.getControl(self.C_CAT_CATEGORY)
item = cList.getSelectedItem()
if item:
self.selected_category = item.getLabel()
self.category = self.selected_category
self.buttonClicked = controlId
self.close()
elif controlId == 80005:
kodi = float(xbmc.getInfoLabel("System.BuildVersion")[:4])
dialog = xbmcgui.Dialog()
if kodi < 16:
dialog.ok('TV Guide Fullscreen', 'Editing categories in Kodi %s is currently not supported.' % kodi)
else:
cat = dialog.input('Add Category', type=xbmcgui.INPUT_ALPHANUM)
if cat:
categories = set(self.categories)
categories.add(cat)
self.categories = list(set(categories))
items = list()
categories = ["All Channels"] + list(self.categories)
for label in categories:
item = xbmcgui.ListItem(label)
items.append(item)
listControl = self.getControl(self.C_CAT_CATEGORY)
listControl.reset()
listControl.addItems(items)
else:
self.buttonClicked = controlId
self.close()
def two_step_verification(self, ticket_uuid):
dialog = xbmcgui.Dialog()
code = dialog.input(self.localized(30204), type=xbmcgui.INPUT_ALPHANUM)
if code == '': sys.exit()
url = self.api_url + '/ssocookie'
headers = {
"Accept": "*/*",
"Content-type": "application/x-www-form-urlencoded",
"Origin": "https://id.sonyentertainmentnetwork.com",
"Accept-Language": "en-US,en;q=0.8",
"Accept-Encoding": "deflate",
"User-Agent": self.ua_android_tv,
"Connection": "Keep-Alive",
"Referer": "https://id.sonyentertainmentnetwork.com/signin/?service_entity=urn:service-entity:psn&ui=pr&service_logo=ps&response_type=code&scope=psn:s2s&client_id="+self.req_client_id+"&request_locale=en_US&redirect_uri=https://io.playstation.com/playstation/psn/acceptLogin&error=login_required&error_code=4165&error_description=User+is+not+authenticated"
}
payload = 'authentication_type=two_step&ticket_uuid='+ticket_uuid+'&code='+code+'&client_id='+self.login_client_id
r = requests.post(url, headers=headers, cookies=self.load_cookies(), data=payload, verify=self.verify)
json_source = r.json()
self.save_cookies(r.cookies)
if 'npsso' in json_source:
npsso = json_source['npsso']
self.addon.setSetting(id='npsso', value=npsso)
elif 'error_description' in json_source:
msg = json_source['error_description']
self.notification_msg(self.localized(30200), msg)
sys.exit()
else:
# Something went wrong during login
self.notification_msg(self.localized(30200), self.localized(30201))
sys.exit()
def search():
dialog = xbmcgui.Dialog()
search_txt = dialog.input('Enter search text', type=xbmcgui.INPUT_ALPHANUM)
if search_txt == '': sys.exit()
json_source = get_json(EPG_URL + '/search/'+search_txt+'/offset/0/size/100')
list_shows(json_source['body']['programs'])
def login(self):
if self.username == '':
dialog = xbmcgui.Dialog()
self.username = dialog.input(self.localized(30202), type=xbmcgui.INPUT_ALPHANUM)
if self.username != '':
self.addon.setSetting(id='username', value=self.username)
else:
sys.exit()
if self.password == '':
dialog = xbmcgui.Dialog()
self.password = dialog.input(self.localized(30203), type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)
if self.password != '':
self.addon.setSetting(id='password', value=self.password)
else:
sys.exit()
if self.username != '' and self.password != '':
url = self.api_url + '/ssocookie'
headers = {"Accept": "*/*",
"Content-type": "application/x-www-form-urlencoded",
"Origin": "https://id.sonyentertainmentnetwork.com",
"Accept-Language": "en-US,en;q=0.8",
"Accept-Encoding": "deflate",
"User-Agent": self.ua_android_tv,
"X-Requested-With": "com.snei.vue.atv",
"Connection": "Keep-Alive"
}
payload = 'authentication_type=password&username='+urllib.quote_plus(self.username)+'&password='+urllib.quote_plus(self.password)+'&client_id='+self.andriod_tv_client_id
r = requests.post(url, headers=headers, cookies=self.load_cookies(), data=payload, verify=self.verify)
json_source = r.json()
self.save_cookies(r.cookies)
if 'npsso' in json_source:
npsso = json_source['npsso']
self.addon.setSetting(id='npsso', value=npsso)
elif 'authentication_type' in json_source:
if json_source['authentication_type'] == 'two_step':
ticket_uuid = json_source['ticket_uuid']
self.two_step_verification(ticket_uuid)
elif 'error_description' in json_source:
msg = json_source['error_description']
self.notification_msg(self.localized(30200), msg)
sys.exit()
else:
# Something went wrong during login
self.notification_msg(self.localized(30200), self.localized(30201))
sys.exit()
def wizard():
addon = xbmcaddon.Addon("service.vpn.manager")
addon_name = addon.getAddonInfo("name")
# Indicate the wizard has been run, regardless of if it is to avoid asking again
addon.setSetting("vpn_wizard_run", "true")
# Wizard or settings?
if xbmcgui.Dialog().yesno(addon_name, "No primary VPN connection has been set up. Would you like to do this using the set up wizard or using the Settings dialog?", "", "", "Settings", "Wizard"):
# Select the VPN provider
provider_list = list(provider_display)
provider_list.sort()
vpn = xbmcgui.Dialog().select("Select your VPN provider.", provider_list)
vpn = provider_display.index(provider_list[vpn])
vpn_provider = provider_display[vpn]
success = True
# If User Defined VPN then offer to run the wizard
if isUserDefined(vpn_provider):
success = importWizard()
if success:
# Get the username and password
vpn_username = ""
vpn_password = ""
if usesPassAuth(vpn_provider):
vpn_username = xbmcgui.Dialog().input("Enter your " + vpn_provider + " username.", type=xbmcgui.INPUT_ALPHANUM)
if not vpn_username == "":
vpn_password = xbmcgui.Dialog().input("Enter your " + vpn_provider + " password.", type=xbmcgui.INPUT_ALPHANUM, option=xbmcgui.ALPHANUM_HIDE_INPUT)
# Try and connect if we've gotten all the data
if (not usesPassAuth(vpn_provider)) or (not vpn_password == ""):
addon.setSetting("vpn_provider", vpn_provider)
addon.setSetting("vpn_username", vpn_username)
addon.setSetting("vpn_password", vpn_password)
connectVPN("1", vpn_provider)
# Need to reinitialise addon here for some reason...
addon = xbmcaddon.Addon("service.vpn.manager")
if connectionValidated(addon):
xbmcgui.Dialog().ok(addon_name, "Successfully connected to " + vpn_provider + ". Use the Settings dialog to add additional VPN connections. You can also define add-on filters to dynamically change the VPN connection being used.")
else:
xbmcgui.Dialog().ok(addon_name, "Could not connect to " + vpn_provider + ". Use the Settings dialog to correct any issues and try connecting again.")
else:
xbmcgui.Dialog().ok(addon_name, "You need to enter both a VPN username and password to connect.")
else:
xbmcgui.Dialog().ok(addon_name, "There was a problem setting up the User Defined provider. Fix any issues and run the wizard again from the VPN Configuration tab.")