feat: add new template variable `download_date` (#107) (#108)

This commit is contained in:
Nyakku Shigure 2023-02-04 16:58:59 +08:00 committed by GitHub
parent b592110d6a
commit a3b63ef23c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 5 deletions

View File

@ -299,7 +299,10 @@ yutto <url> -c "d8bc7493%2C2843925707%2C08c3e*81"
|username|UP 主用户名|个人空间、收藏夹、合集、视频列表下载|
|series_title|合集标题|收藏夹、视频合集、视频列表下载|
|pubdate|投稿日期|仅投稿视频|
|download_date|下载日期|全部|
> **Note**
>
> 未来可能会对路径变量及默认路径模板进行调整
#### url 别名文件路径

View File

@ -168,7 +168,7 @@ def _parse_bangumi_metadata(item: dict[str, Any]) -> MetaData:
plot=item["share_copy"],
thumb=item["cover"],
premiered=get_time_str_by_stamp(item["pub_time"]),
dataadded=get_time_str_by_now(),
dateadded=get_time_str_by_now(),
source="", # TODO
original_filename="", # TODO
)

View File

@ -248,7 +248,7 @@ def _parse_ugc_video_metadata(video_info: _UgcVideoInfo, page_info: _UgcVideoPag
plot=video_info["description"],
thumb=page_info["first_frame"] if page_info["first_frame"] is not None else video_info["picture"],
premiered=get_time_str_by_stamp(video_info["pubdate"]),
dataadded=get_time_str_by_now(),
dateadded=get_time_str_by_now(),
source="", # TODO
original_filename="", # TODO
)

View File

@ -57,6 +57,7 @@ async def extract_bangumi_data(
"username": UNKNOWN,
"series_title": UNKNOWN,
"pubdate": UNKNOWN,
"download_date": bangumi_info["metadata"]["dateadded"],
}
subpath_variables_base.update(subpath_variables)
subpath = resolve_path_template(args.subpath_template, auto_subpath_template, subpath_variables_base)
@ -100,6 +101,7 @@ async def extract_ugc_video_data(
"username": UNKNOWN,
"series_title": UNKNOWN,
"pubdate": UNKNOWN,
"download_date": ugc_video_info["metadata"]["dateadded"],
}
subpath_variables_base.update(subpath_variables)
subpath = resolve_path_template(args.subpath_template, auto_subpath_template, subpath_variables_base)

View File

@ -6,8 +6,7 @@ from typing import Literal, Union
from yutto.utils.console.logger import Logger
path_template_variables = ["title", "id", "name", "username"]
PathTemplateVariable = Literal["title", "id", "name", "username", "series_title", "pubdate"]
PathTemplateVariable = Literal["title", "id", "name", "username", "series_title", "pubdate", "download_date"]
PathTemplateVariableDict = dict[PathTemplateVariable, Union[int, str]]
UNKNOWN: str = "unknown_variable"

View File

@ -13,7 +13,7 @@ class MetaData(TypedDict):
plot: str
thumb: str
premiered: str
dataadded: str
dateadded: str
source: str
original_filename: str