Skip to content

Music-trends

Music-trends #1124

Workflow file for this run

name: Music-trends
# Controls when the action will run.
on:
schedule:
- cron: "09 14 * * *" # At 14:09 everyday.
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "music"
music:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: Update & install curl, iconv & jq
run: sudo apt update && sudo apt-get install libxml2-utils curl libc-bin jq -y
- name: Get acces to spotify api
run: |
curl -s -X "POST" -H "Authorization: Basic ${{ secrets.SPOTIFY_API }}" -d grant_type=client_credentials https://accounts.spotify.com/api/token | jq '.access_token' | tr -d '"' > token
- name: Grab artist
run: |
curl -s "https://kma.kkbox.com/charts/api/v1/daily?category=390&date=$(date --date=yesterday --iso-8601)&lang=en&limit=50&terr=sg&type=newrelease" | jq '.data.charts.newrelease[].artist_name' | tr -d '"' | sed 's/, /\n/g' > artists_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZEVXbMDoHDwVN2tF/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.artists[].name' | tr -d '"' >> artists_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DX4HGSmd79ENf/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.artists[].name' | tr -d '"' >> artists_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZEVXbIPWwFssbupI/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.artists[].name' | tr -d '"' >> artists_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/1kEdw1CTrPTyrsW6LOS3qV/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.artists[].name' | tr -d '"' >> artists_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DXcBWIGoYBM5M/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.artists[].name' | tr -d '"' >> artists_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DWVuV87wUBNwc/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.artists[].name' | tr -d '"' >> artists_temp
- name: Grab album
run: |
curl -s "https://kma.kkbox.com/charts/api/v1/daily?category=390&date=$(date --date=yesterday --iso-8601)&lang=en&limit=50&terr=sg&type=newrelease" | jq '.data.charts.newrelease[].album_name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' > albums_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZEVXbMDoHDwVN2tF/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' >> albums_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DX4HGSmd79ENf/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' >> albums_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZEVXbIPWwFssbupI/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' >> albums_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/1kEdw1CTrPTyrsW6LOS3qV/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' >> albums_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DXcBWIGoYBM5M/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' >> albums_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DWVuV87wUBNwc/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.album.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' >> albums_temp
- name: Grab song name
run: |
curl -s "https://kma.kkbox.com/charts/api/v1/daily?category=390&date=$(date --date=yesterday --iso-8601)&lang=en&limit=50&terr=sg&type=newrelease" | jq '.data.charts.newrelease[].song_name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' > songs_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZEVXbMDoHDwVN2tF/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' >> songs_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DX4HGSmd79ENf/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' >> songs_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZEVXbIPWwFssbupI/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' >> songs_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/1kEdw1CTrPTyrsW6LOS3qV/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' >> songs_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DXcBWIGoYBM5M/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' >> songs_temp
curl -s -X "GET" "https://api.spotify.com/v1/playlists/37i9dQZF1DWVuV87wUBNwc/tracks" -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $(cat token)" | jq '.items[].track.name' | tr -d '"' | sed 's/(/\n/g' | tr -d ')' | sed 's/,/\n/g' | sed 's/ - /\n/g' >> songs_temp
- name: Permutations options artists
run: |
cat artists_temp | awk '{print tolower($0)}' > artists_lower;
cat artists_temp | awk '{print toupper($0)}' > artists_upper;
sed "s/ //g" artists_temp > artists_nospaces;
sed "s/-//g" artists_temp > artists_nodash;
sed "s/'//g" artists_temp > artists_quote;
sed 'y/ÖöËÇçÀāáǎàëēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀÉĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛÏÜ/OoECcAaaaaeeeeeiiiioooouuuuuuuuAAAAEEEEEIIIIOOOOUUUUUUUUIU/' artists_temp artists_lower artists_quote artists_upper artists_nodash artists_nospaces > artists_noaccent;
- name: Permutations options albums
run: |
cat albums_temp | awk '{print tolower($0)}' > artists_lower;
cat albums_temp | awk '{print toupper($0)}' > artists_upper;
sed "s/ //g" albums_temp > artists_nospaces;
sed "s/-//g" albums_temp > artists_nodash;
sed "s/'//g" albums_temp > artists_quote;
sed 'y/ÖöËÇçÀāáǎàëēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀÉĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛÏÜ/OoECcAaaaaeeeeeiiiioooouuuuuuuuAAAAEEEEEIIIIOOOOUUUUUUUUIU/' artists_quote artists_nodash artists_nospaces artists_upper artists_lower albums_temp > albums_noaccent;
- name: Permutations options songs
run: |
cat songs_temp | awk '{print tolower($0)}' > songs_lower;
cat songs_temp | awk '{print toupper($0)}' > songs_upper;
sed "s/ //g" songs_temp > songs_nospaces;
sed "s/-//g" songs_temp > songs_nodash;
sed "s/'//g" songs_temp > songs_quote;
sed 'y/ÖöËÇçÀāáǎàëēéěèīíǐìōóǒòūúǔùǖǘǚǜĀÁǍÀÉĒÉĚÈĪÍǏÌŌÓǑÒŪÚǓÙǕǗǙǛÏÜ/OoECcAaaaaeeeeeiiiioooouuuuuuuuAAAAEEEEEIIIIOOOOUUUUUUUUIU/' songs_quote songs_nodash songs_nospaces songs_upper songs_lower songs_temp > songs_noaccent;
- name: Run sort and uniq
run: |
cat artists* >> pourquoit_artists;LC_ALL=C sort -u pourquoit_artists > artists; ls -la; wc -l artists*;
cat albums* >> pourquoit_albums;LC_ALL=C sort -u pourquoit_albums > albums; ls -la; wc -l albums*;
cat songs* >> pourquoit_songs;LC_ALL=C sort -u pourquoit_songs > songs; ls -la; wc -l songs*;
# Runs a set of commands using the runners shell
- name: Git commit and push
run: |
git config user.name "Music-bot"
git config user.email ""
git add artists albums songs
git commit -m "[Bot] Music trends from $(date +'%Y_%m_%d')"
git push origin master