Skip to content

Commit

Permalink
Several bug fixes (ZeroDivisionError, ValueError)
Browse files Browse the repository at this point in the history
  • Loading branch information
sunsettrack4 committed Nov 1, 2022
1 parent 9a17732 commit e929f27
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions resources/lib/epg.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def __init__(self, file_paths):

# AUTO START UP
start_up = False
start_dt = f'{datetime.now().year}{datetime.now().month}{datetime.now().day}'
start_dt = f'{datetime.now().strftime("%Y%m%d")}'
if self.user_db.main["settings"]["ag"] == "yes":
start_up = True
if self.user_db.main["settings"]["ag"] == "out" and self.file_available and \
Expand Down Expand Up @@ -99,7 +99,7 @@ def epg_process(self, start_up, start_dt):
if int(self.user_db.main["settings"]["rate"]) != 0 and \
(int(self.user_db.main["settings"]["rate"]) * 3600 + datetime.strptime(f'{start_dt} {self.user_db.main["settings"]["ut"]}', "%Y%m%d %H:%M").timestamp()) < datetime.now().timestamp():
self.grabbing = True
start_dt = f'{datetime.now().year}{datetime.now().month}{datetime.now().day}'
start_dt = f'{datetime.now().strftime("%Y%m%d")}'
sleep(1)

def load_airings(self, channel):
Expand Down Expand Up @@ -133,6 +133,9 @@ def grabber_process(self):

# DOWNLOAD FILES
self.status = "Downloading EPG data..."

if len(self.user_db.main["channels"]) == 0:
raise Exception("Please add your channels first before starting the grabber process.")

executor = concurrent.futures.ThreadPoolExecutor(max_workers=self.user_db.main["settings"]["dl_threads"])
{executor.submit(self.load_airings, channel).add_done_callback(self.cache_airings) for channel in self.user_db.main["channels"]}
Expand Down Expand Up @@ -394,6 +397,11 @@ def grabber_process(self):
self.file_available = True
self.file_created = datetime.fromtimestamp(os.path.getmtime(f"{self.file_paths['storage']}xml/epg.xml")).strftime('%Y-%m-%d %H:%M:%S')

try:
print(f"{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}: File created successfully!")
except:
pass

self.status = "File created successfully!"
self.progress = 100
self.grabbing = False
Expand Down

0 comments on commit e929f27

Please sign in to comment.