# Apple Music CLI / Wrapper Single-file Node.js ESM scraper + CLI untuk **music.apple.com**. Zero dependency. Hanya butuh Node.js ≥ 18. Ambil metadata katalog (search, song, album, artist, playlist, charts, home, dll.) tanpa developer token resmi — memakai anonymous token dari web player. > **Bukan** downloader full track. Full audio dilindungi DRM FairPlay. --- ## Install ```bash tidak perlu install / zero depency ``` Syarat: **Node.js ≥ 18** (built-in `fetch`). --- ## CLI ```bash node apple-music.js [args] [options] ``` ### Commands | Command | Keterangan | |---------|------------| | `search ` | Cari lagu / album / artist / playlist | | `suggest ` | Search suggestions | | `song ` | Detail lagu | | `album ` | Detail album + daftar tracks | | `artist ` | Detail artist | | `playlist ` | Detail playlist + tracks | | `url ` | Resolve URL `music.apple.com/...` | | `charts` | Top charts (songs, albums, playlists) | | `genres` | Daftar genre | | `storefronts` | Daftar negara / storefront | | `home` | Ringkasan: top songs + albums + playlists + genres | | `token` | Tampilkan anonymous token | ### Options | Flag | Default | Keterangan | |------|---------|------------| | `-c, --country ` | `us` | Storefront (`us`, `id`, `jp`, `gb`, ...) | | `-l, --limit ` | `10` | Limit hasil | | `-t, --types ` | `songs,albums,artists,playlists` | Filter tipe search | | `-j, --json` | (default) | Output JSON pretty | | `-H, --human` | — | Output human-readable | | `-h, --help` | — | Help | ### Contoh ```bash # Search node apple-music.js search "never gonna give you up" -l 5 node apple-music.js search "tulus" -c id -l 5 node apple-music.js search "drake" -t songs -l 3 # Detail (boleh ID atau URL penuh) node apple-music.js song 1559885421 node apple-music.js album 1559885420 node apple-music.js artist 669771 node apple-music.js playlist "https://music.apple.com/us/playlist/.../pl.xxx" node apple-music.js song "https://music.apple.com/us/album/.../1559885420?i=1559885421" # Resolve URL node apple-music.js url "https://music.apple.com/us/album/never-gonna-give-you-up/1559885420?i=1559885421" # Charts / home node apple-music.js charts -c id -l 20 node apple-music.js home -c us -l 5 # Suggestions node apple-music.js suggest "sienna spiro" # Human-readable node apple-music.js search "tulus" -c id -l 3 --human ``` --- ## Output (contoh) ```json { "songs": [ { "id": "1559885421", "type": "song", "name": "Never Gonna Give You Up", "url": "https://music.apple.com/us/album/never-gonna-give-you-up/1559885420?i=1559885421", "artwork": "https://is1-ssl.mzstatic.com/image/thumb/.../600x600bb.jpg", "artist": "Rick Astley", "album": "Whenever You Need Somebody", "durationSec": 214, "releaseDate": "1987-07-27", "isrc": "GBARL9300135", "genres": ["Pop", "Music"], "trackNumber": 1, "discNumber": 1 } ] } ``` Field umum: | Field | Tipe | Ada di | |-------|------|--------| | `id` | string | semua | | `type` | string | semua | | `name` | string | semua | | `url` | string | semua | | `artwork` | string (URL) | semua | | `artist` | string | song, album | | `album` | string | song | | `durationSec` | number | song | | `releaseDate` | string | song, album | | `isrc` | string | song | | `genres` | string[] | song, album, artist | | `trackNumber` / `discNumber` | number | song | | `trackCount` | number | album | | `upc` | string | album | | `recordLabel` | string | album | | `tracks` | array | album, playlist | | `curator` / `description` | string | playlist | --- ## Library (import) ```js import { search, getSong, getAlbum, getArtist, getPlaylist, resolve, charts, home, suggestions, parseUrl, } from "./apple-music.js"; const results = await search("tulus", { country: "id", limit: 5 }); console.log(results.songs); const song = await getSong("1559885421"); console.log(song.name, song.artist, song.durationSec); const link = await resolve( "https://music.apple.com/us/album/never-gonna-give-you-up/1559885420?i=1559885421" ); ``` ### API utama ```js search(term, { country, limit, types, lang }) suggestions(term, { country, limit, types }) getSong(id, { country }) getAlbum(id, { country }) // + tracks[] getArtist(id, { country }) getPlaylist(id, { country }) // + tracks[] resolve(url) // parse + fetch dari link music.apple.com charts({ country, limit, types }) home({ country, limit }) genres({ country }) storefronts({ limit }) parseUrl(url) // { type, id, storefront } | null ``` --- ## Catatan - Token diambil otomatis dari web player Apple Music (cache di memory). - Storefront default: `us`. Ganti dengan `-c id` untuk Indonesia, dll. - Full track **tidak** bisa diunduh (DRM). Scraper ini hanya metadata + artwork URL. - Output selalu JSON pretty kecuali pakai `--human`.