-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathretrivinator.py
101 lines (77 loc) · 2.97 KB
/
retrivinator.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import json
import spotipy
from secrets import CLIENT_ID, CLIENT_SECRETS, USERNAME
from timemachininator import convert
import time
#fucntion tyme
# def setVolume():
# sp.next_track()
# fucntion tyme
def Volume():
sp.next_track()
def prevTrack():
sp.previous_track()
def skipTrack():
sp.next_track()
def pausePlayback():
sp.pause_playback()
def startPlayback():
sp.start_playback()
def getToken():
scope = 'user-read-playback-state user-modify-playback-state'
return spotipy.util.prompt_for_user_token(USERNAME, scope, client_id=CLIENT_ID,
client_secret=CLIENT_SECRETS, redirect_uri='https://github.com/TongueDaddy')
def getInfo():
currentTrack = current['item']
currentArtist = current['item']['artists'][0]
currentAlbum = current['item']['album']
progressTime = (round(current['progress_ms']/1000))
durationTime = (round(current['item']['duration_ms']/1000))
albumCover = current['item']['album']['images'][0]
volume = current['device']['volume_percent']
isShuffle = current['shuffle_state']
isRepeat = current['repeat_state']
print('Zack is now playing' + ' ' + currentTrack['name']) # track
print('by' + ' ' + currentArtist['name']) # artist
print('on' + ' ' + currentAlbum['name']) # album
print(convert(progressTime) + ' ' + '---' +
' ' + convert(durationTime)) # time
print(albumCover['url']) # picutre url
print('at' + ' ' + str(volume)) # how much luoud
print('shuffle=' + str(isShuffle) + ' ' + 'repeat=' +
str(isRepeat)) # shuffle and repeat state
if __name__ == "__main__":
token = getToken()
# sex time
if token:
sp = spotipy.Spotify(auth=token)
results = sp.currently_playing()
# add shuffle state, volume %, repeat state*
current = sp.current_playback()
if current is None or current['is_playing'] is not True:
print('hey we dont exist :O')
input('say something when you are playing otherwise ima just chill: ')
sp.start_playback()
# please start playing music when i want it to
# then look for what song is playing
with open('jason.json', 'w') as outfile:
json.dump(current, outfile)
getInfo() # this is info going to display
# while True:
# try:
# if keyboard.is_pressed('right arrow'): # keyboard controls
# sp.next_track()
# pass
# if keyboard.is_pressed('left arrow'):
# sp.previous_track()
# pass
# if keyboard.is_pressed('space'):
# try:
# sp.start_playback()
# pass
# except:
# sp.pause_playback()
# pass
# except:
# print('uh oh, theres an oopsies')
# break