yaronzz / Tidal-Media-Downloader

Download 'TIDAL' Music On Windows/Linux/MacOs (PYTHON/C#)
http://doc.yaronzz.com/post/tidal_dl_installation/
Apache License 2.0
3.4k stars 473 forks source link

[FEATURE]: Quality "HIGH" for HiRes-FLAC from August 2023? #1080

Open queen4me opened 1 year ago

queen4me commented 1 year ago

Which tool

tidal-dl

Describe the feature

TIDAL has anounced to change from MQA to HiRes-FLAC starting in August 2023. Would you please implement downloading HiRes-FLAC files? I'm a big fan of your awesome tool and can't wait to download HiRes FLAC instead of these messy MQA.

Add screenshots

No response

SiddharthSharma01 commented 11 months ago

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

ebb-earl-co commented 11 months ago

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

I went through the other repo linked by @pablo-reyes-cabrera above, and was able to download 24-bit 44.1kHz of this song here. image

The access token I used was gotten from the Android method (I have an Android tablet, and pulled the Tidal app's files to my laptop with adb).

That repository was archived 4 days ago, and it's not a polished tool like yaronzz's tidal-dl, but since I was a Python developer years ago, I was able to massage the code to get it to do what I want. I have half a mind to fully flesh out his implementation and submit a PR here given my success...

ladle3000 commented 11 months ago

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

I went through the other repo linked by @pablo-reyes-cabrera above, and was able to download 24-bit 44.1kHz of this song here. image

The access token I used was gotten from the Android method (I have an Android tablet, and pulled the Tidal app's files to my laptop with adb).

That repository was archived 4 days ago, and it's not a polished tool like yaronzz's tidal-dl, but since I was a Python developer years ago, I was able to massage the code to get it to do what I want. I have half a mind to fully flesh out his implementation and submit a PR here given my success...

Cool. What improvements are there over the yaronzz version?

pablo-reyes-cabrera commented 11 months ago

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

I went through the other repo linked by @pablo-reyes-cabrera above, and was able to download 24-bit 44.1kHz of this song here. image

The access token I used was gotten from the Android method (I have an Android tablet, and pulled the Tidal app's files to my laptop with adb).

That repository was archived 4 days ago, and it's not a polished tool like yaronzz's tidal-dl, but since I was a Python developer years ago, I was able to massage the code to get it to do what I want. I have half a mind to fully flesh out his implementation and submit a PR here given my success...

Super! Is it possible that you can share the new code?

thanks in advance,

Pablo

ebb-earl-co commented 11 months ago

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

I went through the other repo linked by @pablo-reyes-cabrera above, and was able to download 24-bit 44.1kHz of this song here. image The access token I used was gotten from the Android method (I have an Android tablet, and pulled the Tidal app's files to my laptop with adb). That repository was archived 4 days ago, and it's not a polished tool like yaronzz's tidal-dl, but since I was a Python developer years ago, I was able to massage the code to get it to do what I want. I have half a mind to fully flesh out his implementation and submit a PR here given my success...

Cool. What improvements are there over the yaronzz version?

@ladle3000 honestly, not much: it looks to be a clone. The biggest difference is that the lescx/tidal-dl has removed everything to do with videos.

ladle3000 commented 11 months ago

Thanks for the honesty 👍🏼

On Tue, Oct 24, 2023, 2:50 PM Colin Eberl Coe @.***> wrote:

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

I went through the other repo linked https://github.com/lescx/tidal-dl by @pablo-reyes-cabrera https://github.com/pablo-reyes-cabrera above, and was able to download 24-bit 44.1kHz of this song here https://tidal.com/browse/track/317662496. [image: image] https://user-images.githubusercontent.com/11299014/277496141-2fbb3536-5389-4d2b-a76e-a3bbc5cdc5f1.png The access token I used was gotten from the Android method (I have an Android tablet, and pulled the Tidal app's files to my laptop with adb). That repository was archived 4 days ago, and it's not a polished tool like yaronzz's tidal-dl, but since I was a Python developer years ago, I was able to massage the code to get it to do what I want. I have half a mind to fully flesh out his implementation and submit a PR here given my success...

Cool. What improvements are there over the yaronzz version?

@ladle3000 https://github.com/ladle3000 honestly, not much: it looks to be a clone. The biggest difference is that the lescx/tidal-dl has removed everything to do with videos.

— Reply to this email directly, view it on GitHub https://github.com/yaronzz/Tidal-Media-Downloader/issues/1080#issuecomment-1777832579, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASBWJJ5AVNZ57GR4LKX4PDYBAEXZAVCNFSM6AAAAAAZ2V5KQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONZXHAZTENJXHE . You are receiving this because you were mentioned.Message ID: @.***>

ebb-earl-co commented 11 months ago

@SiddharthSharma01 the process, at a conceptual level, is not very complicated.

  1. Get an access token (called a bearer token) This is an industry standard way of authenticating calls to an API.

    • A token is granted by the server by doing the OAUTH2 dance, which is the Tidal web page that pops up with a 5-letter code. The Master-Only client_id is used by default (see here) to do this OAUTH2 exchange. How do they have this client_id? That's a good question, and I don't know the answer, but this file shows that it comes from a project called RedSea. In any case, the OAUTH2 dance amounts to this function in the tidal.py file sending what's called a POST request to the Tidal authentication API endpoint: https://auth.tidal.com/v1/oauth2/device_authorization.
    • If no error occurred, (which would happen if the client_id suddenly became invalid, so let's cross our fingers it keeps working) then you'll get the following response from the Tidal authorization API: {'deviceCode': 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', 'userCode': 'XXXXX', 'verificationUri': 'link.tidal.com', 'verificationUriComplete': 'link.tidal.com/XXXXX', 'expiresIn': 300, 'interval': 2}. Obviously, I've removed the actual values. Now, the function loginByWeb displays the verificationUriComplete on the screen for expireIn seconds (here, 300), waiting for you to click on the link and authorize the device. In particular, it runs checkAuthStatus every interval + 1 seconds (here, every 3 seconds).
    • This checkAuthStatus function is the Bearer token getter; the key to us getting a key. Once again it's preparing and sending a POST request, but this time to the endpoint https://auth.tidal.com/v1/oauth2/token. This endpoint, as you can probably guess by the name, will give you a Bearer token if you send it the proof that the device you just authorized is actually authorized. How is this done? You can think of HTTP requests as envelopes in the normal (snail) mail: the endpoints, or URLs, are the addresses on the front of the envelope. The data/parameters/everything following the "?" in the URL are the contents of the envelope. The old-timey wax seal on the envelope is the auth parameter sent; here it's those cracked values from the RedSea project. Lastly, one of the values sent inside our envelope is 'grant_type': 'urn:ietf:params:oauth:grant-type:device_code' which is us saying "We're sending the device_code and client_id, please grant us a Bearer token in your return envelope".
    • If the POST request to the /token endpoint is successful, we'll receive a response with a lot of fields, but the important ones are the following: 'clientName': 'TIDAL_Android_2.38.0_Fire_TV_Atmos', 'token_type': 'Bearer', 'access_token': 'LONG_GOBBLEDYGOOK_HERE', 'refresh_token': 'DIFFERENT_GOBBLEDYGOOK_HERE', 'expires_in': 604800}. The expires_in number is 1 week in seconds. The access_token is our key, figuratively and literally: it is the "seal" with which we can stamp all "envelopes" we send to the API from here on out, to prove that we are a trusted client, getting the API to return data to what it thinks is an Android 2.38.0-running, Dolby Atmos-enabled, Fire TV TIDAL app.
    • As an aside, the refresh_token value is useful, because after this access_token expires in a week, all that has to be done is to send a POST request to the same /token endpoint, but this time passing along grant_type: 'refresh_token'. This will return a fresh, new access_token that will be valid for another week.
  2. Now that you have an access_token (and, by the way, you could have skipped all of step 1 if you have an expired access_token written down somewhere, and have access to the refresh_token value, by logging in with the convenience function loginByAccessToken. How do you know if a token is expired? Simply send an "envelope" to https://api.tidal.com/v1/sessions sealed with the access_token using this function, and it will tell you whether the token is still valid. In any case, now we have (almost) carte blanche access to the API, how do we get album covers and artist information and the actual music data? You guessed it: more requests to API endpoints! To answer @SiddharthSharma01's original question: once you've got a track that you want to get in HiRes format (24-bit FLAC, >= 44.1kHz sampling rate), get its numeric ID value, I'll call this track_id, and send a request to https://api.tidalhifi.com/v1/tracks/track_id/playbackinfopostpaywall?countryCode=US&audioquality=HI_RES_LOSSLESS&&playbackmode=STREAM&assetpresentation=FULL making sure to "seal" the request with your access_token (a.k.a. bearer token). The countryCode part will be different if you authenticated in a different country, so you'll need to know the ISO 3166-1 alpha-2 country code for your country. I feel as if what I've written here is already toeing the line of what's acceptable/liable to get this project taken down from GitHub, so I'll just broadly outline the next few steps: having them available in the code is one thing, but spelling them out in English I feel is a good way to get a DMCA takedown request...

  3. The response from a properly-formatted request in step 2 is probably a base64-encoded XML document enumerating the DASH protocol chunks of the file you want to receive. This will be 50 or so fragments of the desired file, in .mp4 format.

  4. The downloadTrack function downloads all of these .mp4 parts of the file in parallel, and decrypts the final, full file (which is the name of the track + .part at the end) using a master key that must have been figured out by some other enterprising hackers.

  5. Et voilà, you've got a .flac of the track you wanted. The rest of this script is figuring out where you wanted it downloaded; what metadata you wanted to add to the file; whether to download album cover.

I'll close this by saying that the excellent yt-dlp project is able to download a file given the MPD information (essentially an XML document; what the Tidal /track API returns to the client), so using that excellent project's code could cut down on the complexity for this here project, but TBD whether it would work...

HritwikSinghal commented 11 months ago

Hi sorry for disturbing but I am totally new here. Both tidal dl and gui version only download 16 bit 44.1khz in hifi (As I don't want Mqa files). My only question is there any way to download 24bit 44.1khz or 48khz (if not hi res ). But I want lossless files not Mqa files. Can any one help and please describe it briefly. Thanks for the help

I went through the other repo linked by @pablo-reyes-cabrera above, and was able to download 24-bit 44.1kHz of this song here. image

The access token I used was gotten from the Android method (I have an Android tablet, and pulled the Tidal app's files to my laptop with adb).

That repository was archived 4 days ago, and it's not a polished tool like yaronzz's tidal-dl, but since I was a Python developer years ago, I was able to massage the code to get it to do what I want. I have half a mind to fully flesh out his implementation and submit a PR here given my success...

I went through the same repo, made the changes to make it work, and it looks like it is downloading MQA just like this project.

I ran MQA_identifier on the files, and they are indeed shown as MQA.

as for what changes i made, i set the squality = "HI_RES_LOSSLESS" here so that it basically always downloads HIGH_RES.

pablo-reyes-cabrera commented 10 months ago

Hi, Finally (using Charles, not fiddler), I was able to download themes with high resolution (up to 24 bits and 96Khz). However, when the quality of a track in tidal is Max|mqa it downloads in 44khz, 16 bits. Which doesn't match me with the "master" concept. it's that ok?. or tidal-dl doesn't handle mqa?.

regards, Pablo

fndrsm commented 9 months ago

Two things to note: most tracks are still MQA or only 48/24 FLAC (where the file size is pretty similar), and two, the API sometimes serves different encodes of FLAC with the same frequency and bitrate but wildly different file sizes (no idea how that can possibly work with FLAC but it's what the API does)

check with qobuz, if you find quality more than 48/24 you can download true hires.

with some edit and access_token on browser, i can download HI_RES_LOSSLESS. Btw current client_app credentials can't generate access_token have HI_RES_LOSSLESS

eg: https://tidal.com/browse/track/266515518

HI_RES vs HI_RES_LOSSLESS

2023-08-04

is that foobar with skin? any link download for the skin? @Emrise-r

fndrsm commented 9 months ago

I went through the same repo, made the changes to make it work, and it looks like it is downloading MQA just like this project.

I ran MQA_identifier on the files, and they are indeed shown as MQA.

as for what changes i made, i set the squality = "HI_RES_LOSSLESS" here so that it basically always downloads HIGH_RES.

Hi, can i get the exe file for tidal-dl or tidal-gui that contain your changes which squality = "HI_RES_LOSSLESS". Since i don't understand how to build this project. Thanks

ebb-earl-co commented 9 months ago

Everyone, if you're still looking for a way to get HiRes, please check out my project, which is a fork of this project: https://github.com/ebb-earl-co/tidal-wave. I don't have a GUI yet, but command-line version works on Windows, GNU/Linux, (probably) MacOS, and there's even a Docker image.

Here's some output from downloading Never Gonna Give You Up: image

And here's the beginning of the logs for downloading Pink Floyd's Dark Side of the Moon, which is available in HiRes: image

ladle3000 commented 9 months ago

I will definitely give it a try. Thanks for your efforts!

On Tue, Jan 2, 2024 at 1:32 PM Colin Coe @.***> wrote:

Everyone, if you're still looking for a way to get HiRes, please check out my project, which is a fork of this project: https://github.com/ebb-earl-co/tidal-wave. I don't have a GUI yet, but command-line version works on Windows, GNU/Linux, (probably) MacOS, and there's even a Docker image.

Here's some output from downloading Never Gonna Give You Up https://tidal.com/browse/track/226092704: image.png (view on web) https://github.com/yaronzz/Tidal-Media-Downloader/assets/11299014/ab68a973-7950-4fad-a272-b7af3e0d9852

— Reply to this email directly, view it on GitHub https://github.com/yaronzz/Tidal-Media-Downloader/issues/1080#issuecomment-1874395345, or unsubscribe https://github.com/notifications/unsubscribe-auth/AASBWJOMBY5Z6VX7ORUQYX3YMRHE5AVCNFSM6AAAAAAZ2V5KQWVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZUGM4TKMZUGU . You are receiving this because you were mentioned.Message ID: @.***>

fndrsm commented 9 months ago

Everyone, if you're still looking for a way to get HiRes, please check out my project, which is a fork of this project: https://github.com/ebb-earl-co/tidal-wave. I don't have a GUI yet, but command-line version works on Windows, GNU/Linux, (probably) MacOS, and there's even a Docker image.

Here's some output from downloading Never Gonna Give You Up: image

And here's the beginning of the logs for downloading Pink Floyd's Dark Side of the Moon, which is available in HiRes: image

Always give error FileNotFoundError: [WinError 2] The system cannot find the file specified. How do i fix it? image

Track used :

  1. https://tidal.com/browse/track/330333348
  2. https://tidal.com/browse/track/266515518
ebb-earl-co commented 9 months ago

Everyone, if you're still looking for a way to get HiRes, please check out my project, which is a fork of this project: https://github.com/ebb-earl-co/tidal-wave. I don't have a GUI yet, but command-line version works on Windows, GNU/Linux, (probably) MacOS, and there's even a Docker image. Here's some output from downloading Never Gonna Give You Up: image And here's the beginning of the logs for downloading Pink Floyd's Dark Side of the Moon, which is available in HiRes: image

Always give error FileNotFoundError: [WinError 2] The system cannot find the file specified. How do i fix it? image

Track used :

1. https://tidal.com/browse/track/330333348

2. https://tidal.com/browse/track/266515518

@fndrsm do you have FFmpeg installed? This looks suspiciously like you do not have it installed.

fndrsm commented 9 months ago

@fndrsm do you have FFmpeg installed? This looks suspiciously like you do not have it installed.

I don't know. But i saw ffmpeg.dll on Tidal folder. I don't understand this things on windows and i don't use linux right know. What I have to do with FFmpeg file that i download from FFmpeg website? Where do i put those files since i dont see .exe file to install. Sorry I just not understand yet how FFmpeg installation.

ebb-earl-co commented 9 months ago

@fndrsm it's no problem, there are a couple easy ways to install FFmpeg on Windows:

in the second scenario, you might have to deal with Windows paths and make sure that the shell can find ffmpeg.exe once you've extracted it from the .zip, but I'm not a Windows expert...

fndrsm commented 9 months ago

@fndrsm it's no problem, there are a couple easy ways to install FFmpeg on Windows:

* The best way is to use a proper package manager on Windows, and Chocolatey is great. Once Chocolatey is installed, you simply execute `choco install ffmpeg -y` in an Administrative shell

* On [FFmpeg's website](https://ffmpeg.org//download.html#build-windows) there is a link to [this person's GitHub site](https://github.com/BtbN/FFmpeg-Builds/releases). There, you download the `https://github.com/BtbN/FFmpeg-Builds/releases/download/latest/ffmpeg-master-latest-win64-gpl.zip` file and extract the zip
  ![image](https://private-user-images.githubusercontent.com/11299014/293822429-338c9ff4-d500-4a07-be56-536dc14ae9b4.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MDQyNDk1NTksIm5iZiI6MTcwNDI0OTI1OSwicGF0aCI6Ii8xMTI5OTAxNC8yOTM4MjI0MjktMzM4YzlmZjQtZDUwMC00YTA3LWJlNTYtNTM2ZGMxNGFlOWI0LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDAxMDMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwMTAzVDAyMzQxOVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ1YzQwNjFhZWIxMTZkNzc5MzRmMWY1MjA1YzEzMTk5ZWNmYjgyZTJjMGI5ODY2Zjg4MDY2YTQ3ZmQxODk2ZmUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.UiBYe94oFVZynK-oEYIG9LkFm3LzHR5gY-6_rqR_HhU)

in the second scenario, you might have to deal with Windows paths and make sure that the shell can find ffmpeg.exe once you've extracted it from the .zip, but I'm not a Windows expert...

I did manage to run you script. Thanks, i'll reply you again when i have any question.

image image

Emrise-r commented 9 months ago

Yes it is skin https://github.com/Ottodix/Eole-foobar-theme

ladle3000 commented 8 months ago

Everyone, if you're still looking for a way to get HiRes, please check out my project, which is a fork of this project: https://github.com/ebb-earl-co/tidal-wave. I don't have a GUI yet, but command-line version works on Windows, GNU/Linux, (probably) MacOS, and there's even a Docker image.

Here's some output from downloading Never Gonna Give You Up: image

And here's the beginning of the logs for downloading Pink Floyd's Dark Side of the Moon, which is available in HiRes: image

Hey. I was going to check this out today. You still have to get a key manually for hires flac? Any hope to not have this hoop on a future?

Also, can you enable discussions on your project. Wanted to contact you there, but didn't want to spam "issues".

lsyyktv commented 8 months ago

R~YB1L2XGEFP3 190Q83G5S SO(}Q_8W{FJTSJ5_D8 VG45 _BSX2ZD%44J`PC2Z3VKEH55

The easiest way to get Qobuz,Tidal,KKBOX HIRES music,just paste command+url in TG group https://t.me/+cJf2sjtQeEpiZTI1

ebb-earl-co commented 8 months ago

Everyone, if you're still looking for a way to get HiRes, please check out my project, which is a fork of this project: https://github.com/ebb-earl-co/tidal-wave. I don't have a GUI yet, but command-line version works on Windows, GNU/Linux, (probably) MacOS, and there's even a Docker image. Here's some output from downloading Never Gonna Give You Up: image And here's the beginning of the logs for downloading Pink Floyd's Dark Side of the Moon, which is available in HiRes: image

Hey. I was going to check this out today. You still have to get a key manually for hires flac? Any hope to not have this hoop on a future?

Also, can you enable discussions on your project. Wanted to contact you there, but didn't want to spam "issues".

I've set up discussions! I hadn't known that that was a feature.

Separately, I don't have a good way of automating the HiRes FLAC process at the moment, because, according to the TIDAL supported devices page, the clients that can access HiRes FLAC are authenticated with username and password, like any other website. This is a different mechanism to the Fire TV and Android Auto clients' login mechanism, so unless I can find some API shenanigans, it might not be possible to automate those clients.

lkjdsf65 commented 1 month ago

¿paste command+url in TG group? What command?