Giter Site home page Giter Site logo

cosoradio's Introduction

CoSoRadio

Scrapes counter.social firehose for posts using the #CoSoMusic hashtag. For each one, ff they have a YouTube link as well, get the Title (and tags, if any) from the YouTube video and then add the song to a public Spotify playlist and share it out on CoSo.

TechStack

Language: Golang

APIs: Spotify, YouTube, counter.social

Runs: Locally (for now). Due to OAuth authentication scheme, you're forced through a web login. There's no way to do a "headless" API integration with spotify that I've found yet. More research needed into that for both Spotify, Google & CoSo APIs.

Build and Run

$ cd cmd
$ go build .
$ GOOGLE_ID=<GOOGLE ID> \
  GOOGLE_SECRET=<GOOGLE SECRET> \
  SPOTIFY_ID=<SPOTIFY ID> \
  SPOTIFY_SECRET=<SPOTIFY SECRET> \
  COSO_CLIENT_KEY=<COSO CLIENT KEY/ID> \
  COSO_CLIENT_SECRET=<COSO CLIENT SECRET> \
  CSM_MAKE_PLAYLIST=true \
  CSM_DO_TOOT=true \
  CSM_SCRAPE_COSO=true \
  ./cmd

Workflow

  1. Auth to Spotify and create Spotify Client
  2. Auth to Google and create Google API Service
  3. Pull music from source
    • Currently just uses the CoSo timeline public API. The search API isn't returning results when searching for statuses.
    • Currently only getting the latest 40. Eventually if I can get the search API working, I can page through results since the last time/status ID and get more.
  4. Given the slice of Song objects, take the YouTubeUrl, look it up with the YouTube API, and get the title and tags from the video and add them to the correct Song object.
  5. Create an empty Spotify playlist
  6. For each Song, search for the Title + First Tag in Spotify
  7. Add the resulting songs to the playlist
  8. Post the Spotify Playlist to CoSo as #CoSoRadio

Run this once a day. Eventually I'll see if I can't get it running once a day as a cloud function in GCP.

Required Envs

  • SPOTIFY_ID : The spotify ID [App set up with a redirect url of http://localhost:8080/callback]
  • SPOTIFY_SECRET : The spotify Secret
  • GOOGLE_ID : Google API Key ID [Oauth2 with scope to read only from youtube api]
  • GOOGLE_SECRET: Google API Secret
  • COSO_CLIENT_KEY : Counter.social API Key (In documentation referred to as client id)
  • COSO_CLIENT_SECRET : Counter.social API Secret

Options

  • CSM_MAKE_PLAYLIST : when =true will make the spotify playlist. Defaults to false
  • CSM_DO_TOOT : when =true will send the toot to coso. Only will post to CoSo if the playlist is crated too. Defaults to false.
  • CSM_SCRAPE_COSO : when =true will scrape coso for #CoSoMusic hashtag for the previous day. when =false will pull from /cmd/Fixtures/songs.json. Defaults to false.

cosoradio's People

Contributors

jasondborneman avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.