Skip to content

Commit d6bc2e7

Browse files
committed
add docstring for room scrape fun in apple-music-scraper
1 parent d9f3010 commit d6bc2e7

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

Apple-Music-Scraper/main.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,27 @@
22
import requests, json
33
from utils import *
44

5+
56
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+
"""
626
result = []
727
headers = {"User-Agent": "Mozilla/5.0"}
828

@@ -40,6 +60,7 @@ def room_scrape(link="https://music.apple.com/us/room/6748797380"):
4060

4161
return result
4262

63+
4364
def playlist_scrape(link="https://music.apple.com/us/playlist/new-music-daily/pl.2b0e6e332fdf4b7a91164da3162127b5"):
4465
result = []
4566
headers = {"User-Agent": "Mozilla/5.0"}
@@ -78,6 +99,7 @@ def playlist_scrape(link="https://music.apple.com/us/playlist/new-music-daily/pl
7899

79100
return result
80101

102+
81103
def search(keyword="sasha sloan"):
82104
result = {"artists": [], "albums": [], "songs": [], "playlists": [], "videos": []}
83105
link = f"https://music.apple.com/us/search?term={keyword}"
@@ -200,6 +222,7 @@ def search(keyword="sasha sloan"):
200222

201223
return result
202224

225+
203226
def song_scrape(url="https://music.apple.com/us/song/california/1821538031"):
204227
result = {
205228
"title": "",
@@ -278,6 +301,7 @@ def song_scrape(url="https://music.apple.com/us/song/california/1821538031"):
278301

279302
return result
280303

304+
281305
def album_scrape(url="https://music.apple.com/us/album/1965/1817707266?i=1817707585"):
282306
result = {
283307
"title": "",
@@ -419,6 +443,7 @@ def album_scrape(url="https://music.apple.com/us/album/1965/1817707266?i=1817707
419443

420444
return result
421445

446+
422447
def video_scrape(url="https://music.apple.com/us/music-video/gucci-mane-visualizer/1810547026"):
423448
result = {
424449
"title": "",
@@ -519,6 +544,7 @@ def video_scrape(url="https://music.apple.com/us/music-video/gucci-mane-visualiz
519544

520545
return result
521546

547+
522548
def artist_scrape(url="https://music.apple.com/us/artist/king-princess/1349968534"):
523549
result = {
524550
"title": "",

0 commit comments

Comments
 (0)