#6 Calendar view
Add a calendar view Update required python version to 3.10 Correct config and animes flags to -c and -a Change timer tick rate to every 15mins instead of 55mins Update readme Signed-off-by: MK13 <marius@kleberonline.de>
This commit is contained in:
81
anime-rss.py
81
anime-rss.py
@@ -1,3 +1,4 @@
|
||||
from collections import defaultdict
|
||||
import feedparser
|
||||
import json
|
||||
import re
|
||||
@@ -5,6 +6,9 @@ import subprocess
|
||||
import argparse
|
||||
from notifypy import Notify
|
||||
import os
|
||||
import sys
|
||||
from rich.console import Console
|
||||
from rich.table import Table
|
||||
|
||||
feedparser.USER_AGENT = "anime-rss/1.0"
|
||||
|
||||
@@ -19,8 +23,9 @@ BOLD_GREEN = BOLD + GREEN
|
||||
UNDERLINE = CSI + "4;4m"
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("c", help="path to the config.json file", type=str, default="config.json", nargs='?')
|
||||
parser.add_argument("a", help="path to the animes.json file", type=str, default="animes.json", nargs='?')
|
||||
parser.add_argument("-c", help="path to the config.json file", type=str, default="config.json", nargs='?')
|
||||
parser.add_argument("-a", help="path to the animes.json file", type=str, default="animes.json", nargs='?')
|
||||
parser.add_argument("-t", help="print a tabular calendar view and exit", action="store_true")
|
||||
args = parser.parse_args()
|
||||
|
||||
|
||||
@@ -39,10 +44,80 @@ def send_notification(message):
|
||||
notification.icon = os.path.dirname(os.path.realpath(__file__)) + "/notfication-icon.png"
|
||||
notification.send()
|
||||
|
||||
|
||||
|
||||
with open(args.a, "r") as feeds:
|
||||
feeds = json.load(feeds)
|
||||
|
||||
if args.t:
|
||||
table = Table(title="Animes")
|
||||
|
||||
table.add_column("Monday")
|
||||
table.add_column("Tuesday")
|
||||
table.add_column("Wednesday")
|
||||
table.add_column("Thursday")
|
||||
table.add_column("Friday")
|
||||
table.add_column("Saturday")
|
||||
table.add_column("Sunday")
|
||||
|
||||
buckets = defaultdict(list)
|
||||
|
||||
for feed in feeds["Feeds"]:
|
||||
for anime in feed["Animes"]:
|
||||
day = anime["Airing"].lower()
|
||||
|
||||
buckets[day].append(anime["Title"])
|
||||
|
||||
while buckets.items():
|
||||
monday = ""
|
||||
tuesday = ""
|
||||
wednesday = ""
|
||||
thursday = ""
|
||||
friday = ""
|
||||
saturday = ""
|
||||
sunday = ""
|
||||
|
||||
if len(buckets["monday"]) > 0:
|
||||
monday = buckets["monday"].pop(len(buckets["monday"]) - 1)
|
||||
else:
|
||||
buckets.pop("monday")
|
||||
|
||||
if len(buckets["tuesday"]) > 0:
|
||||
tuesday = buckets["tuesday"].pop(len(buckets["tuesday"]) - 1)
|
||||
else:
|
||||
buckets.pop("tuesday")
|
||||
|
||||
if len(buckets["wednesday"]) > 0:
|
||||
wednesday = buckets["wednesday"].pop(len(buckets["wednesday"]) - 1)
|
||||
else:
|
||||
buckets.pop("wednesday")
|
||||
|
||||
if len(buckets["thursday"]) > 0:
|
||||
thursday = buckets["thursday"].pop(len(buckets["thursday"]) - 1)
|
||||
else:
|
||||
buckets.pop("thursday")
|
||||
|
||||
if len(buckets["friday"]) > 0:
|
||||
friday = buckets["friday"].pop(len(buckets["friday"]) - 1)
|
||||
else:
|
||||
buckets.pop("friday")
|
||||
|
||||
if len(buckets["saturday"]) > 0:
|
||||
saturday = buckets["saturday"].pop(len(buckets["saturday"]) - 1)
|
||||
else:
|
||||
buckets.pop("saturday")
|
||||
|
||||
if len(buckets["sunday"]) > 0:
|
||||
sunday = buckets["sunday"].pop(len(buckets["sunday"]) - 1)
|
||||
else:
|
||||
buckets.pop("sunday")
|
||||
|
||||
table.add_row(monday, tuesday, wednesday, thursday, friday, saturday, sunday)
|
||||
|
||||
console = Console()
|
||||
console.print(table, justify="center")
|
||||
|
||||
sys.exit(0)
|
||||
|
||||
with open(args.c, "r") as config:
|
||||
config = json.load(config)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user