-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: 拷贝一份 poster 作为 fanart 使用 (#84)
* feat: 拷贝一份 poster 作为 fanart 使用 * feat: 添加对于现有视频的迁移脚本
- Loading branch information
Showing
2 changed files
with
53 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
""" | ||
2.0.2 -> 2.0.3 时添加了将 poster 拷贝为 fanart 的行为 | ||
该行为对已存在的视频不会生效,所以可以手动执行该脚本 | ||
具体来说,该脚本会: | ||
1. 遍历命令行参数中所有存在的路径 | ||
2. 找到路径中所有以 poster.jpg 结尾的文件 | ||
3. 将 poster.jpg 替换为 fanart.jpg,拷贝到同一目录 | ||
""" | ||
|
||
import os | ||
import sys | ||
import shutil | ||
from pathlib import Path | ||
|
||
|
||
def main(): | ||
if len(sys.argv) <= 1: | ||
print("用法: python 2.0.3_add_fanart.py <path1> <path2> ...") | ||
exit(1) | ||
paths = [Path(path) for path in sys.argv[1:]] | ||
for path in paths: | ||
if not path.exists(): | ||
print(f"路径 {path} 不存在,跳过..") | ||
continue | ||
for root, _, files in os.walk(path): | ||
for file in files: | ||
if file.endswith("poster.jpg"): | ||
poster_path = Path(root) / file | ||
print(f"已找到 poster: {poster_path}") | ||
fanart_path = Path(root) / file.replace("poster.jpg", "fanart.jpg") | ||
shutil.copyfile(poster_path, fanart_path) | ||
print(f"已将 {poster_path} 拷贝至 {fanart_path}") | ||
print("操作完成") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters