miraclx / freyr-js

A tool for downloading songs from music streaming services like Spotify and Apple Music.
https://git.io/freyr-js
Apache License 2.0
1.37k stars 89 forks source link

fix(meta): use correct total disc number count #634

Closed miraclx closed 5 months ago

miraclx commented 5 months ago

Deezer's API unfortunately, doesn't include any way to derive the total disc count of an album.

There's an alt-API we could use for this (which also provides us copyright information)

$ xh 'https://www.deezer.com/ajax/gw-light.php?method=deezer.getUserData&api_version=1.0&api_token=' \
  | jq '{cf: .results.checkForm, sid: .results.SESSION_ID}'
{
  "cf": "8MBdPkLVd3V~Exj0gJP0chXXXgM~2yb0",
  "sid": "fr0f7920da51b1f2b72dbbc7052a4a4141872d94"
}

$ xh 'https://www.deezer.com/ajax/gw-light.php?method=deezer.pageAlbum&api_version=1.0&api_token=8MBdPkLVd3V~Exj0gJP0chXXXgM~2yb0' \
    cookie:sid=fr0f7920da51b1f2b72dbbc7052a4a4141872d94 \
    alb_id:=264169542 lang=us \
  | jq -r '{total_discs: [.results.SONGS.data[] | .DISK_NUMBER] | unique | sort | reverse[0], copyright: .results.DATA.PRODUCER_LINE}'
{
  "total_discs": "3",
  "copyright": "(P) 2021 Floating World LTD"
}
github-actions[bot] commented 5 months ago
--- 🐋 🤖 **A docker image for this PR has been built!** ```console docker pull freyrcli/freyrjs-git:pr-634 ``` | [**Base (master)**][base-url] | [![](https://img.shields.io/docker/image-size/freyrcli/freyrjs-git/3ad2d58?color=gray&label=%20&logo=docker)][base-url] | | :-: | - | | [**This Patch**][pr-url] | [![](https://img.shields.io/docker/image-size/freyrcli/freyrjs-git/pr-634?color=gray&label=%20&logo=docker)][pr-url] | [![][compare-img]][compare-url] ---
What's this? This docker image is a self-contained sandbox that includes all the patches made in this PR. Allowing others to easily use your patches without waiting for it to get merged and released officially. For more context, see https://github.com/miraclx/freyr-js#docker-development.