Note: This incurs AWS charges. I am not liable for any damages or costs.
The spotify.py
is console based and manual. The lambda.py
is the lambda version of this. The spotify.yaml
is the AWS CloudFormation template which creates:
- DynamoDB (to store the Spotify track ID, track name, and artist name)
- EventBridge Rule (to Invoke the Lambda every 5-minutes)
- Lambda (basic Python code to get refresh token and get player)
- Log Group (for Lambda to write to, 3 day retention)
- Systems Manager Parameters (Spotify Client ID, Spotify Client Secret, and Refresh Token)
- IAM Role and relevant Policies so this can function (Lambda, CloudWatch, SSM, and SNS)
- SNS Topic/Subscription for any issues (haven't had my refresh token expire yet, so who knows)
- Get Spotify Refresh Token (get the URL w/ client id, get the token, get your first auth token)
- Upload Requests Lambda Layer
- Update the Systems Manager Parameters with the appropriate client ID, client secret, and refresh token
- Launch the Stack in AWS CloudFormation
- Confirm your e-mail (SNS Subscription)
- Complete
- Install AWS SAM
- sam build && sam deploy --guided
- https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ssm.html
- https://developer.spotify.com/documentation/general/guides/authorization/code-flow/
- https://developer.spotify.com/documentation/web-api/reference/#/operations/get-information-about-the-users-current-playback
- https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-resource-function.html
- https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit/blob/master/dm/templates/cloud_function/
- https://cloud.google.com/deployment-manager/docs/configuration/supported-resource-types
- https://registry.terraform.io/providers/hashicorp/google/4.39.0
This is a basic PowerShell to control Spotify's Player and get top track/artist report.
The functions...don't work, so keep that in mind.
Load PowerShell:
. .\spotify.ps1
- Authorization
- Paste in web browser
- Get token (grab from after access_token to &token_type)
- player MYTOKEN 100
- 100 is the volume
- Login to https://developer.spotify.com/dashboard/applications
- Create a new app or select existing app
- Copy the
Client ID
- Select
Show Client Secret
- Copy the
Client Secret
- Update the respective variables in
getRefreshToken
ofspotify.ps1
. .\spotify.ps1
to import the functions$result = getRefreshToken
- Copy the
$result.refreshToken
- Update AWS SSM Parameter with the value from step 9