added page limit pass through variable

This commit is contained in:
aj 2020-01-25 20:30:15 +00:00
parent 1a2970bc5d
commit ccd0754633
2 changed files with 31 additions and 2 deletions

View File

@ -308,6 +308,27 @@ class AudioFeatures:
self.track_href = track_href
self.valence = self.check_float(valence)
def to_dict(self):
return {
'acousticness': self.acousticness,
'analysis_url': self.analysis_url,
'danceability': self.danceability,
'duration_ms': self.duration_ms,
'energy': self.energy,
'uri': str(self.uri) if self.uri is not None else None,
'instrumentalness': self.instrumentalness,
'key': self.key,
'key_code': self._key,
'liveness': self.liveness,
'loudness': self.loudness,
'mode': self.mode.value,
'speechiness': self.speechiness,
'tempo': self.tempo,
'time_signature': self.time_signature,
'track_href': self.track_href,
'valence': self.valence
}
@property
def key(self) -> str:
legend = {

View File

@ -808,8 +808,13 @@ class Network:
if resp:
if resp.get('audio_features', None):
parsed_features = [self.parse_audio_features(i) for i in resp['audio_features']]
audio_features += parsed_features
for feature in resp['audio_features']:
if feature is not None:
audio_features.append(self.parse_audio_features(feature))
else:
audio_features.append(None)
else:
logger.error('no audio features included')
else:
@ -840,6 +845,9 @@ class Network:
audio_features = self.get_track_audio_features([i.uri for i in tracks])
if audio_features:
if len(audio_features) != len(tracks):
logger.error(f'{len(audio_features)} features returned for {len(tracks)} tracks')
for index, track in enumerate(tracks):
track.audio_features = audio_features[index]