# gh-actions workflow to download from magnet links # Usage # 1. Place this file within .github/workflows in your GitHub repo and push. # 2. Select this workflow from the Repo Actions tab, select Run Workflow, # add your Magnet URI(s), and wait a little while. # # This workflow produces a build artifact that contains URLs pointing to # sequential *.tar.gz chunks you can download non-interactively with # 'wget -i download.txt -O - | tar -xzv'. # Catbox links and GitHub artifacts expire in 72 hours. # # Notes # catbox.moe is used to fully utilize runner disk space limit of ~25GiB. # actions/upload-artifact@v2 zips before uploading, reducing maximum effective # space to ~12GiB if files were to be delivered as a build artifact. name: Magnet Download by Proxy on: workflow_dispatch: inputs: MAGNET_URI: type: string required: true description: Magnet Link/URI(s) SEED_MODE: type: boolean required: true default: true description: Continue seeding after downloading? jobs: Download: runs-on: ubuntu-latest env: MAGNET: ${{ github.event.inputs.MAGNET_URI }} ARIA2C: aria2c -d dl --disable-ipv6 --force-sequential steps: - name: Install prerequisite(s) run: sudo apt-get install -y aria2 pigz - name: Download file(s) run: | mkdir dl $ARIA2C --seed-time=0 $MAGNET - name: Tarball file(s) in place run: | mkdir parts tar --remove-files -cv dl/ \ | pigz -1 | split -db 1000M - parts/file.tar.gz. - name: Upload tarball chunk(s) to litterbox.catbox.moe run: | for f in parts/*; do curl -f --retry 10 --retry-delay 60 \ -F 'reqtype=fileupload' -F 'time=72h' -F "fileToUpload=@$f" \ 'https://litterbox.catbox.moe/resources/internals/api.php' printf '\n' done | tee /dev/stderr > download.txt printf '\n\e[1m%s\e[0m\n' 'Download List' cat download.txt - name: Upload file URL list as artifact uses: actions/upload-artifact@v2 with: name: artifact path: download.txt retention-days: 3 - name: Seed after downloading (end workflow to obtain artifact) if: ${{ github.event.inputs.SEED_MODE == 'true' }} run: | for f in parts/*; do cat "$f"; rm "$f" done | pigz -d | tar -xv $ARIA2C -V -c $MAGNET || :