[PR #722] [CLOSED] Objects instead of json #1003

Closed
opened 2026-02-28 00:03:11 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/spotipy-dev/spotipy/pull/722
Author: @MakeShiftArtist
Created: 8/31/2021
Status: Closed

Base: masterHead: master


📝 Commits (3)

  • 09650a2 added Track, User, Artist, Album, and Track objects
  • 6b3f563 added new search methods and changed client.me() to a user object
  • 3cb0af6 bumped to 2.19.1

📊 Changes

3 files changed (+471 additions, -2 deletions)

View changed files

📝 setup.py (+1 -1)
📝 spotipy/client.py (+59 -1)
spotipy/objects.py (+411 -0)

📄 Description

New Objects

Still a work in progress but I didn't like being forced to look at json data to see what was happening, so I added some objects to do that work for us. I did some bug testing and everything seems to be running smoothly. The objects should be fairly well documented as well

User

Meant for user objects, not artists

client.me()

Now returns a User object instead of some json data

Artist

The artist object. Given that some info varies depending on how the request is made, i bug tested and it SHOULD work fine, but you may have some None values

Album

The album object. there may be some None values, but there are 4 new methods to get additional info as well.

Track

the track object, again there may be some None values but it has 3 new methods to get more infomation.

New search methods

if a dev wants to search for artists, tracks, or albums, they can now use client.search_artists, client.search_track, and client.search_albums, respectively, which are generators that give the appropriate objects

Example code

import spotipy
import json
from spotipy.oauth2 import SpotifyOAuth

with open('config.json') as f:
  config = json.load(f)

client = spotipy.Spotify(
    auth_manager=SpotifyOAuth(
        client_id=config["client_id"],
        client_secret=config["client_secret"],
        redirect_uri="http://localhost/",
        scope="user-library-read"
    )
)

albums = client.search_albums("Perception", limit=1)
for album in albums:
    for track in album.get_tracks():
        print(track)
        print(track.explicit)
        break

"""
Intro III
False
"""
``

---

<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
## 📋 Pull Request Information **Original PR:** https://github.com/spotipy-dev/spotipy/pull/722 **Author:** [@MakeShiftArtist](https://github.com/MakeShiftArtist) **Created:** 8/31/2021 **Status:** ❌ Closed **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (3) - [`09650a2`](https://github.com/spotipy-dev/spotipy/commit/09650a27b019f3bcd430237889bc5745c8dc20c6) added Track, User, Artist, Album, and Track objects - [`6b3f563`](https://github.com/spotipy-dev/spotipy/commit/6b3f563c373934670f0e397d67f8e27019b86a7b) added new search methods and changed client.me() to a user object - [`3cb0af6`](https://github.com/spotipy-dev/spotipy/commit/3cb0af60911c333a6614cbed077e4421f3ff3b87) bumped to 2.19.1 ### 📊 Changes **3 files changed** (+471 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `setup.py` (+1 -1) 📝 `spotipy/client.py` (+59 -1) ➕ `spotipy/objects.py` (+411 -0) </details> ### 📄 Description # New Objects Still a work in progress but I didn't like being forced to look at json data to see what was happening, so I added some objects to do that work for us. I did some bug testing and everything seems to be running smoothly. The objects should be fairly well documented as well ## User Meant for user objects, not artists ```py client.me() ``` Now returns a User object instead of some json data ## Artist The artist object. Given that some info varies depending on how the request is made, i bug tested and it SHOULD work fine, but you may have some `None` values ## Album The album object. there may be some None values, but there are 4 new methods to get additional info as well. ## Track the track object, again there may be some None values but it has 3 new methods to get more infomation. # New search methods if a dev wants to search for artists, tracks, or albums, they can now use `client.search_artists`, `client.search_track`, and `client.search_albums`, respectively, which are generators that give the appropriate objects # Example code ```py import spotipy import json from spotipy.oauth2 import SpotifyOAuth with open('config.json') as f: config = json.load(f) client = spotipy.Spotify( auth_manager=SpotifyOAuth( client_id=config["client_id"], client_secret=config["client_secret"], redirect_uri="http://localhost/", scope="user-library-read" ) ) albums = client.search_albums("Perception", limit=1) for album in albums: for track in album.get_tracks(): print(track) print(track.explicit) break """ Intro III False """ `` --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-02-28 00:03:11 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotipy#1003
No description provided.