platypush/common/spotify/__init__.py
def spotify_get_track(self, track_id: str):
        """
        Get information about a Spotify track ID.
        """
        if self._spotify_api_credentials:
            info = self.spotify_api_call(f'/v1/tracks/{track_id}')
        else:
            info = json.loads(
                [
                    re.match(r'^\s*Spotify.Entity\s*=\s*(.*);\s*$', line).group(1)
                    for line in requests.get(f'https://open.spotify.com/track/{track_id}').text.split('\n')
                    if 'Spotify.Entity' in line
                ].pop()
            )

        return SpotifyTrackSchema().dump({
            **info,
            'file': info['uri'],
            'time': info['duration_ms']/1000. if info.get('duration_ms') is not None else None,
            'artist': '; '.join([
                artist['name'] for artist in info.get('artists', [])
            ]),
            'album': info.get('album', {}).get('name'),
            'name': info.get('name'),
            'title': info.get('name'),
            'date': int(info.get('album', {}).get('release_date', '').split('-')[0]),
            'track': info.get('track_number'),
            'id': info['id'],
            'x-albumuri': info.get('album', {}).get('uri'),
        })

        Get information about a Spotify track ID.
        
Get information about a Spotify track ID.
Get information about a Spotify track ID .
def spotify_get_track(self, track_id: str):
        if self._spotify_api_credentials:
            info = self.spotify_api_call(f'/v1/tracks/{track_id}')
        else:
            info = json.loads(
                [
                    re.match(r'^\s*Spotify.Entity\s*=\s*(.*);\s*$', line).group(1)
                    for line in requests.get(f'https://open.spotify.com/track/{track_id}').text.split('\n')
                    if 'Spotify.Entity' in line
                ].pop()
            )
        return SpotifyTrackSchema().dump({
            **info,
            'file': info['uri'],
            'time': info['duration_ms']/1000. if info.get('duration_ms') is not None else None,
            'artist': '; '.join([
                artist['name'] for artist in info.get('artists', [])
            ]),
            'album': info.get('album', {}).get('name'),
            'name': info.get('name'),
            'title': info.get('name'),
            'date': int(info.get('album', {}).get('release_date', '').split('-')[0]),
            'track': info.get('track_number'),
            'id': info['id'],
            'x-albumuri': info.get('album', {}).get('uri'),
        })
def spotify_get_track ( self , track_id : str ) : if self . _spotify_api_credentials : info = self . spotify_api_call ( f'/v1/tracks/{track_id}' ) else : info = json . loads ( [ re . match ( r'^\s*Spotify.Entity\s*=\s*(.*);\s*$' , line ) . group ( 1 ) for line in requests . get ( f'https://open.spotify.com/track/{track_id}' ) . text . split ( '\n' ) if 'Spotify.Entity' in line ] . pop ( ) ) return SpotifyTrackSchema ( ) . dump ( { ** info , 'file' : info [ 'uri' ] , 'time' : info [ 'duration_ms' ] / 1000. if info . get ( 'duration_ms' ) is not None else None , 'artist' : '; ' . join ( [ artist [ 'name' ] for artist in info . get ( 'artists' , [ ] ) ] ) , 'album' : info . get ( 'album' , { } ) . get ( 'name' ) , 'name' : info . get ( 'name' ) , 'title' : info . get ( 'name' ) , 'date' : int ( info . get ( 'album' , { } ) . get ( 'release_date' , '' ) . split ( '-' ) [ 0 ] ) , 'track' : info . get ( 'track_number' ) , 'id' : info [ 'id' ] , 'x-albumuri' : info . get ( 'album' , { } ) . get ( 'uri' ) , } )
Get information about a Spotify track ID.
Get information about a Spotify track ID .
"""
        Get information about a Spotify track ID.
        """
self
track_id
str