Crawl and build M3U #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Crawl and build M3U | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| start: | |
| description: "Primer SID (incluido)" | |
| required: true | |
| default: "0" | |
| end: | |
| description: "Último SID (incluido)" | |
| required: true | |
| default: "999999" | |
| concurrency: | |
| description: "Tareas simultáneas, máximo 2048" | |
| required: true | |
| default: "2048" | |
| per_host: | |
| description: "Conexiones simultáneas por host" | |
| required: true | |
| default: "2048" | |
| max_rps: | |
| description: "Peticiones iniciadas por segundo" | |
| required: true | |
| default: "2048" | |
| acknowledge_load: | |
| description: "Para alta carga escribe I_HAVE_PERMISSION" | |
| required: false | |
| default: "I_HAVE_PERMISSION" | |
| publish: | |
| description: "Publicar output/ en la rama" | |
| type: boolean | |
| required: true | |
| default: true | |
| schedule: | |
| - cron: "17 3 * * 1" | |
| timezone: "Europe/Madrid" | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: samcloud-crawl | |
| cancel-in-progress: false | |
| jobs: | |
| crawl: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 330 | |
| env: | |
| SCHEDULED_START: ${{ vars.SAMCLOUD_START || '0' }} | |
| SCHEDULED_END: ${{ vars.SAMCLOUD_END || '9999' }} | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-python@v5 | |
| with: | |
| python-version: "3.12" | |
| cache: pip | |
| - run: python -m pip install --upgrade pip | |
| - run: python -m pip install . | |
| - name: Resolve inputs | |
| id: params | |
| shell: bash | |
| run: | | |
| if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then | |
| echo "start=${{ inputs.start }}" >> "$GITHUB_OUTPUT" | |
| echo "end=${{ inputs.end }}" >> "$GITHUB_OUTPUT" | |
| echo "concurrency=${{ inputs.concurrency }}" >> "$GITHUB_OUTPUT" | |
| echo "per_host=${{ inputs.per_host }}" >> "$GITHUB_OUTPUT" | |
| echo "max_rps=${{ inputs.max_rps }}" >> "$GITHUB_OUTPUT" | |
| echo "ack=${{ inputs.acknowledge_load }}" >> "$GITHUB_OUTPUT" | |
| else | |
| echo "start=$SCHEDULED_START" >> "$GITHUB_OUTPUT" | |
| echo "end=$SCHEDULED_END" >> "$GITHUB_OUTPUT" | |
| echo "concurrency=32" >> "$GITHUB_OUTPUT" | |
| echo "per_host=16" >> "$GITHUB_OUTPUT" | |
| echo "max_rps=8" >> "$GITHUB_OUTPUT" | |
| echo "ack=" >> "$GITHUB_OUTPUT" | |
| fi | |
| - name: Crawl | |
| run: | | |
| samcloud-m3u \ | |
| --start "${{ steps.params.outputs.start }}" \ | |
| --end "${{ steps.params.outputs.end }}" \ | |
| --concurrency "${{ steps.params.outputs.concurrency }}" \ | |
| --per-host "${{ steps.params.outputs.per_host }}" \ | |
| --max-rps "${{ steps.params.outputs.max_rps }}" \ | |
| --acknowledge-load "${{ steps.params.outputs.ack }}" \ | |
| --no-progress | |
| - name: Upload generated files | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: samcloud-m3u-${{ github.run_id }} | |
| path: | | |
| output/ | |
| data/stations.sqlite3 | |
| data/next_sid.txt | |
| retention-days: 30 | |
| - name: Publish output to repository | |
| if: github.event_name == 'workflow_dispatch' && inputs.publish | |
| shell: bash | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add output/ data/next_sid.txt | |
| git diff --cached --quiet && exit 0 | |
| git commit -m "Update generated SAM Cloud playlist" | |
| git push |