[PYTHON] Play music by hitting the unofficial API of Google Play Music

Overview

Python beginners hit the unofficial API of Google Play Music to play music Continuation of the post (something like)

What I wanted to do in addition to the previous content

・ I want to be able to play music without permission → Use the station ・ Make the next song play freely

About the station

・ 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

About moving to the next song

-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.

problem

-Since the time limit timer cannot be stopped when pausing, it may be better to change the implementation method.

Source code

https://github.com/johejo/gpm2/blob/master/station_player.py

Recommended Posts

Play music by hitting the unofficial API of Google Play Music
Python beginners hit the unofficial API of Google Play Music to play music
Play by hitting the Riot Games API in Python First half
Judge the authenticity of posted articles by machine learning (Google Prediction API).
Get the image of "Suzu Hirose" by Google image search.
About the camera change event of Google Maps Android API
The story of creating a database using the Google Analytics API
Read English sentences by hitting Google Translate API with Python without using the distributed module
The google search console sitemap api client is in webmasters instead of search console
Explains JavaScript of Google Maps Geocoding API
Get the minutes of the Diet via API
Pandas of the beginner, by the beginner, for the beginner [Python]
Get holidays with the Google Calendar API
Try hitting the YouTube API in Python
Play with puns using the COTOHA API
Try hitting the Spotify API in Django.
[Python] Automatically totals the total number of articles posted by Qiita using the API
The format of the message obtained by Slack API is subtly difficult to use
Check the operation of OpenCV3 installed by Anaconda
I tried hitting the Qiita API from go
Sort the elements of the array by specifying the conditions
I tried using the Google Cloud Vision API
I tried to touch the API of ebay
How to use the Google Cloud Translation API
Until you can use the Google Speech API
Minimize the number of polishings by combinatorial optimization
Search by the value of the instance in the list
Download the csv file created by Google Colaboratory
Investigation of the relationship between speech preprocessing and transcription accuracy in the Google Cloud Speech API
The format of the message obtained by Slack API is subtly difficult to use
Play music by hitting the unofficial API of Google Play Music
Python beginners hit the unofficial API of Google Play Music to play music
Try to scrape as much as you can scrape the sample program of Google Spreadsheet API (v4) quick start