Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix empty episode table in 'tooluse' command #20

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/tool_use/tooluse/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,16 @@
console = Console()

def fetch_rss_feed(url):
return feedparser.parse(url)
feed = feedparser.parse(url)
if feed.bozo:
console.print("[bold red]Error:[/bold red] Failed to parse RSS feed.")
return None
return feed

def display_episodes(feed):
if not feed.entries:
console.print("[bold yellow]No episodes available to display.[/bold yellow]")
return
table = Table(title="Podcast Episodes", box=box.ROUNDED)
table.add_column("Title", style="cyan", no_wrap=True)
table.add_column("Date", style="magenta")
Expand Down Expand Up @@ -98,10 +105,14 @@ def play_mp3(url):
console.print("[bold red]Error:[/bold red] Could not play audio. Please install either:")
console.print("- sounddevice and soundfile (pip install sounddevice soundfile)")
console.print("- mpv (system package)")
console.print("[bold red]Debug Info:[/bold red] Ensure the RSS feed URL is correct and accessible.")

def main():
rss_url = "https://anchor.fm/s/fb2a98a0/podcast/rss"
feed = fetch_rss_feed(rss_url)
if not feed or not feed.entries:
console.print("[bold yellow]No episodes found. Please check the RSS feed URL or your internet connection.[/bold yellow]")
return

while True:
console.clear()
Expand Down