Skip to content

Commit

Permalink
several minor updates
Browse files Browse the repository at this point in the history
added refresh function into videos list and implemented better "no videos" table handling
  • Loading branch information
ch1kulya committed Jan 22, 2025
1 parent 338defb commit 9b3164a
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/utils/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ def videos_menu(self) -> None:
videos = sorted(videos, key=lambda x: x["published"], reverse=True)
cutoff_date = datetime.now(videos[0]["published"].tzinfo) - timedelta(days=self.manager.config["days_filter"])
videos = [video for video in videos if video["published"] > cutoff_date]
if not videos:
self.draw_heading("Video Fetcher")
self.show_message("No videos found!\nCheck your filters and internet connection.", "red")
return
self.manager._log(f"[b green]Fetched successfully.")
sleep(0.3)
while True:
Expand Down Expand Up @@ -254,9 +258,31 @@ def videos_menu(self) -> None:
color_time = "magenta"
table.add_row(f"[{color}]{str(idx + 1)}[/{color}]", f"[{color}]{title}[/{color}]", f"[{color}]{channel_name}[/{color}]", f"[{color}]{duration}[/{color}]", f"[{color_time}]{time_ago}[/{color_time}]")
self.console.print(Align.center(table, vertical="middle"))
choice = Prompt.ask("\n" + " " * 9 + "Select video [underline]index[/underline] to watch")
choice = Prompt.ask("\n" + " " * 9 + "Select video [underline]index[/underline] to watch or [underline]0[/underline] to refresh")
if not choice.strip():
break
if int(choice) == 0:
self.draw_heading("Video Fetcher")
self.manager._log(f"Refreshing started.")
parsed_feeds = self.manager.parse_feeds(self.manager.channels)
videos.clear()
with self.console.status(" " * 9 + "[b green]Fetching videos..."):
for i, channel_id in enumerate(self.manager.channels):
feed = parsed_feeds[i]
videos.extend(self.manager.fetch_videos(channel_id, feed))
if not videos:
self.draw_heading("Video Fetcher")
self.show_message("No videos found!\nCheck your subscriptions and internet connection.", "red")
return
videos.sort(key=lambda x: x["published"], reverse=True)
cutoff_date = datetime.now(videos[0]["published"].tzinfo) - timedelta(days=self.manager.config["days_filter"])
videos[:] = [v for v in videos if v["published"] > cutoff_date]
if not videos:
self.draw_heading("Video Fetcher")
self.show_message("No videos found!\nCheck your filters and internet connection.", "red")
return
self.manager._log(f"[b green]Refreshed successfully.")
continue
if choice.isdigit() and 1 <= int(choice) <= len(videos):
video = videos[int(choice) - 1]
video_details = {
Expand Down

0 comments on commit 9b3164a

Please sign in to comment.