mirror of
https://github.com/Xevion/spotify-explicit.git
synced 2025-12-06 03:16:34 -06:00
main refreshing work
This commit is contained in:
22
main.py
22
main.py
@@ -7,6 +7,22 @@ import pull
|
||||
import process
|
||||
import logging
|
||||
|
||||
cache = json.load(open(os.path.join(sys.path[0], f'.cache-{auth.username}')))
|
||||
if time.time() > cache['expires_at']:
|
||||
pull.main()
|
||||
def main():
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
logging.info('Pulling data from Spotify')
|
||||
refresh()
|
||||
|
||||
|
||||
# Refreshes tracks from files if the token from Spotipy has expired,
|
||||
# thus keeping us up to date in most cases while keeping rate limits
|
||||
def refresh():
|
||||
file_path = os.path.join(sys.path[0], f'.cache-{auth.username}')
|
||||
if os.path.exists(file_path):
|
||||
cache = json.load(open(file_path, 'r'))
|
||||
if time.time() > cache['expires_at']:
|
||||
logging.info('Refreshing Spotify data by pulling tracks, this may take a moment.')
|
||||
pull.main()
|
||||
else:
|
||||
logging.info('Spotify data deemed to be recent enough (under {} seconds old)'.format(cache['expires_in']))
|
||||
|
||||
main()
|
||||
@@ -1,5 +1,13 @@
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
|
||||
def get_files():
|
||||
pass
|
||||
|
||||
def process_track_file(data):
|
||||
pass
|
||||
|
||||
def main():
|
||||
saved_response = json.load(open('saved_tracks.json', 'r'))
|
||||
for track in saved_response['items']:
|
||||
|
||||
Reference in New Issue
Block a user