15f161e5b5
Reddit: Exa crawling had chronic CRAWL_LIVECRAWL_TIMEOUT issues. rdt-cli (304 stars, public-clis) works without login — search, read full posts, and comments all verified. Massive improvement. Bilibili: add bili-cli (590 stars) as optional enhanced backend for hot/rank/search/feed. yt-dlp remains for video metadata + subtitles. Also fix UA string (was "agent-reach/1.0", now proper browser UA). 75 tests passing. Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
863 B
Python
32 lines
863 B
Python
# -*- coding: utf-8 -*-
|
||
"""Reddit — search and read via rdt-cli (public-clis/rdt-cli)."""
|
||
|
||
import shutil
|
||
import subprocess
|
||
from .base import Channel
|
||
|
||
|
||
class RedditChannel(Channel):
|
||
name = "reddit"
|
||
description = "Reddit 帖子和评论"
|
||
backends = ["rdt-cli"]
|
||
tier = 0
|
||
|
||
def can_handle(self, url: str) -> bool:
|
||
from urllib.parse import urlparse
|
||
d = urlparse(url).netloc.lower()
|
||
return "reddit.com" in d or "redd.it" in d
|
||
|
||
def check(self, config=None):
|
||
rdt = shutil.which("rdt")
|
||
if rdt:
|
||
return "ok", (
|
||
"rdt-cli 可用(搜索帖子、阅读全文、查看评论,无需登录)"
|
||
)
|
||
return "off", (
|
||
"需要安装 rdt-cli:\n"
|
||
" pipx install rdt-cli\n"
|
||
"或:\n"
|
||
" uv tool install rdt-cli"
|
||
)
|