Skip to content

Commit

Permalink
Fixed: Apple Music top albums chart. Partial fix for #190
Browse files Browse the repository at this point in the history
Apple has changed their feeds and it seems that this may be the only one left
https://rss.applemarketingtools.com/
  • Loading branch information
danielunderwood committed Nov 21, 2021
1 parent 68d4687 commit 2d273f2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lidarrmetadata/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def _parse_itunes_chart(URL, count):
async with aiohttp.ClientSession() as session:
async with session.get(URL, timeout=aiohttp.ClientTimeout(total=5)) as response:
json = await response.json()
results = filter(lambda r: r.get('kind', '') == 'album', json['feed']['results'])
results = filter(lambda r: r.get('kind', '') == 'albums', json['feed']['results'])
search_provider = provider.get_providers_implementing(provider.AlbumNameSearchMixin)[0]
search_results = []
for result in results:
Expand All @@ -36,7 +36,7 @@ async def get_apple_music_top_albums_chart(count=10):
:param count: Number of results to return. Defaults to 10
:return: Chart response for itunes
"""
URL = 'https://rss.itunes.apple.com/api/v1/us/apple-music/top-albums/all/{count}/explicit.json'.format(
URL = 'https://rss.applemarketingtools.com/api/v2/us/music/most-played/{count}/albums.json'.format(
count=4 * count)
return await _parse_itunes_chart(URL, count)

Expand Down
6 changes: 5 additions & 1 deletion tests/chart_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,8 @@ async def test_billboard_200_albums_chart(patch_search_provider):

@pytest.mark.asyncio
async def test_billboard_100_artists_chart(patch_search_provider):
await chart.get_billboard_100_artists_chart()
await chart.get_billboard_100_artists_chart()

@pytest.mark.asyncio
async def test_apple_music_top_albums_chart(patch_search_provider):
await chart.get_apple_music_top_albums_chart()

0 comments on commit 2d273f2

Please sign in to comment.