Skip to content

Commit

Permalink
Workaround for quick shutdown, fixed ongoing season logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaisberg authored and Gaisberg committed Dec 27, 2023
1 parent a877fd9 commit a141777
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion backend/program/media/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _determine_state(self):
return Symlink()
if all(episode.file and episode.folder for episode in self.episodes):
return Download()
if self.is_scraped():
if self.is_scraped() or any(episode.state == Scrape for episode in self.episodes):
return Scrape()
if any(episode.state == Content for episode in self.episodes):
return Content()
Expand Down
12 changes: 10 additions & 2 deletions backend/program/media/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ def perform_action(self):
scrape.run(self.context)
if self.context.type == "show":
for season in self.context.seasons:
season.state.perform_action()
if season.aired_at:
season.state.perform_action()
else:
for episode in season.episodes:
episode.state.perform_action()


class Scrape(MediaItemState):
Expand All @@ -46,7 +50,11 @@ def perform_action(self):
debrid.run(self.context)
if self.context.type == "show":
for season in self.context.seasons:
season.state.perform_action()
if season.aired_at:
season.state.perform_action()
else:
for episode in season.episodes:
episode.state.perform_action()
if self.context.type == "season":
self.context.state.perform_action()

Expand Down
2 changes: 1 addition & 1 deletion backend/program/realdebrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def _is_downloaded(self, item):

def _update_torrent_info(self, item):
info = self.get_torrent_info(item.get("active_stream")["id"])
item.active_stream["name"] = info.filename
item.active_stream["name"] = info.original_filename

def _download_item(self, item):
request_id = self.add_magnet(item)
Expand Down
6 changes: 5 additions & 1 deletion backend/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def save(self) -> None:
def run(self):
while self.running:
self.save()
time.sleep(10)
# workaround for quick shutdown, we should use threading.Event instead
for i in range(10):
if not self.running:
break
time.sleep(i)


class Parser:
Expand Down

0 comments on commit a141777

Please sign in to comment.