mirror of
https://github.com/AliAkhtari78/SpotifyScraper.git
synced 2026-04-25 19:45:49 +03:00
[GH-ISSUE #47] Missing album object in get_track_info() response" #65
Labels
No labels
bug
bug
claude-assistant
claude-assistant
claude-assistant
dependencies
documentation
documentation
enhancement
in review list
infrastructure
infrastructure
infrastructure
pull-request
refactoring
release
stale
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/SpotifyScraper#65
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @AliAkhtari78 on GitHub (May 26, 2025).
Original GitHub issue: https://github.com/AliAkhtari78/SpotifyScraper/issues/47
Originally assigned to: @Copilot on GitHub.
KeyError raised when code tries to access track['album']['name']
🪲 Bug summary
Calling
SpotifyClient.get_track_info()on a standard track URL returns a dictwithout an
albumkey.Consequently, the README example fails on
with
KeyError: 'album'.✔️ Preconditions
Python ≥ 3.9
Package versions:
spotify-scraper== 0.4.0 (latest release)requests== 2.31.0beautifulsoup4== 4.12.3Reproducible on macOS 14.5 and Ubuntu 24.04 (x86_64, ARM64)
🔩 Steps to reproduce
Install from PyPI:
pip install spotify-scraperRun the snippet below unchanged:
Observe
KeyError: 'album'.😕 Current behaviour
SpotifyClient.get_track_info()returns only top-level fields (name,artists,duration_ms, …) but omits the nestedalbumobject.🤔 Expected behaviour
Return value should match Spotify Web API’s Track schema, i.e. include
📜 Logs / traceback
🕵️ Root-cause hypothesis
The HTML parser currently scrapes only the first JSON script tag from
open.spotify.com/track/*, which lacks album-level data; thealbumInformation lives either
application/ld+jsonblob embedded in the page (Gist), or/v1/tracks/{id}(Spotify for Developers, Spotify for Developers).🗺️Guide Task list
tests/test_track_album.py.parser.py::parse_track_json()to include thealbumblock.Option A: extract from
ld+jsonblobOption B: call Web API endpoint if
SPOTIFY_AUTH_TOKENexists.pytest -x.ruff check .&mypy spotify_scraper -p.0.4.1.CHANGELOG.md.Fixes #123).