我讓他變厲害ㄌ

This commit is contained in:
tasi788 2020-08-13 13:19:20 +08:00
parent 4bec14b5e0
commit 27aeda533e
No known key found for this signature in database
GPG Key ID: 7A46E3C578E9EE6E
2 changed files with 53 additions and 21 deletions

View File

@ -2,7 +2,7 @@ name: Hide_FarmContent_From_Search
on:
push:
branches: [ master ]
branches: [master]
jobs:
# This workflow contains a single job called "build"
@ -11,25 +11,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.x"
- name: Run AutoBuild
run: |
cd AutoBuild
python hide_farm.py
- name: Run AutoBuild
run: |
cd AutoBuild
python hide_farm.py
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add hide_farm_from_search.txt
git commit -m "AutoBuild"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.FUTAFILTERAUTOBUILD }}
- name: Commit files
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add hide_farm_from_search.txt
git commit -m "🤖 自動更新 NoFarm"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.FUTAFILTERAUTOBUILD }}

View File

@ -1,3 +1,8 @@
import os
from datetime import datetime, timedelta, timezone
tz = timezone(timedelta(hours=+8))
domain_list = ''
with open('../nofarm_hosts.txt', 'r') as files:
for domains in files.read().split('\n'):
@ -7,5 +12,32 @@ with open('../nofarm_hosts.txt', 'r') as files:
domain=domain
)
if not os.path.exists('../hide_farm_from_search.txt'):
with open('../hide_farm_from_search.txt', 'w') as files:
pass
with open('../hide_farm_from_search.txt', 'r') as orig:
version, ver_dt = '', ''
try:
version = orig.read().split('\n')[2].split(': ')[1]
ver_dt = datetime.strptime(version[:-3], '%Y.%m%d').date()
except IndexError:
pass
now = datetime.now(tz)
v = now.strftime('%Y.%m%d.')
if now.date() != ver_dt:
v += '01'
else:
v += str(int(version[-2:])+1).zfill(2)
with open('../hide_farm_from_search.txt', 'w') as files:
files.write(domain_list)
head = '[Adblock Plus]\n' \
'! Title: Make futa great again!\n' \
'! Version: {version}\n' \
'! Expires: 1 hour\n' \
'! Homepage: https://t.me/adguard_tw\n' \
'! ----------------------------------------------------------------------\n'.format(
version=v
)
files.write(head + domain_list)