Commit 77f731b

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-09-24 04:54:29
fix(podcast): ensure downloaded podcast file exists before proceeding
1 parent cb5175d
Changed files (1)
src
podcast
src/podcast/main.py
@@ -64,7 +64,7 @@ async def summary_pods(client: Client):
             logger.info(f"Updating podcast {feed_title}: {entry['title']}")
             message = Message(id=rand_number(), chat=Chat(id=PODCAST.TID))
             info = await download_enclosure(entry, cover_url=glom(feed, "feed.image.href", default=""))
-            if not info["path"]:
+            if not Path(info["path"]).is_file():
                 logger.error(f"Failed download podcast {feed_title} -- {entry['title']}")
                 await send2tg(client, message, texts=f"Failed download podcast {feed_title} -- {entry['title']}", reply_msg_id=-1)
                 continue
@@ -121,9 +121,10 @@ async def summary_pods(client: Client):
                     else [{"video": info["path"], "thumb": info["thumb"]}]
                 )
 
-                await send2tg(client, message, texts=caption, media=media, reply_msg_id=-1)
+                messages = await send2tg(client, message, texts=caption, media=media, reply_msg_id=-1)
                 processed_xml = await update_xml_desc(feed_url, processed_xml, entry, summary=gpt_res.get("texts", ""), audio_path=info["asr_path"])
-                await set_cf_r2(entry["db_key"], data={"title": entry["title"], "url": entry["link"]})
+                if isinstance(messages[0], Message):
+                    await set_cf_r2(entry["db_key"], data={"title": entry["title"], "url": entry["link"]})
                 has_update = True
                 Path(info["path"]).unlink(missing_ok=True)
                 Path(info["asr_path"]).unlink(missing_ok=True)