├── .github └── workflows │ └── container-build-publishing.yml ├── .last_upstream_tag ├── Dockerfile ├── LICENSE └── README.md /.github/workflows/container-build-publishing.yml: -------------------------------------------------------------------------------- 1 | name: Check Tag & Build 2 | 3 | # This workflow uses actions that are not certified by GitHub. 4 | # They are provided by a third-party and are governed by 5 | # separate terms of service, privacy policy, and support 6 | # documentation. 7 | 8 | on: 9 | schedule: 10 | - cron: '0 * * * *' # 每小时检查一次 11 | push: 12 | branches: 13 | - main # 选择你想要的分支 14 | 15 | env: 16 | # Use docker.io for Docker Hub if empty 17 | REGISTRY: ghcr.io 18 | # github.repository as / 19 | IMAGE_NAME: ${{ github.repository }} 20 | 21 | 22 | jobs: 23 | check-tag: 24 | runs-on: ubuntu-latest 25 | outputs: 26 | trigger: ${{ steps.if_new_tag.outputs.new_tag }} 27 | steps: 28 | - name: Checkout This Repository 29 | uses: actions/checkout@v4 30 | 31 | - name: Set up Git 32 | run: | 33 | git config --global user.name 'github-actions[bot]' 34 | git config --global user.email 'github-actions[bot]@users.noreply.github.com' 35 | 36 | - name: Check Latest Tag from Upstream 37 | id: check_tag 38 | run: | 39 | UPSTREAM_LATEST_TAG=$(npm show musicn version | head -n 1) 40 | echo "Latest upstream tag: $UPSTREAM_LATEST_TAG" 41 | echo "latest_tag=$UPSTREAM_LATEST_TAG" >> $GITHUB_ENV 42 | 43 | - name: Check Last Processed Tag 44 | id: check_last_tag 45 | run: | 46 | if [ -f .last_upstream_tag ]; then 47 | LAST_PROCESSED_TAG=$(cat .last_upstream_tag) 48 | echo "Last processed tag: $LAST_PROCESSED_TAG" 49 | else 50 | LAST_PROCESSED_TAG="none" 51 | echo "No last processed tag found." 52 | fi 53 | echo "last_tag=$LAST_PROCESSED_TAG" >> $GITHUB_ENV 54 | 55 | - name: Compare Tags 56 | id: if_new_tag 57 | if: ${{ env.latest_tag != env.last_tag }} 58 | run: | 59 | echo "New tag detected: ${latest_tag}" 60 | echo "new_tag=true" >> "$GITHUB_OUTPUT" 61 | 62 | - name: Save Last Processed Tag 63 | if: ${{ env.latest_tag != env.last_tag }} 64 | run: echo ${latest_tag} > .last_upstream_tag 65 | 66 | - name: Commit and Push Last Processed Tag 67 | if: ${{ env.latest_tag != env.last_tag }} 68 | run: | 69 | git add .last_upstream_tag 70 | git commit -m "Update last processed upstream tag to ${latest_tag}" 71 | git push 72 | 73 | 74 | build: 75 | needs: check-tag 76 | runs-on: ubuntu-latest 77 | if: needs.check-tag.outputs.trigger == 'true' 78 | permissions: 79 | contents: read 80 | packages: write 81 | # This is used to complete the identity challenge 82 | # with sigstore/fulcio when running outside of PRs. 83 | id-token: write 84 | 85 | steps: 86 | - name: Checkout repository 87 | uses: actions/checkout@v4 88 | 89 | - name: Setup Node.js 90 | uses: actions/setup-node@v4 91 | with: 92 | node-version: 'latest' 93 | 94 | - name: Get Latest Tag from Upstream 95 | id: get_tag 96 | run: | 97 | UPSTREAM_LATEST_TAG=$(npm show musicn version | head -n 1) 98 | echo "Latest upstream tag: $UPSTREAM_LATEST_TAG" 99 | echo "latest_tag=$UPSTREAM_LATEST_TAG" >> $GITHUB_ENV 100 | 101 | - name: Set up QEMU 102 | uses: docker/setup-qemu-action@v3 103 | with: 104 | platforms: all 105 | 106 | - name: Setup Docker buildx 107 | uses: docker/setup-buildx-action@v3 108 | 109 | # Login against a Docker registry except on PR 110 | # https://github.com/docker/login-action 111 | - name: Log into registry ${{ env.REGISTRY }} 112 | if: github.event_name != 'pull_request' 113 | uses: docker/login-action@v3 114 | with: 115 | registry: ${{ env.REGISTRY }} 116 | username: ${{ github.actor }} 117 | password: ${{ secrets.GITHUB_TOKEN }} 118 | 119 | # Extract metadata (tags, labels) for Docker 120 | # https://github.com/docker/metadata-action 121 | - name: Extract Docker metadata 122 | id: meta 123 | uses: docker/metadata-action@v5 124 | with: 125 | images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} 126 | flavor: | 127 | latest=true 128 | tags: | 129 | type=raw,value=${{ env.latest_tag }} 130 | 131 | # Build and push Docker image with Buildx (don't push on PR) 132 | # https://github.com/docker/build-push-action 133 | - name: Build and push Docker image 134 | id: build-and-push 135 | uses: docker/build-push-action@v6 136 | with: 137 | builder: ${{ steps.buildx.outputs.name }} 138 | context: . 139 | platforms: linux/amd64,linux/arm64 140 | push: true 141 | tags: ${{ steps.meta.outputs.tags }} 142 | labels: ${{ steps.meta.outputs.labels }} -------------------------------------------------------------------------------- /.last_upstream_tag: -------------------------------------------------------------------------------- 1 | 1.5.3-beta.0 2 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM node:alpine 2 | 3 | WORKDIR /data 4 | 5 | RUN apk add --no-cache tini \ 6 | && npm i musicn -g \ 7 | && rm -rf ${HOME}/.npm 8 | 9 | ENTRYPOINT ["/sbin/tini", "--"] -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 wy580477 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## 鸣谢 2 | 3 | - [zonemeen/musicn](https://github.com/zonemeen/musicn) 4 | 5 | ## 概述 6 | 7 | 可播放及下载音乐的命令行工具 [musicn](https://github.com/zonemeen/musicn) 的容器版本,支持 amd64/arm64 架构。 8 | 9 | 目前已不能下载无损格式。 10 | 11 | ![image](https://user-images.githubusercontent.com/98247050/230909773-52d95ba7-e42e-4612-86dd-7cb363bc3f2f.png) 12 | 13 | 14 | ## 部署 15 | 16 | 命令行 + Web 模式 17 | ``` 18 | docker run -d --name=musicn --restart=unless-stopped -v ${PWD}/musicn:/data -p 7478:7478 ghcr.io/wy580477/musicn-container:latest msc -q 19 | ``` 20 | 仅命令行模式 (空闲时几乎不耗内存) 21 | ``` 22 | docker run -d --name=musicn --restart=unless-stopped -v ${PWD}/musicn:/data ghcr.io/wy580477/musicn-container:latest tail -f 23 | ``` 24 | ${PWD}/musicn 为命令行模式下载文件存放目录,默认当前目录下 musicn 文件夹。 25 | 26 | 执行 musicn 命令: 27 | 28 | ``` 29 | docker exec -it musicn msc 周杰伦 30 | 31 | # 设置 bash 命令别名方便使用,重新登陆 shell 后生效 32 | echo "alias msc='docker exec -it musicn msc'" >> ~/.bashrc 33 | 34 | # 查看命令帮助 35 | msc -h 36 | 37 | # 指定子目录 test 为下载目录 38 | msc 周杰伦 -p ./test 39 | 40 | # 升级版本 41 | docker container rm musicn --force && docker pull ghcr.io/wy580477/musicn-container:latest 42 | # 然后重新执行安装命令 43 | 44 | # 容器内升级 (不推荐,万一我以后弃坑不更新 image 版本,可以用这个方法更新) 45 | docker exec -it musicn npm i musicn -g 46 | ``` 47 | 更多命令用法详见: [musicn 文档](https://github.com/zonemeen/musicn#%E6%90%9C%E7%B4%A2%E7%9A%84%E9%A1%B5%E7%A0%81%E6%95%B0%E9%BB%98%E8%AE%A4%E6%98%AF%E7%AC%AC1%E9%A1%B5) 48 | 49 | 访问 http://<宿主机 ip>:7478 可到达 Web 搜索和下载界面。(扫码访问功能不可用, 请手动输入网址访问) 50 | 51 | ![image](https://user-images.githubusercontent.com/98247050/230908384-99c5d283-26f6-4a9b-aa9f-104ccf7e4702.png) 52 | 53 | ### Docker-Compose 部署 54 | 命令行 + Web 模式 55 | ``` 56 | version: '3.4' 57 | services: 58 | 59 | musicn: 60 | image: ghcr.io/wy580477/musicn-container:latest 61 | container_name: musicn 62 | restart: unless-stopped 63 | entrypoint: ["/sbin/tini", "--", "msc", "-q"] 64 | ports: 65 | - "7478:7478" 66 | volumes: 67 | - ./musicn:/data 68 | ``` 69 | 70 | 仅命令行模式 71 | ``` 72 | version: '3.4' 73 | services: 74 | 75 | musicn: 76 | image: ghcr.io/wy580477/musicn-container:latest 77 | container_name: musicn 78 | restart: unless-stopped 79 | entrypoint: ["/sbin/tini", "--", "tail", "-f"] 80 | volumes: 81 | - ./musicn:/data 82 | ``` 83 | 84 | --------------------------------------------------------------------------------