def MainMenu(view_group="InfoList"): """ First function and main menu for your channel Display Main Menu if API_K was retrieved TODO: make search compatible in Plex/Web """ oc = ObjectContainer() headphones.SSL = Prefs['https'] headphones.IP = Prefs['hpIP'] headphones.PORT = Prefs['hpPort'] headphones.HTTP_ROOT = Prefs['hpURLBase'] headphones.username = Prefs['hpUsername'] headphones.password = Prefs['hpPassword'] API_KEY = False if headphones.API_K: API_KEY = True Dict['settings_modified'] = False else: try: headphones.API_K = headphones.getAPI_K() if headphones.API_K: API_KEY = True except: oc.add(PrefsObject(title="Preferences", summary="PLUGIN IS CURRENTLY UNABLE TO CONNECT TO Retrieve API_K.\nCheck network settings & channel preferences", thumb=R(PREFS_ICON))) return oc if API_KEY: oc.add(DirectoryObject(key=Callback(GetIndex), title="Manage Your Music Catalog", summary="View and edit your existing music library")) oc.add(DirectoryObject(key=Callback(GetUpcoming), title="Future Releases", summary="See which artists in your catalog have future releases", thumb=R(UPCOMING))) oc.add(DirectoryObject(key=Callback(GetHistory), title="History", summary="See which albums have been snatched/downloaded recently", thumb=R(HISTORY))) oc.add(DirectoryObject(key=Callback(Wanted), title="Wanted List", summary="Wanted albums", thumb=R(WANTED))) # an InputDO in the MainMenu of a channel will work ( in web) when only in the main menu, but anywhere else subsequent, it fails #oc.add(InputDirectoryObject(key=Callback(SearchMenu), title="search", summary="Results of search", prompt="Search for:", thumb=R(SEARCH_ICON))) #oc.add(InputDirectoryObject(key=Callback(SearchMenu), title="Plex/Web search", summary="Results of search", prompt="Search for:", thumb=R(SEARCH_ICON))) if Client.Product == "Web Client": oc.add(InputDirectoryObject(key=Callback(QueryArtist), title="Search for Artist", summary="Find an Artist to add to Headphones", prompt="Search for", thumb=R(SEARCH_ICON))) else: oc.add(DirectoryObject(key=Callback(SearchMenu), title="Search", summary="Album or Artist Search for Plex Home Theater client", thumb=R(SEARCH_ICON))) oc.add(DirectoryObject(key=Callback(Suggestions), title="Suggestions", summary="Artists suggested by Headphones app", thumb=R(ICON))) oc.add(PrefsObject(title="Preferences", summary="Set Headphones preferences", thumb=R(PREFS_ICON))) else: oc.add(PrefsObject(title="Preferences", summary="PLUGIN IS CURRENTLY UNABLE TO CONNECT TO HEADPHONES.\nSet Headphones plugin preferences to allow it to connect to Headphones server", thumb=R(PREFS_ICON))) return oc
def ValidatePrefs(): """ This function is called when the user modifies their preferences. The developer can check the newly provided values to ensure they are correct (e.g. attempting a login to validate a username and password), and optionally return a MessageContainer to display any error information to the user. """ if Prefs['hpIP']: try: headphones.API_K = headphones.getAPI_K() Dict['API_K'] = headphones.API_K return except: return ObjectContainer(header="Unable to retrieve API key", message="Please confirm that your settings are correct.") else: return ObjectContainer(header="Unable to retrieve API key", message="Please confirm that your settings are correct.")
def ValidatePrefs(): """ This function is called when the user modifies their preferences. The developer can check the newly provided values to ensure they are correct (e.g. attempting a login to validate a username and password), and optionally return a MessageContainer to display any error information to the user. """ if Prefs['hpIP']: try: headphones.API_K = headphones.getAPI_K() Dict['API_K'] = headphones.API_K return except: return ObjectContainer( header="Unable to retrieve API key", message="Please confirm that your settings are correct.") else: return ObjectContainer( header="Unable to retrieve API key", message="Please confirm that your settings are correct.")
def MainMenu(view_group="InfoList"): """ First function and main menu for your channel Display Main Menu if API_K was retrieved TODO: make search compatible in Plex/Web """ oc = ObjectContainer() headphones.SSL = Prefs['https'] headphones.IP = Prefs['hpIP'] headphones.PORT = Prefs['hpPort'] headphones.HTTP_ROOT = Prefs['hpURLBase'] headphones.username = Prefs['hpUsername'] headphones.password = Prefs['hpPassword'] API_KEY = False if headphones.API_K: API_KEY = True Dict['settings_modified'] = False else: try: headphones.API_K = headphones.getAPI_K() if headphones.API_K: API_KEY = True except: oc.add( PrefsObject( title="Preferences", summary= "PLUGIN IS CURRENTLY UNABLE TO CONNECT TO Retrieve API_K.\nCheck network settings & channel preferences", thumb=R(PREFS_ICON))) return oc if API_KEY: oc.add( DirectoryObject( key=Callback(GetIndex), title="Manage Your Music Catalog", summary="View and edit your existing music library")) oc.add( DirectoryObject( key=Callback(GetUpcoming), title="Future Releases", summary= "See which artists in your catalog have future releases", thumb=R(UPCOMING))) oc.add( DirectoryObject( key=Callback(GetHistory), title="History", summary= "See which albums have been snatched/downloaded recently", thumb=R(HISTORY))) oc.add( DirectoryObject(key=Callback(Wanted), title="Wanted List", summary="Wanted albums", thumb=R(WANTED))) # an InputDO in the MainMenu of a channel will work ( in web) when only in the main menu, but anywhere else subsequent, it fails #oc.add(InputDirectoryObject(key=Callback(SearchMenu), title="search", summary="Results of search", prompt="Search for:", thumb=R(SEARCH_ICON))) #oc.add(InputDirectoryObject(key=Callback(SearchMenu), title="Plex/Web search", summary="Results of search", prompt="Search for:", thumb=R(SEARCH_ICON))) if Client.Product == "Web Client": oc.add( InputDirectoryObject( key=Callback(QueryArtist), title="Search for Artist", summary="Find an Artist to add to Headphones", prompt="Search for", thumb=R(SEARCH_ICON))) else: oc.add( DirectoryObject( key=Callback(SearchMenu), title="Search", summary= "Album or Artist Search for Plex Home Theater client", thumb=R(SEARCH_ICON))) oc.add( DirectoryObject(key=Callback(Suggestions), title="Suggestions", summary="Artists suggested by Headphones app", thumb=R(ICON))) oc.add( PrefsObject(title="Preferences", summary="Set Headphones preferences", thumb=R(PREFS_ICON))) else: oc.add( PrefsObject( title="Preferences", summary= "PLUGIN IS CURRENTLY UNABLE TO CONNECT TO HEADPHONES.\nSet Headphones plugin preferences to allow it to connect to Headphones server", thumb=R(PREFS_ICON))) return oc