def getMyPlexAccount(opts=None):  # pragma: no cover
    """ Helper function tries to get a MyPlex Account instance by checking
        the the following locations for a username and password. This is
        useful to create user-friendly command line tools.
        1. command-line options (opts).
        2. environment variables and config.ini
        3. Prompt on the command line.
    """
    from plexapi import CONFIG
    from plexapi.myplex import MyPlexAccount
    # 1. Check command-line options
    if opts and opts.username and opts.password:
        print('Authenticating with Plex.tv as %s..' % opts.username)
        return MyPlexAccount(opts.username, opts.password)
    # 2. Check Plexconfig (environment variables and config.ini)
    config_username = CONFIG.get('auth.myplex_username')
    config_password = CONFIG.get('auth.myplex_password')
    if config_username and config_password:
        print('Authenticating with Plex.tv as %s..' % config_username)
        return MyPlexAccount(config_username, config_password)
    # 3. Prompt for username and password on the command line
    username = input('What is your plex.tv username: ')
    password = getpass('What is your plex.tv password: ')
    print('Authenticating with Plex.tv as %s..' % username)
    return MyPlexAccount(username, password)
def getMyPlexAccount ( opts = None ) : from plexapi import CONFIG from plexapi . myplex import MyPlexAccount if opts and opts . username and opts . password : print ( 'Authenticating with Plex.tv as %s..' % opts . username ) return MyPlexAccount ( opts . username , opts . password ) config_username = CONFIG . get ( 'auth.myplex_username' ) config_password = CONFIG . get ( 'auth.myplex_password' ) if config_username and config_password : print ( 'Authenticating with Plex.tv as %s..' % config_username ) return MyPlexAccount ( config_username , config_password ) username = input ( 'What is your plex.tv username: ' ) password = getpass ( 'What is your plex.tv password: ' ) print ( 'Authenticating with Plex.tv as %s..' % username ) return MyPlexAccount ( username , password )
Helper function tries to get a MyPlex Account instance by checking
        the the following locations for a username and password. This is
        useful to create user-friendly command line tools.
        1. command-line options (opts).
        2. environment variables and config.ini
        3. Prompt on the command line.