description and source-codefunction PlexAPI(options, deprecatedPort) {
var opts = options || {};
var hostname = typeof options === 'string' ? options : options.hostname;
this.hostname = hostname;
this.port = deprecatedPort || opts.port || PLEX_SERVER_PORT;
this.https = opts.https;
this.timeout = opts.timeout;
this.username = opts.username;
this.password = opts.password;
this.managedUser = opts.managedUser;
this.authToken = opts.token;
this.authenticator = opts.authenticator || this._credentialsAuthenticator();
this.responseParser = opts.responseParser || this._defaultResponseParser;
this.options = opts.options || {};
this.options.identifier = this.options.identifier || uuid.v4();
this.options.product = this.options.product || 'Node.js App';
this.options.version = this.options.version || '1.0';
this.options.device = this.options.device || os.platform();
this.options.deviceName = this.options.deviceName || 'Node.js App';
this.options.platform = this.options.platform || 'Node.js';
this.options.platformVersion = this.options.platformVersion || process.version;
if (typeof this.hostname !== 'string') {
throw new TypeError('Invalid Plex Server hostname');
}
if (typeof deprecatedPort !== 'undefined') {
console.warn('PlexAPI constuctor port argument is deprecated, use an options object instead.');
}
this.serverUrl = hostname + ':' + this.port;
this._initializeAuthenticator();
}