mirror of
https://github.com/AliAkhtari78/SpotifyScraper.git
synced 2026-04-26 03:55:50 +03:00
[PR #48] [MERGED] Fix missing album object in get_track_info() response #123
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#123
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?
📋 Pull Request Information
Original PR: https://github.com/AliAkhtari78/SpotifyScraper/pull/48
Author: @Copilot
Created: 5/26/2025
Status: ✅ Merged
Merged: 5/28/2025
Merged by: @AliAkhtari78
Base:
master← Head:copilot/fix-47📝 Commits (4)
f43e8dfInitial plan for issue2c1048dInitial plan for fixing the missing album field in track data585f056Add JSON-LD fallback extraction for album dataaec7fb1Add MCP (Mock, Capture, Playback) testing for album field extraction📊 Changes
14 files changed (+1313 additions, -12 deletions)
View changed files
📝
CHANGELOG.md(+14 -7)➕
MCP_TESTING.md(+107 -0)➕
docs/mcp_testing.md(+127 -0)➕
examples/mcp_testing_demo.py(+130 -0)➕
mcp_test_runner.py(+101 -0)📝
pyproject.toml(+2 -2)📝
src/spotify_scraper/__init__.py(+1 -1)📝
src/spotify_scraper/parsers/json_parser.py(+100 -2)➕
tests/fixtures/vcr_cassettes/track_album_extraction.yaml(+133 -0)➕
tests/fixtures/vcr_cassettes/track_client_album_field.yaml(+133 -0)➕
tests/fixtures/vcr_cassettes/track_json_ld_fallback.yaml(+133 -0)➕
tests/unit/test_track_album.py(+98 -0)➕
tests/unit/test_track_album_mcp.py(+214 -0)➕
track_with_album.json(+20 -0)📄 Description
Problem
The
SpotifyClient.get_track_info()method was missing thealbumfield in its response, causing KeyError when code tried to accesstrack['album']['name']as shown in the README example.Root Cause
The HTML parser was only extracting track data from the first JSON script tag, which sometimes lacks album-level data. Album information is often embedded in a secondary
application/ld+jsonblob in the page.Solution
extract_track_data_from_page()to check if the album field is missing from the primary track dataextract_album_data_from_jsonld()method to extract album information from JSON-LD script tagstests/unit/test_track_album.pyto verify the fixTesting
test_track_album.pywith two tests:test_track_album_field_present: Verifies the album field is properly extracted by TrackExtractortest_client_get_track_info_album_field: Confirms that the client returns data with the album fieldAll tests pass, ensuring that the
albumfield is consistently available in track data.Changes
Fixes #47.
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.