Closed bascurtiz closed 5 years ago
Try to change raw_input to input
What version of python do you use?
Python 3.7.2
Did you try to change raw_input() to input()?
I did, and then it works!
But when trying to grab a playlist or album, I get this:
Try to use branch "python3", but don't forget this script uses wget
I will use python downloading using requests instead of wget, but I can't do it now
Awesome!
Just FYI: However, Search feature in your script is working with: browser = 'wdgaB1CilGA-S_s2' # Streams HIGH/LOW Quality over RTMP, FLAC and Videos over HTTP, but many Lossless Streams are encrypted. native = '4zx46pyr9o8qZNRw' # Same as Android Token, but FLAC streams are encrypted audirvana = 'BI218mwp9ERZ3PFI' # Like Android Token, supports MQA, but returns 'numberOfVideos = 0' in Playlists amarra = 'wc8j_yBJd20zOmx0' # Like Android Token, but returns 'numberOfVideos = 0' in Playlists token2 = 'oIaGpqT_vQPnTr0Q' # Like token1, but uses RTMP for HIGH/LOW Quality
Search feature in your script is NOT working with: token1 = 'P5Xbeo5LFvESeDy6' # Like Android Token, but returns 'numberOfVideos = 0' in Playlists token3 = '_KM2HixcUBZtmktH' # Same as token1 android = 'kgsOOmYk3zShYrNP' # All Streams are HTTP Streams. Correct numberOfVideos in Playlists ios = '_DSTon1kC8pABnTw' # Same as Android Token, but uses ALAC instead of FLAC
By default I use this token “audirvana = 'BI218mwp9ERZ3PFI' # Like Android Token, supports MQA, but returns 'numberOfVideos = 0' in Playlists”
Now script works, normally?
Only, the search function.
No, if you want to work with python3 you need to grab script from this repository from branch “python3”
OK, I understood. I have the same problem, I will fix it after I charge my laptop.
\o/
Try to add this function def download(url, file_name): with open(file_name, "wb") as file: response = get(url)
, this to start of file from requests import get
. And then replace os.system('wget "'+url+'" -O "music/'+name+'.flac"') os.system('wget "'+track.album.image+'" -O "music/'+name+'.png"')
with download(url, 'music/'+name+'.flac') download(track.album.image, name+'.png')
I wrote this from my phone
# -*- coding: utf-8 -*-
# vim:fileencoding=utf-8
import tidalapi
from transliterate import translit
import os
from mutagen.flac import Picture, FLAC
from requests import get
session = tidalapi.Session(tidalapi.Config('LOSSLESS'))
session._config.api_token='BI218mwp9ERZ3PFI'
session.login('xxx@xxx.com', 'xxx')
def download(url, file_name):
with open(file_name, "wb") as file: response = get(url)
def start():
mode = input("Mode: \n 1) Playlist grabber\n 2) Track grabber\n 3) Album grabber\n 4) Search \n")
if int(mode) == 1:
playlist_id = input("Enter playlist id: ")
playlist = session.get_playlist_tracks(playlist_id=playlist_id)
for track in playlist:
download_flac(track)
want_start()
elif int(mode) == 2:
track_id = input("Enter track id: ")
track = session._map_request('tracks/'+str(track_id), params={'limit': 100}, ret='tracks')
download_flac(track)
want_start()
elif int(mode) == 3:
album_id = input("Enter album id: ")
album = session.get_album_tracks(album_id=album_id)
for track in album:
download_flac(track)
want_start()
elif int(mode) == 4:
search_query = input("Enter search query: ")
search = session.search(field='track', value=search_query)
for track in search.tracks:
print(track.artist.name+" - "+track.name+": "+str(track.id))
want_start()
else:
print("Incorrect mode!")
start()
def download_flac(track):
url = session.get_media_url(track_id=track.id)
name = translit(""+track.name, "ru", reversed=True)
artist_name = translit(""+track.artist.name, "ru", reversed=True)
album_name = translit(""+track.album.name, "ru", reversed=True)
releaseDate = str(track.album.release_date)
print(name+' - '+url)
album_artist = translit(u""+track.album.artist.name, "ru", reversed=True).encode("UTF-8")
print('wget "'+url+'" -O "music/'+name+'.flac"')
download(url, 'music/'+name+'.flac')
download(track.album.image, name+'.png')
audio = FLAC("music/"+name+".flac")
albumart = "music/"+name+".png"
image = Picture()
image.type = 3
mime = 'image/png'
image.desc = 'front cover'
with open(albumart, 'rb') as f: # better than open(albumart, 'rb').read() ?
image.data = f.read()
audio['artist'] = artist_name
audio['title'] = name
audio['album'] = album_name
audio['date'] = releaseDate
audio.add_picture(image)
audio.save()
os.remove("music/"+name+".png")
def want_start():
want = input("Do you want to continue [0/1]: ")
if want == "1":
start()
elif want == "0":
print("OK!")
else:
want_start()
start()
#playlist = session.get_playlist_tracks(playlist_id='004a984e-6f9e-44ed-a447-9c3dd4b0405f')
#for track in playlist:
# url = session.get_media_url(track_id=track.id)
# name = translit(u""+track.name, "ru", reversed=True).encode("UTF-8")
# print(name+' - '+url)
# os.system('wget "'+url+'" -O "music/'+name+'.flac"'.encode('utf-8'))
Use new update of python3
python3 branch
Works! Thank you =)
Will test playlist too.
OK, can I close this issue?
Let's. And focus on playlist, cause it errors after a bit.
After fixing the indents in tidal.py with PyCharm, changing the token to a working one, using my own login credentials, i get this:
Any idea?