Skip to content

Commit

Permalink
update copyright
Browse files Browse the repository at this point in the history
  • Loading branch information
meisnate12 committed Apr 17, 2024
1 parent ae8c04b commit 96267f3
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/copyright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Update-Copyright-Year

on:
schedule:
- cron: '0 3 1 1 *'
workflow_dispatch:

jobs:
Update-Copyright-Year:
runs-on: ubuntu-latest
steps:

- name: Get current year
id: date
run: echo "year=$(date +'%Y')" >> $GITHUB_OUTPUT

- name: Check Out Repo
uses: actions/checkout@v4

- name: Update Copyright
run: sed -i -E 's/(Copyright \(c\) ).+( meisnate12)/\1${{ steps.date.outputs.year }}\2/' LICENSE

- name: Check Diff
id: verify_diff
run: |
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
- name: Commit & Push Changes
if: steps.verify_diff.outputs.changed == 'true'
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add -A
git commit -m "Update at ${{ steps.date.outputs.date }} UTC" -a
git push origin master
- name: Discord Failure Notification
uses: meisnate12/discord-notifications@master
if: failure()
with:
webhook_id: ${{ secrets.BUILD_WEBHOOK_ID }}
webhook_token: ${{ secrets.BUILD_WEBHOOK_TOKEN }}
message: <@&1079153184007790652>
title: "Anime IDs Copyright: **Failure**"
color: 16106776
url: https://github.com/Kometa-Team/Anime-IDs/actions/runs/${{ github.run_id }}
username: Metabot
avatar_url: https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/.github/logo.png
author: IMDb Awards
author_icon_url: https://raw.githubusercontent.com/Kometa-Team/Kometa/nightly/.github/git.png
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 meisnate12
Copyright (c) 2024 meisnate12

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
18 changes: 9 additions & 9 deletions imdb_awards.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
]
script_name = "IMDb Awards"
base_dir = os.path.dirname(os.path.abspath(__file__))
kometa_args = KometaArgs("Kometa-Team/IMDb-Awards", base_dir, options, use_nightly=False)
logger = KometaLogger(script_name, "imdb_awards", os.path.join(base_dir, "logs"), is_trace=kometa_args["trace"], log_requests=kometa_args["log-requests"])
args = KometaArgs("Kometa-Team/IMDb-Awards", base_dir, options, use_nightly=False)
logger = KometaLogger(script_name, "imdb_awards", os.path.join(base_dir, "logs"), is_trace=args["trace"], log_requests=args["log-requests"])
logger.screen_width = 160
logger.header(kometa_args, sub=True)
logger.header(args, sub=True)
logger.separator("Validating Options", space=False, border=False)
logger.start()
event_ids = YAML(path=os.path.join(base_dir, "event_ids.yml"))
Expand All @@ -41,13 +41,13 @@
"Accept-Language": "en-US,en;q=0.5",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/113.0"
}
valid = YAML(path=os.path.join(base_dir, "event_validation.yml"), create=True, start_empty=kometa_args["clean"])
if kometa_args["clean"]:
valid = YAML(path=os.path.join(base_dir, "event_validation.yml"), create=True, start_empty=args["clean"])
if args["clean"]:
valid.data = YAML.inline({})
valid.data.fa.set_block_style()

def _request(url, xpath=None, extra=None):
sleep_time = 0 if kometa_args["no-sleep"] else random.randint(2, 6)
sleep_time = 0 if args["no-sleep"] else random.randint(2, 6)
logger.info(f"{f'{extra} ' if extra else ''}URL: {url}{f' [Sleep: {sleep_time}]' if sleep_time else ''}")
response = html.fromstring(requests.get(url, headers=header).content)
if sleep_time:
Expand All @@ -56,7 +56,7 @@ def _request(url, xpath=None, extra=None):

titles = {}
for i, event_id in enumerate(original_event_ids, 1):
event_yaml = YAML(path=os.path.join(base_dir, "events", f"{event_id}.yml"), create=True, start_empty=kometa_args["clean"])
event_yaml = YAML(path=os.path.join(base_dir, "events", f"{event_id}.yml"), create=True, start_empty=args["clean"])
old_data = event_yaml.data
event_yaml.data = YAML.inline({})
event_yaml.data.fa.set_block_style()
Expand All @@ -79,7 +79,7 @@ def _request(url, xpath=None, extra=None):
for j, event_year in enumerate(event_years, 1):
event_year = str(event_year)
event_year_url = f"{event_url}/{event_id}/{f'{event_year}/1' if '-' not in event_year else event_year.replace('-', '/')}/?ref_=ev_eh"
if first or kometa_args["clean"] or event_year not in old_data:
if first or args["clean"] or event_year not in old_data:
obj = None
for text in _request(event_year_url, xpath="//div[@class='article']/script/text()", extra=f"[Event {i}/{total_ids}] [Year {j}/{total_years}]")[0].split("\n"):
if text.strip().startswith("IMDbReactWidgets.NomineesWidget.push"):
Expand Down Expand Up @@ -120,7 +120,7 @@ def _request(url, xpath=None, extra=None):
event_yaml[event_year] = event_data
event_yaml.data.yaml_add_eol_comment(event_year_url, event_year)
if event_data and event_year not in valid[event_id]["years"]:
if kometa_args["clean"]:
if args["clean"]:
valid[event_id]["years"].append(event_year)
else:
valid[event_id]["years"].insert(0, event_year)
Expand Down

0 comments on commit 96267f3

Please sign in to comment.