mirror of https://github.com/afkcodes/zspotify.git
Fixed premium account check
This commit is contained in:
parent
8c2a83d51e
commit
ab2c64f84a
14
zspotify.py
14
zspotify.py
|
@ -28,7 +28,8 @@ ROOT_PATH = "ZSpotify Music/"
|
|||
SKIP_EXISTING_FILES = True
|
||||
MUSIC_FORMAT = "mp3" # or "ogg"
|
||||
FORCE_PREMIUM = False # set to True if not detecting your premium account automatically
|
||||
RAW_AUDIO_AS_IS = False # set to True if you wish you save the raw audio without re-encoding it.
|
||||
# set to True if you wish you save the raw audio without re-encoding it.
|
||||
RAW_AUDIO_AS_IS = False
|
||||
|
||||
# miscellaneous functions for general use
|
||||
|
||||
|
@ -93,7 +94,7 @@ def client():
|
|||
|
||||
token = SESSION.tokens().get("user-read-email")
|
||||
|
||||
if check_premium(token):
|
||||
if check_premium():
|
||||
print("### DETECTED PREMIUM ACCOUNT - USING VERY_HIGH QUALITY ###")
|
||||
QUALITY = AudioQuality.VERY_HIGH
|
||||
else:
|
||||
|
@ -259,13 +260,10 @@ def get_song_info(song_id):
|
|||
return artists, album_name, name, image_url, release_year, disc_number, track_number, scraped_song_id, is_playable
|
||||
|
||||
|
||||
def check_premium(access_token):
|
||||
def check_premium():
|
||||
global FORCE_PREMIUM
|
||||
""" If user has spotify premium return true """
|
||||
headers = {'Authorization': f'Bearer {access_token}'}
|
||||
resp = requests.get('https://api.spotify.com/v1/me',
|
||||
headers=headers).json()
|
||||
return bool(("product" in resp and resp["product"] == "premium") or FORCE_PREMIUM)
|
||||
return bool((SESSION.get_user_attribute("type") == "premium") or FORCE_PREMIUM)
|
||||
|
||||
|
||||
# Functions directly related to modifying the downloaded audio and its metadata
|
||||
|
@ -496,11 +494,13 @@ def download_from_user_playlist():
|
|||
|
||||
# Core functions here
|
||||
|
||||
|
||||
def checkRaw():
|
||||
global RAW_AUDIO_AS_IS, MUSIC_FORMAT
|
||||
if RAW_AUDIO_AS_IS:
|
||||
MUSIC_FORMAT = "raw"
|
||||
|
||||
|
||||
def main():
|
||||
""" Main function """
|
||||
checkRaw()
|
||||
|
|
Loading…
Reference in New Issue