{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "5238d07c-825b-4872-8725-2ea5ebf356b7",
   "metadata": {},
   "source": [
    "<img src=\"./logo.png\" alt=\"cosmos wormhole\" style=\"display: block; margin: auto; width: 30%\"/>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c0f522a3-c9bd-47ee-9374-5fa3abb2613a",
   "metadata": {},
   "source": [
    "<div>\n",
    "    <h3 style=\"text-align: center;\">cosmos-wormhole</h3>\n",
    "    <p style=\"text-align: center;\"><a href=\"https://www.xiaoyuzhoufm.com/\" target=\"_blank\">小宇宙</a> API (Python Version)</p>\n",
    "    <p style=\"text-align: center;\">🐙 <a href=\"https://github.com/Sorosliu1029/cosmos-wormhole\" target=\"_blank\">GitHub: cosmos-wormhole</a> | 🐍 <a href=\"https://pypi.org/project/cosmos-wormhole/\" target=\"_blank\">PyPI: cosmos-wormhole</a></p>\n",
    "</div>"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ed835e43-c151-4fdc-869d-12dbfea5a363",
   "metadata": {},
   "source": [
    "### 安装\n",
    "\n",
    "```sh\n",
    "pip install cosmos-wormhole\n",
    "```"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "b948db8d-bd7e-4023-8ce8-a59ff80bb836",
   "metadata": {},
   "source": [
    "### 用例"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "30f87287-0042-40dd-8c30-f1c370889fba",
   "metadata": {},
   "outputs": [],
   "source": [
    "from cosmos_wormhole import Client"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "1ab91351-daf2-4d6a-aadd-2f13712f0c91",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": [
     "remove_cell"
    ]
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "\n",
       "<style>\n",
       ".jp-OutputArea-output pre { \n",
       "    line-height: 1 !important\n",
       "}\n",
       "</style>"
      ],
      "text/plain": [
       "<IPython.core.display.HTML object>"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 为了在Jupyter里能够扫二维码，使用cosmos-wormhole不需要这一步\n",
    "from IPython.display import HTML\n",
    "HTML('''\n",
    "<style>\n",
    ".jp-OutputArea-output pre { \n",
    "    line-height: 1 !important\n",
    "}\n",
    "</style>''')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d24b3404-4466-4014-aaab-164d11380375",
   "metadata": {
    "editable": true,
    "slideshow": {
     "slide_type": ""
    },
    "tags": []
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "打开小宇宙App，使用「发现」Tab - 搜索框右侧「扫一扫」登录\n",
      "PS: 小宇宙会提示登录「小宇宙主播后台」。主播后台和主App账号互通\n",
      "                                             \n",
      "                                             \n",
      "    █▀▀▀▀▀█ ▄▄▄ █▄▀▀▀▄ ▀██  █   █ █▀▀▀▀▀█    \n",
      "    █ ███ █ █ ▄█ █▄▄ ▄   █▀▄█▄▀█  █ ███ █    \n",
      "    █ ▀▀▀ █  ▄▄█▄▄▄ ▄█ ▀ █▄▀▄▄▀ █ █ ▀▀▀ █    \n",
      "    ▀▀▀▀▀▀▀ █ █ █▄█▄█▄█ ▀ ▀▄▀ ▀▄█ ▀▀▀▀▀▀▀    \n",
      "    ▀ ▄▄▄▄▀▄██ █ ▀  █ ▄▀ █▄█▄▀ ▄██▀ ▄███     \n",
      "      ▀▄ ▄▀ ▄▄▀ █▀ ▀▀ ▀█▄ █ ▄ ██▀ ▄▀▀▀▀▀█    \n",
      "    ▀ █▄▀ ▀▄▀▄ ▀ ▀▀██  ▄█▄ ▄█ ▄███▀█ ▄ ▄▀    \n",
      "    ▀▄██▄ ▀██ █▀ ▀ █▀ ▀  ▄█   ▀▀█▀▀█▀█▄▄█    \n",
      "    ▄▄ █▀ ▀ █▀▄▄ ▄█ ▄ ▀ ▀█▀█▄█▄█▄▀▀▄▀ ██     \n",
      "    ▀▀▀▄▄ ▀██▀▄██▀ ▄█ █▀ ▀▄▀▀ ▀▀▄▄█▀█▀▀ █    \n",
      "       █ ▄▀▄█▀▀█ █▄ ▀█▄▄▀ ▄▄▀▀██  ▀ █ █▄     \n",
      "    ▄▀▀▀█ ▀ ▄ █▄▀██▀██▄ █▀▄▄▀  ▀▀▄████  █    \n",
      "    █▀   ▀▀█ ▀█   ▀▀ ▀▄▀████▀▄█▄██▀  ▄  ▀    \n",
      "    █ ▄▄▀▀▀▄███  ▄ ▀█▀▀█  ▀▄█ ▄▀ ▀  █▄█▀█    \n",
      "    ▀ ▀▀ ▀▀▀▄▀▄█ █▀█▄▀▄██▄▀▄▀▀▀▀█▀▀▀█▀▀▀▀    \n",
      "    █▀▀▀▀▀█  ▀▄█   ▀█▀▀▀ ▄ ▀ ▀▀▄█ ▀ █  ▄█    \n",
      "    █ ███ █  ▄▀ ███▀ ▄▀ ███▄▀█ ▀███▀▀▄█ ▄    \n",
      "    █ ▀▀▀ █   ▀▀▄▀ ▄▄▀  ▀ █ █▀█▀█▀  ▄▀▀▀█    \n",
      "    ▀▀▀▀▀▀▀ ▀▀   ▀▀ ▀  ▀▀       ▀ ▀▀    ▀    \n",
      "                                             \n",
      "                                             \n",
      "二维码已被扫描，请在小宇宙App中确认登录。\n",
      "登录成功！\n"
     ]
    }
   ],
   "source": [
    "c = Client()\n",
    "await c.login()"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0b63783a-7310-4077-acad-40ec75261899",
   "metadata": {},
   "source": [
    "⚠️ PS:\n",
    "\n",
    "登录成功后，token会保存在 `~/.local/state/cosmos-wormhole/token.json`文件中。如无必要，不要改动该文件。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "c73477b2-3f3d-416f-9b5e-7a548cc2da75",
   "metadata": {},
   "source": [
    "#### 1. 订阅"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "3e12d33e-0f77-420d-b558-a88007c2abca",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "🎙️Podcast(pid=6278b07ad6e7a5551f799dd0, title=公司茶水间)\n",
      "🎙️Podcast(pid=65a625966d045a7f5e0b5640, title=不止金钱)\n",
      "🎙️Podcast(pid=625e7ba592a9f7a721b86d20, title=蜜獾吃书)\n",
      "🎙️Podcast(pid=5f4475a89504bbdb77b50bd0, title=最近买了什么书)\n",
      "🎙️Podcast(pid=5e2aaf88418a84a046546819, title=梁文道·八分)\n",
      "🎙️Podcast(pid=5e3bdf08418a84a046fb556c, title=大内密谈)\n",
      "🎙️Podcast(pid=64379296ff8a107611a67208, title=史蒂夫说)\n",
      "🎧Episode(eid=6874e0a193fd2d72b820959f, pid=64379296ff8a107611a67208, title=史蒂夫说432期 - 回信：不了解自己的人容易执着于肤浅的成败)\n",
      "💬Comment(id=687519a1e26a3567d425b549, text=挺认同steve给第一位时常抑郁和虚无的咨询者给的建议，脑子想根本不行的，还是需要从身体开始拯救自己，我也是时常这样，如果去练舞跳舞，就会好点)\n",
      "↩️Comment(id=6875af7944c4a5b6c470cf5e, text=11:47 是的，身体的正反馈对心理的康复有利。我游泳教练说很多老年人睡不着就来游泳，游完睡眠嘎嘎好😂。以及，有社交体验的运动会对心理恢复更好，即使每次只有很浅薄的small talk. 以及有些朴素的建议，抑郁了可以去干点体力活或做一些体力工作。从功利的角度来说，因为没时间想七想八，既可以消耗体力睡好觉，又可以拿钱。)\n",
      "↩️Comment(id=68751e852134314d913b5e61, text=ip正确，舞起来吧哈哈哈哈)\n",
      "↩️Comment(id=68770e5111d4f41403602567, text=同意..当很迷茫的时候，身体上的探索进步多多少少给了我一点正反馈让我不那么讨厌躺平的自己⋯，就算一点点。都至少给了我，人生还有能靠自己控制，生活是没那么坏的感受。)\n",
      "↩️Comment(id=6878d33d15d8379d4db3b764, text=是的，我也决定今年必须去游泳了！)\n",
      "↩️Comment(id=68763c58e8e669b5695d782e, text=很认同这个点，身体上的疲惫是最好的安眠药)\n"
     ]
    }
   ],
   "source": [
    "async for podcast in c.subscription.list():\n",
    "    print(f\"🎙️{podcast}\")\n",
    "    if podcast.title == \"史蒂夫说\":\n",
    "        async for episode in c.episode.list_by_podcast(podcast.id):\n",
    "            print(f\"🎧{episode}\")\n",
    "            async for comment in c.comment.list_by_episode(episode.id, \"HOT\"):\n",
    "                print(f\"💬{comment}\")\n",
    "                async for reply in c.reply.list_by_comment(comment.id, \"SMART\"):\n",
    "                    print(f\"↩️{reply}\")\n",
    "                break\n",
    "            break\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fc9028e-8223-416b-80ae-61eb7d2f8d80",
   "metadata": {},
   "source": [
    "#### 2. 节目/单集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "7251683b-fa5c-481a-a507-ba0944f1ca7a",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Podcast(pid=5e280faa418a84a0461f9ad8, title=日谈公园)\n",
      "Episode(eid=68776e08f01740ccc77a596b, pid=5e280faa418a84a0461f9ad8, title=vol.719 请马伯庸亲自说说《长安的荔枝》的创作秘辛)\n"
     ]
    }
   ],
   "source": [
    "podcast = await c.podcast.get('5e280faa418a84a0461f9ad8')\n",
    "print(podcast)\n",
    "episode = await c.episode.get('68776e08f01740ccc77a596b')\n",
    "print(episode)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "19485247-7e13-4a23-b94c-2af0e5e32855",
   "metadata": {},
   "source": [
    "#### 3. 节目更新"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "4785ce07-580d-4a54-8638-0318e36d68be",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Episode(eid=687ec6ff96cb2d71096ef22c, pid=5e4515bd418a84a046e2b11a, title=Vol.292 现代性与大屠杀：普通人与恶的距离有多远？)\n",
      "Episode(eid=687debb9a12f9ff06a3bcae5, pid=5e284c39418a84a046263d8a, title=vol.470 零基础Live Aid入门（上）)\n",
      "Episode(eid=687e6bd796cb2d710960fd68, pid=61933ace1b4320461e91fd55, title=127: 与真格戴雨森 25 AI 中场复盘：OpenAI的IMO金牌、Kimi K2翻盘、Agent普及和抢人大战)\n",
      "Episode(eid=687e538ca9dec9250073653d, pid=5e280faa418a84a0461f9ad8, title=vol.720 金世佳：我对不成功的人生充满感激（上）)\n",
      "Episode(eid=687dca72a9dec9250057d909, pid=5e2839ca418a84a0462431b7, title=圆桌会谈：炎炎夏日，我在泳池浴室寻找恶臭之源！)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for episode in c.inbox.list():\n",
    "    print(episode)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f8e86a68-0c29-47f6-91c5-331d27909b31",
   "metadata": {},
   "source": [
    "#### 4. 播放列表"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "01ea2181-aba7-422e-bd7f-f763de11e90e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "687ce8e4a9dec925003c8efd\n",
      "68787863a12f9ff06a9448f8\n",
      "683e851c38dcc57c644718eb\n",
      "6879df2da9dec92500e81fdf\n",
      "68776e08f01740ccc77a596b\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for playlist in c.playlist.list():\n",
    "    print(playlist)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8a3f9a92-39b3-4e9b-89b4-fd24e99f9a6b",
   "metadata": {},
   "source": [
    "#### 5. 用户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "ba4029c9-ed92-4c6f-94bf-294552dc5962",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User(uid=5e2987043419f408b3f7f23f, nickname=以太)\n",
      "User(uid=5e82d3531bfbbc3dad854379, nickname=杨大壹)\n"
     ]
    }
   ],
   "source": [
    "my_profile = await c.profile.get()\n",
    "print(my_profile)\n",
    "podcaster = await c.profile.get('5e82d3531bfbbc3dad854379') # 《文化有限》主播 杨大壹\n",
    "print(podcaster)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "774c92c6-8f9d-4607-82c8-ea6dad773108",
   "metadata": {},
   "source": [
    "#### 6. 关注"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "825d122d-82f2-43df-b04b-5d10356fe971",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User(uid=6045751fe0f5e723bb4aafbf, nickname=袁梦_Nina)\n",
      "User(uid=62f3b03eedce67104a074bf6, nickname=蒋寻)\n",
      "User(uid=60b861e2e0f5e723bbb4d9f6, nickname=妙雅的兔子)\n",
      "User(uid=5e808f0e1bfbbc3dad8419c9, nickname=免子队长油百万)\n",
      "User(uid=5e739699b3c5bca5f63af74b, nickname=Alissi)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for user in c.followee.list_following(my_profile.id):\n",
    "    print(user)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "e72ba22a-0f12-46eb-83c3-2accbfdfa8f0",
   "metadata": {},
   "source": [
    "#### 7. 粉丝"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "cfa11c0f-fb56-4c1a-af09-38bcc527a0e2",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User(uid=62bdba2cedce67104aeef82e, nickname=磊一鸣)\n",
      "User(uid=64890337edce67104aafed32, nickname=言云星月area)\n",
      "User(uid=63c781efedce67104a897dfc, nickname=泡泡po33)\n",
      "User(uid=5eab8af59c735f9cf4eb3adb, nickname=废材少女幽香酱)\n",
      "User(uid=5fe13e59e0f5e723bb847302, nickname=歪歪爱学习)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for user in c.follower.list_follower(my_profile.id):\n",
    "    print(user)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7f9e0c76-81e9-4335-8b0e-84da4d489fb4",
   "metadata": {},
   "source": [
    "#### 8. 收听历史"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "8da10ea5-0ad4-4c6f-ba81-9d640ae4ba97",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Episode(eid=687ce8e4a9dec925003c8efd, pid=60de7c003dd577b40d5a40f3, title=布拉德·皮特银幕上演 F1 传奇，现实世界为何却少有美国车手？)\n",
      "Episode(eid=68787863a12f9ff06a9448f8, pid=65716792d6e0ff5822d25668, title=E26 你离用好定投这个武器，只差这一期内容！| 实操篇)\n",
      "Episode(eid=683e851c38dcc57c644718eb, pid=62382c1103bea1ebfffa1c00, title=No.153 📠 「史前」科技巨头四通与中关村教父 | 中国互联网故事1)\n",
      "Episode(eid=6879df2da9dec92500e81fdf, pid=5f912d9783c34e85ddd7e23d, title=179.身体已不是从前那个少年，however心还是。)\n",
      "Episode(eid=68776e08f01740ccc77a596b, pid=5e280faa418a84a0461f9ad8, title=vol.719 请马伯庸亲自说说《长安的荔枝》的创作秘辛)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for episode in c.history.list():\n",
    "    print(episode)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "99a6fd8d-9156-4cc1-994f-aaeb71bdb22c",
   "metadata": {},
   "source": [
    "#### 9. 收藏的单集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "d612926d-1994-4a9d-bb02-94401fc46890",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Episode(eid=6626ece8db5f58a80d0d31db, pid=5e4515bd418a84a046e2b11a, title=Vol.227 世界读书日，跟143位主播共享一份书单)\n",
      "Episode(eid=66291d2cff598d65f202b6a1, pid=5e280faa418a84a0461f9ad8, title=vol.615 和纵横四海携隐Melody聊聊如何摆脱“时间贫困”)\n",
      "Episode(eid=6452e781b7b3c21b65ce4669, pid=6022a180ef5fdaddc30bb101, title=Vol.109 当今最重要的基础设施，在海底)\n",
      "Episode(eid=68776e08f01740ccc77a596b, pid=5e280faa418a84a0461f9ad8, title=vol.719 请马伯庸亲自说说《长安的荔枝》的创作秘辛)\n",
      "Episode(eid=6426bfd13f40bdefe7f4aaf7, pid=5e280fad418a84a0461fb38b, title=E714.「废物」作家自述：想过正常的有尊严的生活，怎么这么难)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for episode in c.favorited_episode.list():\n",
    "    print(episode)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "f331d872-5108-48a9-b102-a303ac4b5419",
   "metadata": {},
   "source": [
    "#### 10. 收藏的评论"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "16df8e3b-b2ee-430c-9a3f-292e67106455",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Comment(id=635724ff0236bb00100d5aca, text=【萌二评论📑文化有限の合集，请接收！】\n",
      "🌠频道仪式\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/5e4515bd418a84a046e2b128 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/6164c36ebcb2fee71fae4c24 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/633b6a39a5d434d0ee91ba9f \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/62e85c62472e726a52ecd888 \n",
      "🌠综合特缉\n",
      "🌸春日篇：\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/603d758f30638eea2cef9e2f \n",
      "🏖夏日篇：\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/62b0fcb8ba5434fc2d660540 \n",
      "🍁秋日篇：\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/6328f4b63210b0e9e7708a52 \n",
      "🍾节日篇：春节+圣诞+万圣+感恩\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/61f86b2680651919bbdee145 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/61ba74e7a7eccbe3918adf69 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/6177395577a31cddee7b74ea \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/5fbc4f9ddee9c1e16db222ba \n",
      "🌠朗诵配乐\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/60da58b403c9bf1da959dd08 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/62f196e803da6b049bdbeef7 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/61e5f62aeffcbded188a717f \n",
      "🌠读书写作\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/5f56ce8283c34e85dd275e4f \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/5ec3bd68418a84a046a8fc24 \n",
      "🌠精准沟通\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/63322f7e120ae67f87490f03 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/61b7d22c248ff750af64e1ee \n",
      "🌠家庭亲子\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/62c371b595b30b04003c661f \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/5e4515bd418a84a046e2b133 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/6062612b3bdce47be7e06c36 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/63040af7e72c1f7ae44e7258 \n",
      "🌠心理健康\n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/611aeeef629a774bd842ec2d \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/62141a78c8cea1e1315e52a0 \n",
      "🔗 https://www.xiaoyuzhoufm.com/episode/630d450dc69aabcde0f1b0d6)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for comment in c.favorited_comment.list():\n",
    "    print(comment)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "ce876037-5711-4fd5-8eab-a148c2016c99",
   "metadata": {},
   "source": [
    "#### 11. 搜索节目"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "d9386e39-2dc1-491e-9eb6-4231aedab6f9",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Podcast(pid=5e280fa7418a84a0461f912b, title=谐星聊天会)\n",
      "Podcast(pid=660840711519139e4f9699ef, title=小fool人)\n",
      "Podcast(pid=65bb55f6513a776b57dedb32, title=李诞)\n",
      "Podcast(pid=60e43cecc4e7c8188c2f92a4, title=正经叭叭)\n",
      "Podcast(pid=61791d921989541784257779, title=不开玩笑 Jokes Aside)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for podcast in c.podcast_search.search(\"脱口秀\"):\n",
    "    print(podcast)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "66866ff2-0c47-49d5-b775-8b27c458e34b",
   "metadata": {},
   "source": [
    "#### 12. 搜索单集"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "04e33d66-05a9-4d26-8d5f-aaaa0e5898d0",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Episode(eid=6873dcc11317e91f3d8f9ed8, pid=5e280fac418a84a0461fb129, title=vol.533 老友聊聊｜2025悄悄过半，再不总结真记不住啦！)\n",
      "Episode(eid=685f7c4608d8fd858666e5c5, pid=67b92c728671d63e927d8eee, title=单独系列 - 2025下半年经济和市场展望)\n",
      "Episode(eid=6819fac3d8d622bb801bd343, pid=61dd99a47b29652ff572257b, title=vol.127.年报季中的真实中国2025)\n",
      "Episode(eid=68498a63096eb0bc79503c69, pid=61dd99a47b29652ff572257b, title=132.当过度思考的打工人遇上低欲望的时代)\n",
      "Episode(eid=6853fc0db3d7fd80a40cb5ee, pid=5e2831ed418a84a046231c00, title=#Bonus  逃离德黑兰 2025：一个中国人的战火逃生记)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for episode in c.episode_search.search(\"2025\"):\n",
    "    print(episode)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8baf14e9-0999-4f57-ad8d-0977a7244ecf",
   "metadata": {},
   "source": [
    "#### 13. 搜索用户"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2a23fdeb-8032-4347-b3bc-d7fb2cec1dbf",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "User(uid=5e50e0e3e3edfc2abb066657, nickname=七个梦)\n",
      "User(uid=66097132edce67104a10aeaf, nickname=有七个梦)\n",
      "User(uid=60d74289e0f5e723bbefe494, nickname=第七个梦)\n"
     ]
    }
   ],
   "source": [
    "cnt = 0\n",
    "async for user in c.user_search.search(\"七个梦\"):\n",
    "    print(user)\n",
    "    cnt += 1\n",
    "    if cnt >= 5:\n",
    "        break"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "94a0efad-fb51-44e6-8ba6-5a79d0a6af85",
   "metadata": {},
   "source": [
    "#### 用完后，别忘了"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "3efe9873-cb3b-488a-b006-6aec02491e23",
   "metadata": {},
   "outputs": [],
   "source": [
    "await c.close()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.13.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
