Python beginners hit the unofficial API of Google Play Music to play music Continuation of the post (something like)
・ I want to be able to play music without permission → Use the station ・ Make the next song play freely
・ You can get stations with API called get_all_stations of Mobile client of gmusicapi. ・ Display the acquired stations in a list for the time being ・ Select the station you want to play from the list ·Play music
-Set the playback command input with a time limit. Create wait_input as a wrapper for built-in input -Obtain the song length from the song information and use it as the input time limit. ・ If time-out occurs, break the loop and move to the next song.
def wait_input(ms):
import signal
def timeout():
raise RuntimeError("end")
signal.signal(signal.SIGALRM, timeout)
signal.alarm(ms // 1000)
try:
key = input('>>')
except:
key = 'n'
finally:
signal.alarm(0)
return key
Referenced Simple key input with time out on python. Key input with timeout.
-Since the time limit timer cannot be stopped when pausing, it may be better to change the implementation method.
https://github.com/johejo/gpm2/blob/master/station_player.py
Recommended Posts