mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-07-12 16:11:34 +08:00
feat(download): 添加快手下载器并优化下载配置功能
- 新增快手下载器,支持快手视频下载 - 添加下载配置页面,可设置各平台Cookies - 优化后端接口,增加获取和更新Cookies的功能 - 前端新增Downloader组件和相关表单组件 - 更新路由配置,增加下载配置相关路由
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
from app.downloaders.bilibili_downloader import BilibiliDownloader
|
||||
from app.downloaders.douyin_downloader import DouyinDownloader
|
||||
from app.downloaders.kuaishou_downloader import KuaiShouDownloader
|
||||
from app.downloaders.local_downloader import LocalDownloader
|
||||
from app.downloaders.youtube_downloader import YoutubeDownloader
|
||||
|
||||
@@ -7,6 +8,7 @@ SUPPORT_PLATFORM_MAP = {
|
||||
'youtube':YoutubeDownloader(),
|
||||
'bilibili':BilibiliDownloader(),
|
||||
'tiktok':DouyinDownloader(),
|
||||
'kuaishou':KuaiShouDownloader(),
|
||||
'douyin':DouyinDownloader(),
|
||||
'local':LocalDownloader()
|
||||
}
|
||||
44
backend/app/services/cookie_manager.py
Normal file
44
backend/app/services/cookie_manager.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
from typing import Optional, Dict
|
||||
|
||||
|
||||
class CookieConfigManager:
|
||||
def __init__(self, filepath: str = "config/downloader.json"):
|
||||
self.path = Path(filepath)
|
||||
self.path.parent.mkdir(parents=True, exist_ok=True)
|
||||
if not self.path.exists():
|
||||
self._write({})
|
||||
|
||||
def _read(self) -> Dict[str, Dict[str, str]]:
|
||||
try:
|
||||
with self.path.open("r", encoding="utf-8") as f:
|
||||
return json.load(f)
|
||||
except Exception:
|
||||
return {}
|
||||
|
||||
def _write(self, data: Dict[str, Dict[str, str]]):
|
||||
with self.path.open("w", encoding="utf-8") as f:
|
||||
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||
|
||||
def get(self, platform: str) -> Optional[str]:
|
||||
data = self._read()
|
||||
return data.get(platform, {}).get("cookie")
|
||||
|
||||
def set(self, platform: str, cookie: str):
|
||||
data = self._read()
|
||||
data[platform] = {"cookie": cookie}
|
||||
self._write(data)
|
||||
|
||||
def delete(self, platform: str):
|
||||
data = self._read()
|
||||
if platform in data:
|
||||
del data[platform]
|
||||
self._write(data)
|
||||
|
||||
def list_all(self) -> Dict[str, str]:
|
||||
data = self._read()
|
||||
return {k: v.get("cookie", "") for k, v in data.items()}
|
||||
|
||||
def exists(self, platform: str) -> bool:
|
||||
return self.get(platform) is not None
|
||||
Reference in New Issue
Block a user