-
-
Notifications
You must be signed in to change notification settings - Fork 825
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add script to generate cron schedule from fixtures data
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from getters import get_fixtures_data | ||
from dateutil.parser import parse | ||
from datetime import timedelta | ||
|
||
def generate_schedule(): | ||
fixtures = get_fixtures_data() | ||
gw_dict = {} | ||
for f in fixtures: | ||
gw = f['event'] | ||
time = f['kickoff_time'] | ||
if gw is None: | ||
continue | ||
if gw not in gw_dict: | ||
gw_dict[gw] = [time] | ||
else: | ||
gw_dict[gw] += [time] | ||
|
||
sched_dates = [] | ||
for k,dates in gw_dict.items(): | ||
dates = [parse(d) for d in dates] | ||
dates.sort(reverse=True) | ||
run_date = dates[0] + timedelta(hours=12) | ||
sched_dates += [run_date] | ||
|
||
for run_date in sorted(sched_dates): | ||
print(run_date.strftime("%M %H %d %m *")) | ||
|
||
def main(): | ||
generate_schedule() | ||
|
||
if __name__ == '__main__': | ||
main() |
c2f98ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool man. This is the right schedule. The schedule I use in my AI is to notify me about the best transfers for the next gameweek. That's why it runs 4 hours before the deadline.