|
|
|
@ -20,6 +20,8 @@
|
|
|
|
|
from db import DataBase
|
|
|
|
|
from scraper import Scraper
|
|
|
|
|
from notify import Notification
|
|
|
|
|
from rich.console import Console
|
|
|
|
|
from rich.progress import track
|
|
|
|
|
import time
|
|
|
|
|
|
|
|
|
|
def get_urls(file_path):
|
|
|
|
@ -53,28 +55,33 @@ def main():
|
|
|
|
|
urls = get_urls(URL_FILE)
|
|
|
|
|
#print(f"{urls}")
|
|
|
|
|
|
|
|
|
|
# Console initialising
|
|
|
|
|
console = Console()
|
|
|
|
|
|
|
|
|
|
# Checks for new urls in file and add as current state
|
|
|
|
|
# If one of page has updated then notifing.
|
|
|
|
|
# Repeating the checking with the waiting period.
|
|
|
|
|
while True:
|
|
|
|
|
print(f"[DOING] Checking for animes [0/{len(urls)}]")
|
|
|
|
|
console.print(f"[yellow][DOING][/] Checking for animes [0/{len(urls)}]")
|
|
|
|
|
count = 0
|
|
|
|
|
for url in urls:
|
|
|
|
|
data = scr.get_anime(url, POSTERS)
|
|
|
|
|
if data == None:
|
|
|
|
|
print(f"[ERROR] A conections trouble is occured.")
|
|
|
|
|
console.print(f"[red][ERROR][/] A conections trouble is occured.")
|
|
|
|
|
continue
|
|
|
|
|
url, title, status, poster_path = data
|
|
|
|
|
print(f"[DOING] Checking for \"{title}\" [{count}/{len(urls)}]")
|
|
|
|
|
console.print(f"[yellow][DOING][/] Checking for \"{title}\" [{count}/{len(urls)}]")
|
|
|
|
|
r = db.add_anime_if(url, title, status, poster_path)
|
|
|
|
|
if r == -1:
|
|
|
|
|
n = Notification(title, MESSAGE, poster_path)
|
|
|
|
|
n.send()
|
|
|
|
|
print(f"[NOTIFICATION] \"{title}\"")
|
|
|
|
|
console.print(f"[blue bold][NOTIFICATION][/] \"{title}\"")
|
|
|
|
|
count+=1
|
|
|
|
|
print(f"[DONE] Checking for \"{title}\" [{count}/{len(urls)}]")
|
|
|
|
|
print(f"[WAITING] The next check is after {WAITING_PERIOD} seconds")
|
|
|
|
|
time.sleep(WAITING_PERIOD)
|
|
|
|
|
console.print(f"[green][DONE][/] Checking for \"{title}\" [{count}/{len(urls)}]")
|
|
|
|
|
console.print(f"[yellow][WAITING][/] The next check is after {WAITING_PERIOD} seconds")
|
|
|
|
|
# Sleep while waiting
|
|
|
|
|
for n in track(range(WAITING_PERIOD), description="Waiting..."):
|
|
|
|
|
time.sleep(1)
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|
|
|
|
|