Skip to content

Check torrents

Check torrents #1624

name: Check torrents
on:
workflow_dispatch:
workflow_run:
workflows: ['Update SubsPlease database']
types: [completed]
permissions:
contents: write
actions: write # require to delete cache
jobs:
database-check:
name: Verify database
runs-on: ubuntu-latest
env:
anilist-cache: anilist_cache
python-cache: python_cache
steps:
- name: Checkout current code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Determine Python version
id: python_version
run: |
full_version=$(python --version | cut -d' ' -f2)
major_version=$(echo $full_version | grep -oE '^[^.]+.[^.]+')
echo "::set-output name=full_version::$full_version"
echo "::set-output name=major_version::$major_version"
- name: Restore Python Cache
id: python-restore
uses: actions/cache/restore@v3
with:
fail-on-cache-miss: true
path: /opt/hostedtoolcache/Python/${{ steps.python_version.outputs.full_version }}/x64/lib/python${{ steps.python_version.outputs.major_version }}/site-packages
key: ${{ env.python-cache }}
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install alfetcher beautifulsoup4 pynyaasi
- name: Restore AniList Cache
continue-on-error: false
id: anilist-restore
uses: actions/cache/restore@v3
with:
path: /opt/hostedtoolcache/Python/${{ steps.python_version.outputs.full_version }}/x64/lib/python${{ steps.python_version.outputs.major_version }}/site-packages/alfetcher/cache
key: ${{ env.anilist-cache }}
restore-keys: |
${{ env.anilist-cache }}
- name: Check torrent links
shell: bash
env:
ANILIST_KEY: ${{ secrets.ANILIST_KEY }}
run: |
export anilist_key="$ANILIST_KEY"
python torrent_verification.py
- name: Delete Previous Cache
if: ${{ steps.anilist-restore.outputs.cache-hit }}
continue-on-error: true
run: |
gh extension install actions/gh-actions-cache
gh actions-cache delete "${{ env.anilist-cache }}" --confirm
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Save Cache
uses: actions/cache/save@v3
with:
path: /opt/hostedtoolcache/Python/${{ steps.python_version.outputs.full_version }}/x64/lib/python${{ steps.python_version.outputs.major_version }}/site-packages/alfetcher/cache
key: ${{ env.anilist-cache }}