More reliable album-listing for artists
This commit is contained in:
parent
4b907962d1
commit
ea56805ae9
|
@ -15,10 +15,12 @@
|
||||||
function fetch_page {
|
function fetch_page {
|
||||||
local url="$1"
|
local url="$1"
|
||||||
local referal="$2"
|
local referal="$2"
|
||||||
|
local auth="$3"
|
||||||
curl "$url" \
|
curl "$url" \
|
||||||
--progress-bar \
|
--progress-bar \
|
||||||
-L \
|
-L \
|
||||||
-H 'Accept: audio/webm,audio/ogg,audio/wav,audio/*;q=0.9,application/ogg;q=0.7,video/*;q=0.6,*/*;q=0.5'\
|
-H 'Accept: audio/webm,audio/ogg,audio/wav,audio/*;q=0.9,application/ogg;q=0.7,video/*;q=0.6,*/*;q=0.5'\
|
||||||
|
-H "X-Authorization: Token token=${auth}" \
|
||||||
-H 'Accept-Language: en-US,en;q=0.5' --compressed \
|
-H 'Accept-Language: en-US,en;q=0.5' --compressed \
|
||||||
-H 'Range: bytes=0-' \
|
-H 'Range: bytes=0-' \
|
||||||
-H "Referer: https://music.divercities.eu/albums/$referal" \
|
-H "Referer: https://music.divercities.eu/albums/$referal" \
|
||||||
|
@ -39,19 +41,34 @@ function fetch_album {
|
||||||
# fetch an artist's page
|
# fetch an artist's page
|
||||||
function fetch_artist {
|
function fetch_artist {
|
||||||
local artist_id="$1"
|
local artist_id="$1"
|
||||||
fetch_page "https://music.divercities.eu/artists/$artist_id"
|
local artist_url="https://music.divercities.eu/artists/$artist_id"
|
||||||
|
local token="$(fetch_page "$artist_url" | api_key)"
|
||||||
|
fetch_page "https://music.divercities.eu/api/v1/artists/${artist_id}/albums" "$artist_url" "$token"
|
||||||
|
}
|
||||||
|
|
||||||
|
# artist_id -> html
|
||||||
|
# fetch an artist's album json
|
||||||
|
function fetch_artist_album_json {
|
||||||
|
local artist_id="$1"
|
||||||
|
local token="$(fetch_artist "$artist_id" | api_key)"
|
||||||
|
fetch_page "https://music.divercities.eu/api/v1/artists/${artist_id}/albums" \
|
||||||
|
"$artist_url" "$token"
|
||||||
}
|
}
|
||||||
|
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# PARSE
|
# PARSE
|
||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
# artist_html -> numbers
|
# html -> window.appconfig.apiKey
|
||||||
# take a list of album IDs from an artist's page
|
# return the api key from html, for use with api calls
|
||||||
|
function api_key {
|
||||||
|
grep "apiKey" \
|
||||||
|
| sed "s%.* '%%" \
|
||||||
|
| sed "s%'.*%%"
|
||||||
|
}
|
||||||
|
# artist_album_json -> numbers
|
||||||
|
# take a list of album IDs from an artist's album json
|
||||||
function artist_album_ids {
|
function artist_album_ids {
|
||||||
grep "album-cover " \
|
jq -r '.[].id'
|
||||||
| grep "id:" \
|
|
||||||
| sed 's%.*id: %%' \
|
|
||||||
| sed 's%}).*%%'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# |album_html -> album_track_spans
|
# |album_html -> album_track_spans
|
||||||
|
@ -87,7 +104,8 @@ function track_json_artists {
|
||||||
# download all albums from an artist
|
# download all albums from an artist
|
||||||
function dl_artist {
|
function dl_artist {
|
||||||
local artist_id="$1"
|
local artist_id="$1"
|
||||||
local albums="$(fetch_artist "$artist_id" | artist_album_ids)"
|
local albums="$(fetch_artist_album_json "$artist_id" | artist_album_ids)"
|
||||||
|
|
||||||
for album in $albums; do
|
for album in $albums; do
|
||||||
dl_album "$album"
|
dl_album "$album"
|
||||||
done
|
done
|
||||||
|
|
Ŝarĝante…
Reference in New Issue