|
2 | 2 | import requests, json |
3 | 3 | from utils import * |
4 | 4 |
|
| 5 | + |
5 | 6 | def room_scrape(link="https://music.apple.com/us/room/6748797380"): |
| 7 | + """ |
| 8 | + Scrape a shared Apple Music room and extract song URLs. |
| 9 | +
|
| 10 | + Parameters |
| 11 | + ---------- |
| 12 | + link : str, optional |
| 13 | + URL of the Apple Music room page. Defaults to an example room link. |
| 14 | +
|
| 15 | + Returns |
| 16 | + ------- |
| 17 | + list[str] |
| 18 | + List of converted song URLs extracted from the room. |
| 19 | +
|
| 20 | + Notes |
| 21 | + ----- |
| 22 | + This function parses the `serialized-server-data` script tag within |
| 23 | + the Apple Music room HTML, locates the 'copper-track-swoosh' section, |
| 24 | + and extracts track URLs. |
| 25 | + """ |
6 | 26 | result = [] |
7 | 27 | headers = {"User-Agent": "Mozilla/5.0"} |
8 | 28 |
|
@@ -40,6 +60,7 @@ def room_scrape(link="https://music.apple.com/us/room/6748797380"): |
40 | 60 |
|
41 | 61 | return result |
42 | 62 |
|
| 63 | + |
43 | 64 | def playlist_scrape(link="https://music.apple.com/us/playlist/new-music-daily/pl.2b0e6e332fdf4b7a91164da3162127b5"): |
44 | 65 | result = [] |
45 | 66 | headers = {"User-Agent": "Mozilla/5.0"} |
@@ -78,6 +99,7 @@ def playlist_scrape(link="https://music.apple.com/us/playlist/new-music-daily/pl |
78 | 99 |
|
79 | 100 | return result |
80 | 101 |
|
| 102 | + |
81 | 103 | def search(keyword="sasha sloan"): |
82 | 104 | result = {"artists": [], "albums": [], "songs": [], "playlists": [], "videos": []} |
83 | 105 | link = f"https://music.apple.com/us/search?term={keyword}" |
@@ -200,6 +222,7 @@ def search(keyword="sasha sloan"): |
200 | 222 |
|
201 | 223 | return result |
202 | 224 |
|
| 225 | + |
203 | 226 | def song_scrape(url="https://music.apple.com/us/song/california/1821538031"): |
204 | 227 | result = { |
205 | 228 | "title": "", |
@@ -278,6 +301,7 @@ def song_scrape(url="https://music.apple.com/us/song/california/1821538031"): |
278 | 301 |
|
279 | 302 | return result |
280 | 303 |
|
| 304 | + |
281 | 305 | def album_scrape(url="https://music.apple.com/us/album/1965/1817707266?i=1817707585"): |
282 | 306 | result = { |
283 | 307 | "title": "", |
@@ -419,6 +443,7 @@ def album_scrape(url="https://music.apple.com/us/album/1965/1817707266?i=1817707 |
419 | 443 |
|
420 | 444 | return result |
421 | 445 |
|
| 446 | + |
422 | 447 | def video_scrape(url="https://music.apple.com/us/music-video/gucci-mane-visualizer/1810547026"): |
423 | 448 | result = { |
424 | 449 | "title": "", |
@@ -519,6 +544,7 @@ def video_scrape(url="https://music.apple.com/us/music-video/gucci-mane-visualiz |
519 | 544 |
|
520 | 545 | return result |
521 | 546 |
|
| 547 | + |
522 | 548 | def artist_scrape(url="https://music.apple.com/us/artist/king-princess/1349968534"): |
523 | 549 | result = { |
524 | 550 | "title": "", |
|
0 commit comments