yes.
This commit is contained in:
parent
a7178dd283
commit
9196cd8616
1 changed files with 12 additions and 23 deletions
35
main.py
35
main.py
|
@ -32,6 +32,8 @@ screen = RGBMatrix(options = options)
|
|||
|
||||
token = util.prompt_for_user_token(username, scope, client_id, client_secret, redirect_uri)
|
||||
|
||||
canvas = Image.new('RGB', (192, 128), color = 'red')
|
||||
|
||||
def get_track():
|
||||
print('getting info')
|
||||
sp = spotipy.Spotify(auth=token)
|
||||
|
@ -43,28 +45,11 @@ def get_track():
|
|||
response = requests.get(image_url)
|
||||
image = Image.open(BytesIO(response.content))
|
||||
print(image_url)
|
||||
#imageString = requests.get(track['item']['album']['images'][0]['url'])
|
||||
#image = Image.open(f)
|
||||
print('resizing image')
|
||||
image = image.resize((32,32))
|
||||
print(str(image))
|
||||
#return image
|
||||
#image.save("thumbnail.jpg","JPEG")
|
||||
print('set image')
|
||||
#image = Image.new('RGB', (32, 32), color = 'red')
|
||||
image = image.convert('RGB')
|
||||
#screen.SetImage(image, 10, 10)
|
||||
#screen.SetPixel(0,1,255,255,255)
|
||||
offset_x = 10
|
||||
offset_y = 10
|
||||
# for x in range(31):
|
||||
# for y in range(31):
|
||||
# r, g, b = image.getpixel((x, y))
|
||||
# screen.SetPixel(x+offset_x,y+offset_y,r,g,b)
|
||||
showImage(image)
|
||||
print('image set')
|
||||
return image
|
||||
|
||||
def showImage(image, offset_x = 0, offset_y = 0):
|
||||
image = image.convert('RGB')
|
||||
width, height = image.size
|
||||
for x in range(width):
|
||||
for y in range(height):
|
||||
|
@ -72,6 +57,7 @@ def showImage(image, offset_x = 0, offset_y = 0):
|
|||
screen.SetPixel(x+offset_x,y+offset_y,r,g,b)
|
||||
|
||||
|
||||
|
||||
#if token:
|
||||
# sp = spotipy.Spotify(auth=token)
|
||||
# track = sp.currently_playing()
|
||||
|
@ -82,20 +68,23 @@ def showImage(image, offset_x = 0, offset_y = 0):
|
|||
# image = image.resize((32,32))
|
||||
# #image.save("thumbnail.jpg","JPEG")
|
||||
#else:
|
||||
print("Can't get token for", username)
|
||||
# print("Can't get token for", username)
|
||||
def main():
|
||||
x = threading.Thread(target=get_track)
|
||||
x = threading.Thread(target=updateImage)
|
||||
x.start()
|
||||
|
||||
|
||||
def updateImage():
|
||||
print("text")
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
print('text')
|
||||
|
||||
while True:
|
||||
time.sleep(10)
|
||||
print('timed')
|
||||
showImage(canvas)
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue