Open bachig26 opened 1 month ago
Cool idea! Though I can't imagine how would streaming music in python work.
We would need a module to play sounds and some logic to handle track streaming. I have tried something like this with Tidal Stream urls:
curl https://sp-ad-fa.audio.tidal.com/...0.mp4 -o track.flac
curl https://sp-ad-fa.audio.tidal.com/...1.mp4 >> track.flac
It starts playing track and its only 3 seconds long. Then for next track fragment:
curl https://sp-ad-fa.audio.tidal.com/...2.mp4 >> track.flac
It appends next bytes of track to file, but unfortunately we cant skip fragments.
Cool idea! Though I can't imagine how would streaming music in python work.
I found these not sure if exact ones,
Only https://github.com/godsic/vibe is for streaming music from Tidal but it is written in go. Other two are just Tidal API in python.
@oskvr37 a suggestion that i thought of while writing the issue #14.
as you can see from the log of one the downloads, the url from download.download
: https://sp-pr-fa.audio.tidal.com/mediatracks/CAEaKwgDEic5MzAwNzE1ZTQ0NDg0ZmJjOTY3MzFmNTIwZDBmMTdjMF82MS5tcDQ/0.flac?token=1722639450~M2VjODIzOTI2MDMwZTFhODk5YWM4NTY2ZDVjNDMwNWNiMGZmOTNmZQ==
is the stream. so we can feed this url directly to the mpv/vlc/mpc to start the playback.
in my case, i tried with the mpc-be
player.
as you have mentioned similar in the above comment, but i haven't seen any interruption as i have tried over 4-5 songs subsequently.
what do you think? i'm not sure, if this a safe way.
DEBUG Config.__init__ :: loading from file
DEBUG Config.update :: updated
DEBUG Config._save :: saved
DEBUG Config.update :: updated
DEBUG Config._save :: saved
INFO TIDDL.main :: saved settings to .tiddl_config.json
INFO TIDDL.main :: token expires in 4 days 3 hours
DEBUG TidalApi._request :: tracks/216149725 {'countryCode': 'NZ'}
DEBUG urllib3.connectionpool._new_conn :: Starting new HTTPS connection (1): api.tidal.com:443
DEBUG urllib3.connectionpool._make_request :: https://api.tidal.com:443 "GET /v1/tracks/216149725?countryCode=NZ HTTP/1.1" 200 1030
DEBUG TidalApi._request :: tracks/216149725/playbackinfo {'audioquality': 'HI_RES_LOSSLESS', 'playbackmode': 'STREAM', 'assetpresentation': 'FULL'}
DEBUG urllib3.connectionpool._make_request :: https://api.tidal.com:443 "GET /v1/tracks/216149725/playbackinfo?audioquality=HI_RES_LOSSLESS&playbackmode=STREAM&assetpresentation=FULL HTTP/1.1" 200 711
INFO TIDDL.downloadTrack :: BIBI - NABI :: High Quality - 16 bit 44.1 kHz
DEBUG download.downloadTrackStream :: application/vnd.tidal.bts
DEBUG download.download :: https://sp-pr-fa.audio.tidal.com/mediatracks/CAEaKwgDEic5MzAwNzE1ZTQ0NDg0ZmJjOTY3MzFmNTIwZDBmMTdjMF82MS5tcDQ/0.flac?token=1722639450~M2VjODIzOTI2MDMwZTFhODk5YWM4NTY2ZDVjNDMwNWNiMGZmOTNmZQ==
DEBUG urllib3.connectionpool._new_conn :: Starting new HTTPS connection (1): sp-pr-fa.audio.tidal.com:443
DEBUG urllib3.connectionpool._make_request :: https://sp-pr-fa.audio.tidal.com:443 "GET /mediatracks/CAEaKwgDEic5MzAwNzE1ZTQ0NDg0ZmJjOTY3MzFmNTIwZDBmMTdjMF82MS5tcDQ/0.flac?token=1722639450~M2VjODIzOTI2MDMwZTFhODk5YWM4NTY2ZDVjNDMwNWNiMGZmOTNmZQ== HTTP/1.1" 200 21574636
DEBUG download.downloadTrackStream :: flac
INFO TIDDL.downloadTrack :: track saved in E:\eNT\/BIBI - NABI.flac
I just thought since tidal app isn't what I expected in desktop version and on low-spec hardware, it pulls lot of ram memory.
Will there be an option to stream in future? With this current python package and possible future gui, it might be nice to have fast and all-in-one feature to have.