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)
|
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():
|
def get_track():
|
||||||
print('getting info')
|
print('getting info')
|
||||||
sp = spotipy.Spotify(auth=token)
|
sp = spotipy.Spotify(auth=token)
|
||||||
|
@ -43,28 +45,11 @@ def get_track():
|
||||||
response = requests.get(image_url)
|
response = requests.get(image_url)
|
||||||
image = Image.open(BytesIO(response.content))
|
image = Image.open(BytesIO(response.content))
|
||||||
print(image_url)
|
print(image_url)
|
||||||
#imageString = requests.get(track['item']['album']['images'][0]['url'])
|
|
||||||
#image = Image.open(f)
|
|
||||||
print('resizing image')
|
|
||||||
image = image.resize((32,32))
|
image = image.resize((32,32))
|
||||||
print(str(image))
|
return 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')
|
|
||||||
|
|
||||||
def showImage(image, offset_x = 0, offset_y = 0):
|
def showImage(image, offset_x = 0, offset_y = 0):
|
||||||
|
image = image.convert('RGB')
|
||||||
width, height = image.size
|
width, height = image.size
|
||||||
for x in range(width):
|
for x in range(width):
|
||||||
for y in range(height):
|
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)
|
screen.SetPixel(x+offset_x,y+offset_y,r,g,b)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#if token:
|
#if token:
|
||||||
# sp = spotipy.Spotify(auth=token)
|
# sp = spotipy.Spotify(auth=token)
|
||||||
# track = sp.currently_playing()
|
# track = sp.currently_playing()
|
||||||
|
@ -82,20 +68,23 @@ def showImage(image, offset_x = 0, offset_y = 0):
|
||||||
# image = image.resize((32,32))
|
# image = image.resize((32,32))
|
||||||
# #image.save("thumbnail.jpg","JPEG")
|
# #image.save("thumbnail.jpg","JPEG")
|
||||||
#else:
|
#else:
|
||||||
print("Can't get token for", username)
|
# print("Can't get token for", username)
|
||||||
def main():
|
def main():
|
||||||
x = threading.Thread(target=get_track)
|
x = threading.Thread(target=updateImage)
|
||||||
x.start()
|
x.start()
|
||||||
|
|
||||||
|
|
||||||
|
def updateImage():
|
||||||
|
print("text")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
print('text')
|
print('text')
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
time.sleep(10)
|
showImage(canvas)
|
||||||
print('timed')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue