Update Torrent Websites URL #610
This file contains 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: Update Torrent Websites URL | |
on: | |
schedule: | |
- cron: "45 11 * * *" | |
workflow_dispatch: | |
jobs: | |
update-url: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Update YGGTorrent URL | |
run: | | |
OLD_YGG=$(grep -Po "url = '\K[^']+" yggtorrent.py) | |
echo "fetched old url $OLD_YGG" | |
NEW_YGG=$(curl -Ls -o /dev/null -w %{url_effective} $OLD_YGG) | |
NEW_YGG=${NEW_YGG%/} | |
echo "fetched new url $NEW_YGG" | |
if [[ $OLD_YGG == $NEW_YGG ]] | |
then | |
echo "WARNING: URL didn't changed since last time" | |
exit | |
fi | |
NEW_STATUS=$(curl -s -o /dev/null -w %{http_code} $NEW_YGG) | |
echo "fetched new status $NEW_STATUS" | |
if [[ $NEW_STATUS != 000 ]] | |
then | |
find . -type f -exec sed -i "s,$OLD_YGG,$NEW_YGG,g" {} + | |
echo "SUCCESS: $OLD_YGG replaced with $NEW_YGG" | |
MINVER=$(grep -Po "#VERSION: [0-9]+\.\K[0-9]+" yggtorrent.py) | |
sed -i "s,#VERSION: \([0-9]\+\)\.$MINVER,#VERSION: \1\.$((MINVER+1))," yggtorrent.py | |
echo "SUCCESS: Minor version $MINVER incremented" | |
git config --global user.name 'CravateRouge' | |
git config --global user.email '[email protected]' | |
git commit -am "Automated url update from $OLD_YGG to $NEW_YGG" | |
git push | |
else | |
echo "ERROR: new url $NEW_YGG returns status $NEW_STATUS. Update Canceled" | |
exit 1 | |
fi | |
- name: Update OxTorrent URL | |
run: | | |
OLD_OX=$(grep -Po "url = '\K[^']+" oxtorrent.py) | |
echo "fetched old url $OLD_OX" | |
NEW_OX=$(curl -Ls -o /dev/null -w %{url_effective} $OLD_OX) | |
NEW_OX=${NEW_OX%/} | |
echo "fetched new url $NEW_OX" | |
if [[ $OLD_OX == $NEW_OX ]] | |
then | |
echo "WARNING: URL didn't changed since last time" | |
exit | |
fi | |
NEW_STATUS=$(curl -s -o /dev/null -w %{http_code} $NEW_OX) | |
echo "fetched new status $NEW_STATUS" | |
if [[ $NEW_STATUS != 000 ]] | |
then | |
find . -type f -exec sed -i "s,$OLD_OX,$NEW_OX,g" {} + | |
echo "SUCCESS: $OLD_OX replaced with $NEW_OX" | |
MINVER=$(grep -Po "#VERSION: [0-9]+\.\K[0-9]+" oxtorrent.py) | |
sed -i "s,#VERSION: \([0-9]\+\)\.$MINVER,#VERSION: \1\.$((MINVER+1))," oxtorrent.py | |
echo "SUCCESS: Minor version $MINVER incremented" | |
git config --global user.name 'CravateRouge' | |
git config --global user.email '[email protected]' | |
git commit -am "Automated url update from $OLD_OX to $NEW_OX" | |
git push | |
else | |
echo "ERROR: new url $NEW_OX returns status $NEW_STATUS. Update Canceled" | |
exit 1 | |
fi | |