I want to make the music downloader of the Deezer which is music streaming platform
I have the code that request for the track URL:
import requests
headers = {
'authority': 'media.deezer.com',
'accept': '*/*',
'accept-language': 'en-US,en;q=0.9',
'content-type': 'application/json',
'origin': 'https://www.deezer.com',
'referer': 'https://www.deezer.com/',
'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"Windows"',
'sec-fetch-dest': 'empty',
'sec-fetch-mode': 'cors',
'sec-fetch-site': 'same-site',
'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
}
json_data = {
'license_token': 'AAAAAmWndttluz1by1SZowwHmCO-Mfo99shWj_AhHRysQcye5-DpFgVrLA1lYOpM2kxERKQiK--Ulo4vgTaaZ3IcIBV-jr1EAW_5114q9kOWxDPOuZT1gtfU4Rw1EIs',
'media': [
{
'type': 'FULL',
'formats': [
{
'cipher': 'BF_CBC_STRIPE',
'format': 'MP3_320',
},
{
'cipher': 'BF_CBC_STRIPE',
'format': 'MP3_128',
},
{
'cipher': 'BF_CBC_STRIPE',
'format': 'MP3_64',
},
{
'cipher': 'BF_CBC_STRIPE',
'format': 'MP3_MISC',
},
],
},
],
'track_tokens': [
'AAAAAWWnduFlqJAhWxZsdW9pVwI4sivQdCYNtpC_3Lxcj9MhEe_nkK2Rt5BwtSz3nOWIcGhxxNdPgiwq4a-USGnqQ_9Pqg8iTDRJYwThYaX_2JUwON-favtBtg1C-qIma2J9dmfimmP4i1OaekWipQ',
],
}
response = requests.post('https://media.deezer.com/v1/get_url', headers=headers, json=json_data).json()
print(response)
Response of the code
{
"data": [
{
"media": [
{
"media_type": "FULL",
"cipher": {
"type": "BF_CBC_STRIPE"
},
"format": "MP3_320",
"sources": [
{
"url": "https://cdnt-proxy-b.dzcdn.net/media/1/4653e02de2367afac9f4c40349e527276b8234d1ad36c7d62dfe99e5d3bc3f0942defa439c38cc8c3753593b44903aabe5b9bd9186402e84eff8ee88b1e6818dee21beb5377e0ae8cb6caa3b827220ed?hdnea=exp=1705545761~acl=/media/1/4653e02de2367afac9f4c40349e527276b8234d1ad36c7d62dfe99e5d3bc3f0942defa439c38cc8c3753593b44903aabe5b9bd9186402e84eff8ee88b1e6818dee21beb5377e0ae8cb6caa3b827220ed*~data=user_id=4994708722~hmac=73631a9293783b344614bdb539af09904e7ed300f2b8843c74b31509a9183766",
"provider": "ak"
},
{
"url": "https://e-cdnt-proxy-b.dzcdn.net/media/1/4653e02de2367afac9f4c40349e527276b8234d1ad36c7d62dfe99e5d3bc3f0942defa439c38cc8c3753593b44903aabe5b9bd9186402e84eff8ee88b1e6818dee21beb5377e0ae8cb6caa3b827220ed?bWQjn9ppxHd6pH9mmrQ9b9A3-YaBw8hCDog7D9wr_Xeha77CYgnsWQaKb_99SMn_27iLcweRsZKaYOt3suok4PxF1onc31ekg7lokQhtkP89WYijdrD-OWtPvsVJeEofO4lRmKjoReStGeh2EgERRriwgAXPunPJ_edhKMQCy_rXfOSOWK5CvZuuZB0z3pKurhVRFPFCPKDrdj_11e73HQxfltAy0kjJ467ar2xH61zhRg-2X7sOHlbU65hM6dukNmS5sS6ga2z4RvADqNQh21uJDyzZa5mUA8Io8Mqm7_V0f_wbvMR7T1g2i3rgZeLSiJGA7Opb7zIKDA",
"provider": "ec"
}
],
"nbf": 1705473761,
"exp": 1705545761
}
]
}
]
}
Now this data is returned from the post request which contain 2 link when I send request on both links I received the mp3 data and I will stored it in mp3 file but music on both file is distorted and noisy and not clear.
The Question is that how I can get the clear music without distortion and noise As I am intermediate level programmer so I have not too much knowledge about encryption and decryption , hmac . From response I have come to know that they use a cipher called Blowfish CBC Stripe and there is HMAC in the first link.