|
1 | 1 | # Apple Music Scraper |
2 | 2 |
|
3 | | -**Apple Music Scraper** is a powerful tool for extracting rich data from Apple Music web pages using web scraping and reverse-engineered structure of `serialized-server-data`. |
4 | | - |
5 | | -This project is unofficial and purely for educational purposes. No official Apple API used. |
6 | | - |
7 | | - |
8 | | -<br> |
9 | | - |
10 | | - |
11 | | -## 🔧 Functions |
12 | | - |
13 | | -| Function | Parameters | Description | |
14 | | -|------------------------|------------------------------|------------------------------------------------------| |
15 | | -| `search(keyword)` | `keyword: str` | Search Apple Music for artists, songs, albums, playlists, and videos | |
16 | | -| `song_scrape(url)` | `url: str` | Get metadata and preview URL of a song | |
17 | | -| `album_scrape(url)` | `url: str` | Get album details including songs, artist, similar albums, and videos | |
18 | | -| `playlist_scrape(url)` | `url: str` | Extract song URLs from a playlist | |
19 | | -| `room_scrape(url)` | `url: str` | Extract song URLs from a shared room | |
20 | | -| `video_scrape(url)` | `url: str` | Get video metadata including direct video URL and related content | |
21 | | -| `artist_scrape(url)` | `url: str` | Get artist metadata including top songs, albums, videos, bio, and more | |
22 | | - |
23 | | -Each function returns structured JSON containing metadata, URLs, images, previews, and related data. |
24 | | - |
25 | | - |
26 | | -<br> |
27 | | - |
28 | | -## 🧠 Usage |
29 | | - |
30 | | -install requirements |
31 | | - |
32 | | -```bash |
33 | | -pip install -r requirements.txt |
| 3 | +A powerful unofficial scraper for extracting structured metadata from Apple Music web pages using web-scraping techniques and reverse-engineered `serialized-server-data`. |
| 4 | +This tool is for **educational purposes only** and does **not** use any official Apple API. |
| 5 | + |
| 6 | +- **Functionalities** |
| 7 | + - Search for artists, songs, albums, playlists, and videos |
| 8 | + - Extract song metadata and preview URLs |
| 9 | + - Fetch album details including tracks, artist info, similar albums, and videos |
| 10 | + - Scrape playlist and shared room song URLs |
| 11 | + - Retrieve video metadata and direct video links |
| 12 | + - Fetch full artist information including top songs, albums, biography, and more |
| 13 | + |
| 14 | +--- |
| 15 | + |
| 16 | +## Setup Instructions |
| 17 | + |
| 18 | +1. Clone or download the project |
| 19 | +2. Install dependencies: |
| 20 | + ```bash |
| 21 | + pip install -r requirements.txt |
| 22 | + ``` |
| 23 | +3. Import and use the scraper in your Python script: |
| 24 | + ```python |
| 25 | + result = search('night tapes') |
| 26 | + artists = result['artists'] |
| 27 | + |
| 28 | + artist_url = artists[0]['url'] |
| 29 | + artist = artist_scrape(artist_url) |
| 30 | + |
| 31 | + latest_night_tapes_song_url = artist['latest'] |
| 32 | + |
| 33 | + song = album_scrape(latest_night_tapes_song_url) |
| 34 | + song_name = song['title'] |
| 35 | + song_cover = song['image'] |
| 36 | + |
| 37 | + print(f"\nLatest Night Tapes Song: {song_name}\nCover Art: {song_cover}\n") |
| 38 | + ``` |
| 39 | + |
| 40 | +--- |
| 41 | + |
| 42 | +## Detailed Explanation |
| 43 | + |
| 44 | +Each scraping function processes the `serialized-server-data` embedded in Apple Music’s webpage structure. |
| 45 | +The scraper extracts metadata such as: |
| 46 | +- Titles, URLs, artwork |
| 47 | +- Track lists |
| 48 | +- Preview links |
| 49 | +- Album/artist relationships |
| 50 | +- Related videos or albums |
| 51 | +All results are returned as **structured JSON objects** for easy access in your applications. |
| 52 | + |
| 53 | +--- |
| 54 | + |
| 55 | +## Output |
| 56 | + |
| 57 | +The scraper returns JSON structures like: |
| 58 | + |
| 59 | +```json |
| 60 | +{ |
| 61 | + "title": "Example Song", |
| 62 | + "artist": "Example Artist", |
| 63 | + "image": "https://example-image.jpg", |
| 64 | + "preview": "https://example-preview.m4a", |
| 65 | + "related": [...], |
| 66 | + "songs": [...] |
| 67 | +} |
34 | 68 | ``` |
35 | 69 |
|
36 | | -use scraper! |
37 | | -```python |
| 70 | +You can log these results, display them in an interface, or process them however you like. |
38 | 71 |
|
39 | | -result = search('night tapes') |
40 | | -artists = result['artists'] |
| 72 | +--- |
41 | 73 |
|
42 | | -artist_url = artists[0]['url'] |
43 | | -artist = artist_scrape(artist_url) |
| 74 | +## Author |
44 | 75 |
|
45 | | -latest_night_tapes_song_url = artist['latest'] |
| 76 | +- [**Abssdghi**](https://github.com/Abssdghi) |
46 | 77 |
|
47 | | -song = album_scrape(latest_night_tapes_song_url) |
48 | | -song_name = song['title'] |
49 | | -song_cover = song['image'] |
| 78 | +--- |
50 | 79 |
|
51 | | -print(f"\nLatest Night Tapes Song: {song_name}\nCover Art: {song_cover}\n") |
| 80 | +## Disclaimers |
52 | 81 |
|
53 | | -``` |
| 82 | +- This project is **not affiliated with Apple Inc.** |
| 83 | +- It uses **web scraping** and may break if Apple changes its internal web structure. |
| 84 | +- For **educational and personal use only**. Redistribution of scraped content may violate Apple Music’s Terms of Service. |
0 commit comments