Files
SakuraHub/tests/manual_douyin_smoke.py
2026-11-16 20:45:22 +08:00

43 lines
1.3 KiB
Python

from __future__ import annotations
import json
import os
from pathlib import Path
from plugins.douyin.plugin import DouyinPlugin
URL = "https://www.douyin.com/jingxuan?modal_id=7635574968763288867"
def main() -> None:
plugin = DouyinPlugin()
resource = plugin.parse(URL)[0]
downloaded: list[str] = []
if os.environ.get("SAKURA_DOUYIN_SMOKE_DOWNLOAD") == "1":
original_files = resource.files
resource.files = resource.files[:1]
downloaded = [str(path) for path in plugin.download(resource, Path("runtime/douyin_smoke_downloads"))]
resource.files = original_files
print(
json.dumps(
{
"ok": True,
"id": resource.id,
"title": resource.title[:80],
"author": resource.author,
"file_count": len(resource.files),
"file_types": [file.get("type") for file in resource.files],
"downloaded": downloaded,
},
ensure_ascii=False,
)
)
if os.environ.get("SAKURA_DOUYIN_SMOKE_VERBOSE") == "1":
for index, file in enumerate(resource.files[:30]):
print(f"{index}: {file.get('type')} {str(file.get('url') or '')[:180]}")
if __name__ == "__main__":
main()