Using GitHub actions to automatically back up the daily recommended songs of Netease cloud music

Time:2021-4-12

GitHub recently launched actions, which can be used to do a lot of fun things.

I have written a script before, which can save the songs recommended by Netease cloud music every day as a new song list, playing a backup role. But that script needs to be deployed on its own server and run all the time.

Today, it suddenly occurred to me that I can use GitHub’s actions function to run the script regularly every day for backup, so that I don’t need my own server and save maintenance.

GitHub project

NeteaseCloudMusicDayActions

Using the tutorial

  • Create a new warehouse on your own GitHub
  • Create /. GitHub / workflow in the warehouse/ day.yml
  • take day.yml Replace the phone and XXX in the password with your own Netease cloud account password
  • Wait for 1 hour after the first creation, and then the script will automatically run once every hour for detection. You can view the running record in the actions above the project

day.yml

Name: Netease cloud music daily push automatically creates song list

on:
  schedule:
    # * is a special character in YAML so you have to quote this string
    - cron:  '30 * * * *'

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    -Name: update to China time
      run: |
        sudo rm -rf /etc/localtime 
        sudo ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
        date
    -Name: install Netease cloud API
      run: git clone https://github.com/shanghaobo/NeteaseCloudMusicApi.git
    -Name: running Netease cloud API
      run: |
        cd NeteaseCloudMusicApi
        npm install
        nohup node app.js &
    -Name: install and edit script
      run: git clone https://github.com/shanghaobo/NeteaseCloudMusicDay.git
    -Name: set API
      run: echo "api='http://127.0.0.1:3000'" >> NeteaseCloudMusicDay/config.py
    -Name: set Netease cloud music login account
      run: echo "phone='xxxxxxxxxxx'" >> NeteaseCloudMusicDay/config.py
    -Name: set Netease cloud music login password
      run: echo "password='xxxxxx'" >> NeteaseCloudMusicDay/config.py
    -Name: run script
      run: python3 NeteaseCloudMusicDay/main2.py

Effect display

Using GitHub actions to automatically back up the daily recommended songs of Netease cloud music
Using GitHub actions to automatically back up the daily recommended songs of Netease cloud music

GitHub project address

https://github.com/shanghaobo…