@@ -33,7 +33,7 @@ def __init__(self):
3333def main (ctx : click .Context , ** argv ):
3434
3535 verbosity = argv .pop ("verbosity" ).upper ()
36- logging .basicConfig (format = ' %(asctime)s %(message)s' , level = verbosity )
36+ logging .basicConfig (format = " %(asctime)s %(message)s" , level = verbosity )
3737
3838 token = environ .get ("VISTOPIA_API_TOKEN" , None )
3939 token = argv .get ("token" , None ) or token
@@ -44,8 +44,9 @@ def main(ctx: click.Context, **argv):
4444
4545
4646@main .command ("search" , help = "搜索节目" )
47- @click .option ("--keyword" , "-k" , type = click .STRING , required = True ,
48- help = "Search keyword." )
47+ @click .option (
48+ "--keyword" , "-k" , type = click .STRING , required = True , help = "Search keyword."
49+ )
4950@click .pass_context
5051def search (ctx : click .Context , ** argv ):
5152 visitor : Visitor = ctx .obj .visitor
@@ -58,11 +59,11 @@ def search(ctx: click.Context, **argv):
5859 continue
5960 author = item ["author" ]
6061 if item ["subtitle" ]:
61- title = "%s: %s" % ([item [' title' ], item [' subtitle' ]])
62+ title = "%s: %s" % ([item [" title" ], item [" subtitle" ]])
6263 else :
63- title = item [' title' ]
64- desc = item [' share_desc' ]
65- content_id = item ['id' ]
64+ title = item [" title" ]
65+ desc = item [" share_desc" ]
66+ content_id = item ["id" ]
6667 table .append ((content_id , author , title , desc ))
6768
6869 click .echo (tabulate (table ))
@@ -77,7 +78,7 @@ def subscriptions(ctx: click.Context):
7778
7879 table = []
7980 for show in visitor .get_user_subscriptions_list ():
80- title = ": " .join ([show [' title' ], show [' subtitle' ]])
81+ title = ": " .join ([show [" title" ], show [" subtitle" ]])
8182 content_id = show ["content_id" ]
8283 table .append ((content_id , title ))
8384
@@ -92,39 +93,48 @@ def show_content(ctx: click.Context, **argv):
9293
9394 content_id = argv .pop ("id" )
9495 logger .debug (visitor .get_content_show (content_id ))
95- logger .debug (json .dumps (
96- visitor .get_catalog (content_id ), indent = 2 , ensure_ascii = False ))
96+ logger .debug (
97+ json .dumps (visitor .get_catalog (content_id ), indent = 2 , ensure_ascii = False )
98+ )
9799
98- table = []
99100 catalog = visitor .get_catalog (content_id )
101+
102+ click .echo (f"{ catalog ['title' ]} " )
103+ click .echo ()
104+ click .echo (f"艺人: { catalog ['author' ]} " )
105+ click .echo (f"类型: { catalog ['type' ]} " )
106+ click .echo ()
107+
100108 for part in catalog ["catalog" ]:
109+ click .echo (f"{ part ['catalog_number' ]} { part ['catalog_title' ]} " )
110+ table = []
101111 for article in part ["part" ]:
102- table .append ((
103- article ["sort_number" ],
104- # article["article_id"],
105- article ["title" ],
106- article ["duration_str" ],
107- ))
108-
109- click .echo (f"Title: { catalog ['title' ]} " )
110- click .echo (f"Author: { catalog ['author' ]} " )
111- click .echo (f"Type: { catalog ['type' ]} " )
112- click .echo (tabulate (table ))
112+ table .append (
113+ (
114+ article ["sort_number" ],
115+ # article["article_id"],
116+ article ["title" ],
117+ article ["duration_str" ],
118+ )
119+ )
120+ click .echo (tabulate (table ))
113121
114122
115123@main .command ("save-show" , help = "保存节目至本地,并添加封面和 ID3 信息" )
116124@click .option ("--id" , type = click .INT , required = True )
117- @click .option ("--no-tag" , is_flag = True , default = False ,
118- help = "Do not add IDv3 tags." )
125+ @click .option ("--no-tag" , is_flag = True , default = False , help = "Do not add IDv3 tags." )
119126@click .option ("--episode-id" , help = "Episode ID in the form '1-3,4,8'" )
120127@click .pass_context
121128def save_show (ctx : click .Context , ** argv ):
122129 content_id = argv .pop ("id" )
123130 episode_id = argv .pop ("episode_id" , None )
124131 episodes = set (range_expand (episode_id ) if episode_id else [])
125132
126- logger .debug (json .dumps (
127- ctx .obj .visitor .get_catalog (content_id ), indent = 2 , ensure_ascii = False ))
133+ logger .debug (
134+ json .dumps (
135+ ctx .obj .visitor .get_catalog (content_id ), indent = 2 , ensure_ascii = False
136+ )
137+ )
128138
129139 ctx .obj .visitor .save_show (
130140 content_id ,
@@ -136,12 +146,16 @@ def save_show(ctx: click.Context, **argv):
136146@main .command ("save-transcript" , help = "保存节目文稿至本地" )
137147@click .option ("--id" , type = click .INT , required = True )
138148@click .option ("--episode-id" , help = "Episode ID in the form '1-3,4,8'" )
139- @click .option ("--single-file-exec-path" , type = click .Path (),
140- help = "Path to the single-file CLI tool" )
141- @click .option ("--cookie-file-path" , type = click .Path (),
142- help = (
143- "Path to the browser cookie file "
144- "(only needed in single-file mode)" ))
149+ @click .option (
150+ "--single-file-exec-path" ,
151+ type = click .Path (),
152+ help = "Path to the single-file CLI tool" ,
153+ )
154+ @click .option (
155+ "--cookie-file-path" ,
156+ type = click .Path (),
157+ help = ("Path to the browser cookie file " "(only needed in single-file mode)" ),
158+ )
145159@click .pass_context
146160def save_transcript (ctx : click .Context , ** argv ):
147161 content_id = argv .pop ("id" )
@@ -150,21 +164,21 @@ def save_transcript(ctx: click.Context, **argv):
150164 cookie_file_path = argv .pop ("cookie_file_path" )
151165 episodes = set (range_expand (episode_id ) if episode_id else [])
152166
153- logger .debug (json .dumps (
154- ctx .obj .visitor .get_catalog (content_id ), indent = 2 , ensure_ascii = False ))
167+ logger .debug (
168+ json .dumps (
169+ ctx .obj .visitor .get_catalog (content_id ), indent = 2 , ensure_ascii = False
170+ )
171+ )
155172
156173 if single_file_exec_path and cookie_file_path :
157174 ctx .obj .visitor .save_transcript_with_single_file (
158175 content_id ,
159176 episodes = episodes ,
160177 single_file_exec_path = single_file_exec_path ,
161- cookie_file_path = cookie_file_path
178+ cookie_file_path = cookie_file_path ,
162179 )
163180 else :
164- ctx .obj .visitor .save_transcript (
165- content_id ,
166- episodes = episodes
167- )
181+ ctx .obj .visitor .save_transcript (content_id , episodes = episodes )
168182
169183
170184if __name__ == "__main__" :
0 commit comments