mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
add unique_hash to CacheFileHandler and SpotifyOAuth
This commit is contained in:
parent
185140a812
commit
723b8f1c57
@ -51,6 +51,7 @@ class CacheFileHandler(CacheHandler):
|
|||||||
|
|
||||||
def __init__(self,
|
def __init__(self,
|
||||||
cache_path=None,
|
cache_path=None,
|
||||||
|
unique_hash=None,
|
||||||
username=None,
|
username=None,
|
||||||
encoder_cls=None):
|
encoder_cls=None):
|
||||||
"""
|
"""
|
||||||
@ -67,6 +68,8 @@ class CacheFileHandler(CacheHandler):
|
|||||||
self.cache_path = cache_path
|
self.cache_path = cache_path
|
||||||
else:
|
else:
|
||||||
cache_path = ".cache"
|
cache_path = ".cache"
|
||||||
|
if unique_hash:
|
||||||
|
cache_path += "-" + str(unique_hash)
|
||||||
username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"]))
|
username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"]))
|
||||||
if username:
|
if username:
|
||||||
cache_path += "-" + str(username)
|
cache_path += "-" + str(username)
|
||||||
|
|||||||
@ -13,6 +13,7 @@ import os
|
|||||||
import time
|
import time
|
||||||
import warnings
|
import warnings
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
import hashlib
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import urllib.parse as urllibparse
|
import urllib.parse as urllibparse
|
||||||
@ -349,8 +350,9 @@ class SpotifyOAuth(SpotifyAuthBase):
|
|||||||
else:
|
else:
|
||||||
username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"]))
|
username = (username or os.getenv(CLIENT_CREDS_ENV_VARS["client_username"]))
|
||||||
self.cache_handler = CacheFileHandler(
|
self.cache_handler = CacheFileHandler(
|
||||||
|
unique_hash=hashlib.sha256(client_secret.encode('utf-8')).hexdigest()[:7],
|
||||||
username=username,
|
username=username,
|
||||||
cache_path=cache_path
|
cache_path=cache_path,
|
||||||
)
|
)
|
||||||
self.proxies = proxies
|
self.proxies = proxies
|
||||||
self.requests_timeout = requests_timeout
|
self.requests_timeout = requests_timeout
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user