-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathepisodes.py
More file actions
99 lines (75 loc) · 2.4 KB
/
episodes.py
File metadata and controls
99 lines (75 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
"""Episode commands — search, get, list, recent, transcript."""
from __future__ import annotations
import cyclopts
from talk_python_cli.formatting import display
episodes_app = cyclopts.App(
name='episodes',
help='Browse and search Talk Python to Me podcast episodes.',
)
def _client():
from talk_python_cli.app import get_client
return get_client()
@episodes_app.command
def search(query: str, *, limit: int = 10) -> None:
"""Search episodes by keyword.
Parameters
----------
query
Search keywords for episode titles and descriptions.
limit
Maximum number of results to return.
"""
client = _client()
args = {'query': query, 'limit': limit}
content = client.call_tool('search_episodes', args)
display(content, client.output_format)
@episodes_app.command
def get(show_id: int) -> None:
"""Get full details for an episode by its show ID.
Parameters
----------
show_id
Episode show ID (e.g. 400).
"""
client = _client()
content = client.call_tool('get_episode', {'show_id': show_id})
display(content, client.output_format)
@episodes_app.command(name='list')
def list_episodes() -> None:
"""List all podcast episodes with their show IDs and titles."""
client = _client()
content = client.call_tool('get_episodes')
display(content, client.output_format)
@episodes_app.command
def recent(*, limit: int = 10) -> None:
"""Get the most recently published episodes.
Parameters
----------
limit
Number of recent episodes to return.
"""
client = _client()
content = client.call_tool('get_recent_episodes', {'limit': limit})
display(content, client.output_format)
@episodes_app.command
def transcript(show_id: int) -> None:
"""Get the full plain-text transcript for an episode.
Parameters
----------
show_id
Episode show ID.
"""
client = _client()
content = client.call_tool('get_transcript_for_episode', {'show_id': show_id})
display(content, client.output_format)
@episodes_app.command(name='transcript-vtt')
def transcript_vtt(show_id: int) -> None:
"""Get the transcript in WebVTT format (with timestamps).
Parameters
----------
show_id
Episode show ID.
"""
client = _client()
content = client.call_tool('get_transcript_vtt', {'show_id': show_id})
display(content, client.output_format)