Commit d2d3f82

benny-dou <60535774+benny-dou@users.noreply.github.com>
2025-09-12 02:28:48
fix(podcast): skip entries with invalid video info
1 parent 49ae41e
Changed files (1)
src
podcast
src/podcast/main.py
@@ -43,6 +43,8 @@ from networking import download_file, hx_req
 from podcast.asr import backup_audio, get_duration, get_transcripts
 from podcast.utils import HEADERS, clean_feed_url, feed_saved_target, get_pubdate, remove_img_tag
 from podcast.xml import get_feed_title, parse_feed, save_xml, update_xml_desc
+from preview.bilibili import get_bilibili_vinfo
+from preview.youtube import get_youtube_vinfo
 from publish import publish_telegraph
 from utils import bare_url, count_subtitles, https_url, nowdt, rand_number, seconds_to_hms, strings_list
 from ytdlp.download import ytdlp_download
@@ -203,6 +205,15 @@ async def get_new_entries(feed_title: str, feed: dict, processed: dict) -> list[
             delta = now - dt
             if delta.total_seconds() > PODCAST.IGNORE_OLD_THAN_SECONDS:
                 continue
+            if "youtube.com" in link:
+                vinfo = await get_youtube_vinfo(entry["yt_videoid"])
+            elif "bilibili.com" in link:
+                vinfo = await get_bilibili_vinfo(link)
+            else:
+                vinfo = {}
+            if vinfo.get("error_msg"):
+                logger.warning(f"Failed to get video info: {vinfo['error_msg']}")
+                continue
             if not await get_cf_r2(entry["db_key"]):
                 new_entries.append(entry)
         if new_entries: