celebrityAdd( data, socket = false ) {
		//debug('Agent grab celegrity metadata')
		
		// is cache false
		if( isFalse(data.cache) ) {
			return this.epg.agent.celebrity(data)
			.then( results => {
				this.emit(['celebrityAdd', data.iden], results, socket);
				this.broadcast(['celebrityAdd', data.iden], results, socket);
			});
		}
		
		var Person = this.epg.Models.Person;
		
		var remember = Object.assign({}, data);
		delete remember.billingOrder;
		delete remember.role;
		
		// cache
		return this.epg.agent.celebrity( remember )
		.then( results => {
			if(typeof results.error === 'object' && results.error.message) {
				debug('Error with celebrity result');
				this.emit(['celebrityAdd', remember.iden], results, socket)
				debug(result.error.message);
				return false;
			} 
			
			if ( Array.isArray( results ) && results.length > 0 ) {	
				return new Promise( ( resolve, reject ) => {
					
					remember.photo = results[0];
					remember.images = results;
					debug('results celebrityAdd', remember.personId )
					if ( !remember.personId ) return resolve(remember);
					try {
						Person.updateOrCreate({ personId: remember.personId }, remember, (err, newdoc) => {
							if(err) {
								debug('error adding celebrity info', err);
								this.emit('error',{ error: { message: 'Error adding celebrity info for ' + remember.name + ' from database' }}, socket);
								resolve(remember)
							} else {
								this.emit(['celebrityAdd', remember.iden], newdoc, socket);
								resolve(remember)
							}
						});	
					} catch(e) {
						resolve(remember);
					}							
				});
			} else {
				return data
			}
		}).catch((e) => { debug(e); return; });
	}
/** 
	 * get celebrity metadata from source and save to cache
	 * */
get celebrity metadata from source and save to cache
get celebrity metadata from source and save to cache
celebrityAdd( data, socket = false ) {
		if( isFalse(data.cache) ) {
			return this.epg.agent.celebrity(data)
			.then( results => {
				this.emit(['celebrityAdd', data.iden], results, socket);
				this.broadcast(['celebrityAdd', data.iden], results, socket);
			});
		}
		var Person = this.epg.Models.Person;
		var remember = Object.assign({}, data);
		delete remember.billingOrder;
		delete remember.role;
		return this.epg.agent.celebrity( remember )
		.then( results => {
			if(typeof results.error === 'object' && results.error.message) {
				debug('Error with celebrity result');
				this.emit(['celebrityAdd', remember.iden], results, socket)
				debug(result.error.message);
				return false;
			} 
			if ( Array.isArray( results ) && results.length > 0 ) {	
				return new Promise( ( resolve, reject ) => {
					remember.photo = results[0];
					remember.images = results;
					debug('results celebrityAdd', remember.personId )
					if ( !remember.personId ) return resolve(remember);
					try {
						Person.updateOrCreate({ personId: remember.personId }, remember, (err, newdoc) => {
							if(err) {
								debug('error adding celebrity info', err);
								this.emit('error',{ error: { message: 'Error adding celebrity info for ' + remember.name + ' from database' }}, socket);
								resolve(remember)
							} else {
								this.emit(['celebrityAdd', remember.iden], newdoc, socket);
								resolve(remember)
							}
						});	
					} catch(e) {
						resolve(remember);
					}							
				});
			} else {
				return data
			}
		}).catch((e) => { debug(e); return; });
	}
celebrityAdd ( data , socket = false ) { if ( isFalse ( data . cache ) ) { return this . epg . agent . celebrity ( data ) . then ( results => { this . emit ( [ 'celebrityAdd' , data . iden ] , results , socket ) ; this . broadcast ( [ 'celebrityAdd' , data . iden ] , results , socket ) ; } ) ; } var Person = this . epg . Models . Person ; var remember = Object . assign ( { } , data ) ; delete remember . billingOrder ; delete remember . role ; return this . epg . agent . celebrity ( remember ) . then ( results => { if ( typeof results . error === 'object' && results . error . message ) { debug ( 'Error with celebrity result' ) ; this . emit ( [ 'celebrityAdd' , remember . iden ] , results , socket ) debug ( result . error . message ) ; return false ; } if ( Array . isArray ( results ) && results . length > 0 ) { return new Promise ( ( resolve , reject ) => { remember . photo = results [ 0 ] ; remember . images = results ; debug ( 'results celebrityAdd' , remember . personId ) if ( ! remember . personId ) return resolve ( remember ) ; try { Person . updateOrCreate ( { personId : remember . personId } , remember , ( err , newdoc ) => { if ( err ) { debug ( 'error adding celebrity info' , err ) ; this . emit ( 'error' , { error : { message : 'Error adding celebrity info for ' + remember . name + ' from database' } } , socket ) ; resolve ( remember ) } else { this . emit ( [ 'celebrityAdd' , remember . iden ] , newdoc , socket ) ; resolve ( remember ) } } ) ; } catch ( e ) { resolve ( remember ) ; } } ) ; } else { return data } } ) . catch ( ( e ) => { debug ( e ) ; return ; } ) ; }
get celebrity metadata from source and save to cache
get celebrity metadata from source and save to cache
//debug('Agent grab celegrity metadata') // is cache false // cache