mirror of
https://github.com/JefferyHcool/BiliNote.git
synced 2026-09-07 08:36:39 +08:00
feat(frontend): 新增多版本笔记功能,并做了向下兼容。
- 新增关于页面组件,介绍项目背景、功能和使用方法 - 重构笔记生成逻辑,支持多版本笔记 - 新增笔记版本选择、复制和导出功能 -优化笔记界面布局和交互 - 调整部分组件样式,提升用户体验
This commit is contained in:
@@ -7,6 +7,7 @@ import yt_dlp
|
||||
from app.downloaders.base import Downloader, DownloadQuality, QUALITY_MAP
|
||||
from app.models.notes_model import AudioDownloadResult
|
||||
from app.utils.path_helper import get_data_dir
|
||||
from app.utils.url_parser import extract_video_id
|
||||
|
||||
|
||||
class BilibiliDownloader(Downloader, ABC):
|
||||
@@ -69,10 +70,19 @@ class BilibiliDownloader(Downloader, ABC):
|
||||
"""
|
||||
下载视频,返回视频文件路径
|
||||
"""
|
||||
|
||||
if output_dir is None:
|
||||
output_dir = get_data_dir()
|
||||
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
print("video_url",video_url)
|
||||
video_id=extract_video_id(video_url, "bilibili")
|
||||
video_path = os.path.join(output_dir, f"{video_id}.mp4")
|
||||
if os.path.exists(video_path):
|
||||
return video_path
|
||||
|
||||
# 检查是否已经存在
|
||||
|
||||
|
||||
output_path = os.path.join(output_dir, "%(id)s.%(ext)s")
|
||||
|
||||
ydl_opts = {
|
||||
|
||||
@@ -249,13 +249,21 @@ class DouyinDownloader(Downloader):
|
||||
)
|
||||
|
||||
def download_video(self, video_url: str, output_dir: Union[str, None] = None) -> str:
|
||||
|
||||
try:
|
||||
|
||||
if output_dir is None:
|
||||
output_dir = get_data_dir()
|
||||
if not output_dir:
|
||||
output_dir = self.cache_data
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
|
||||
video_id = self.extract_video_id(video_url)
|
||||
video_path = os.path.join(output_dir, f"{video_id}.mp4")
|
||||
if os.path.exists(video_path):
|
||||
return video_path
|
||||
|
||||
|
||||
output_path = os.path.join(output_dir, "%(id)s.%(ext)s")
|
||||
|
||||
video_data = self.fetch_video_info(video_url)
|
||||
|
||||
@@ -7,6 +7,7 @@ import yt_dlp
|
||||
from app.downloaders.base import Downloader, DownloadQuality
|
||||
from app.models.notes_model import AudioDownloadResult
|
||||
from app.utils.path_helper import get_data_dir
|
||||
from app.utils.url_parser import extract_video_id
|
||||
|
||||
|
||||
class YoutubeDownloader(Downloader, ABC):
|
||||
@@ -67,12 +68,15 @@ class YoutubeDownloader(Downloader, ABC):
|
||||
"""
|
||||
if output_dir is None:
|
||||
output_dir = get_data_dir()
|
||||
|
||||
video_id = extract_video_id(video_url, "youtube")
|
||||
video_path = os.path.join(output_dir, f"{video_id}.mp4")
|
||||
if os.path.exists(video_path):
|
||||
return video_path
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
output_path = os.path.join(output_dir, "%(id)s.%(ext)s")
|
||||
|
||||
ydl_opts = {
|
||||
'format': 'worst[ext=mp4]/worst',
|
||||
'format': 'bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]',
|
||||
'outtmpl': output_path,
|
||||
'noplaylist': True,
|
||||
'quiet': False,
|
||||
|
||||
Reference in New Issue
Block a user