add: 刮削演员信息并生成相应目录结构和演员图片

This commit is contained in:
Carol 2023-09-06 09:48:24 +08:00
parent 725d04a768
commit 7da6f43ab3
14 changed files with 96 additions and 20 deletions

7
.gitignore vendored
View File

@ -160,3 +160,10 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
/.idea/.gitignore
/.idea/misc.xml
/.idea/modules.xml
/.idea/inspectionProfiles/profiles_settings.xml
/.idea/inspectionProfiles/Project_Default.xml
/.idea/tmdb-person.iml
/.idea/vcs.xml

View File

@ -1,22 +1,73 @@
# tmdb-person
![](https://img.shields.io/badge/Python-3.8-green)
![](https://img.shields.io/badge/TMDB-V3-blue)
根据nfo文件信息刮削相关演员信息及图片
## example
## 数据
### example
> emby 存储于metadata/peopel 中的数据示例
> 电视剧tvs 和 电影movies 的保存 `.nfo` 命名格式不一样。movies的 `.nfo` 文件以电影名为前缀, tvs 统一以 `tvshow.nfo` 命名
* a: 英文演员信息
* 张: 中文演员信息
* person.nfo
* tvshow.nfo
* example/metadata/person/a: 英文演员信息
* example/metadata/person/张: 中文演员信息
* example/metadata/person/person.nfo: 演员元数据
* example/tvs/一生一世/tvshow.nfo: 电视剧元数据
* example/movies/神出鬼没 (2023) - 2160p.nfo: 电影元数据
## data
### data
> 实际刮削的演员信息存放路径
## 接口
> https://developer.themoviedb.org/
1. 演员信息刮削https://developer.themoviedb.org/reference/person-details
2. 图片统一前缀路径https://www.themoviedb.org/t/p/original
2. 图片统一前缀路径https://www.themoviedb.org/t/p/original
## 使用
* 环境Python3.8
### 安装相关pip依赖包
```python
pip3 install requests
pip3 install os
pip3 install xml
pip3 install json
```
### 说明
**`参数说明`**
* __dir_path: 目标文件夹路径。
* 例如电影存放于 `./movies/` 下,则该路径填写 `./movies` 的完整路径。
* 为了兼容 `电视剧` 中不刮削 `季` 中的 `.nfo` 内容,因此只刮削 `__dir_path` 路径下一层文件夹及当前层下的 `.nfo` 文件(兼容./movies 下同级存放的视频及.nfo文件)
**`目录结构说明`**
- ./movies
- 流浪地球.mkv (不刮削)
- 流浪地球.nfo (刮削)
- 流浪地球2
- 流浪地球2.mkv (不刮削)
- 流浪地球2.nfo (刮削)
- ./tvs
- 三体
- tvshow.nfo (刮削)
- Season 1 (不刮削)
### 运行
**`方法一:`**
修改 `person.py` 文件中 `if __name__ == '__main__':` 方法中 `__dir_path` 参数值
**`方法二:`**
> 通过命令行方式设置参数
```python
python3 person.py /volume1/video/movies
```

View File

Before

Width:  |  Height:  |  Size: 242 KiB

After

Width:  |  Height:  |  Size: 242 KiB

View File

Before

Width:  |  Height:  |  Size: 51 KiB

After

Width:  |  Height:  |  Size: 51 KiB

View File

Before

Width:  |  Height:  |  Size: 57 KiB

After

Width:  |  Height:  |  Size: 57 KiB

View File

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 94 KiB

View File

Before

Width:  |  Height:  |  Size: 442 KiB

After

Width:  |  Height:  |  Size: 442 KiB

View File

Before

Width:  |  Height:  |  Size: 124 KiB

After

Width:  |  Height:  |  Size: 124 KiB

View File

Before

Width:  |  Height:  |  Size: 40 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -60,16 +60,34 @@ class Tmdb:
if __name__ == '__main__':
__nfo_data = Analyze(file_path="example/神出鬼没 (2023) - 2160p.nfo").analyze()
for __actor in __nfo_data["actors"]:
__tmdbid = __actor["tmdbid"]
__actor_name = __actor["name"]
__name = __actor_name[1].lower()
__path_dir = os.path.join("data", __name, __actor_name)
if not os.path.exists(__path_dir):
os.makedirs(__path_dir)
if ".nfo" not in os.listdir(__path_dir):
__actor_info = Tmdb(tmdb_id=__tmdbid, actor_path=__path_dir).get_actor_info()
print(__actor_info)
if "folder" not in os.listdir(__path_dir):
Tmdb(tmdb_id=__tmdbid, actor_path=__path_dir).get_actor_image()
__dir_path = "example/tvs"
__output = "example/metadata/person"
__file_paths = []
for folder in os.listdir(__dir_path):
__folder2 = os.path.join(__dir_path, folder)
# 判断是否文件夹
if os.path.isdir(__folder2):
for nfo_file in os.listdir(__folder2):
__child_file_path = os.path.join(__folder2, nfo_file)
if ".nfo" in os.path.basename(__child_file_path):
__file_paths.append(__child_file_path)
elif os.path.isfile(__folder2):
__file_name = os.path.basename(__folder2)
if ".nfo" in __file_name:
__file_paths.append(__folder2)
print(__file_paths)
for __file_path in __file_paths:
# __file_path = "example/神出鬼没 (2023) - 2160p.nfo"
__nfo_data = Analyze(file_path=__file_path).analyze()
for __actor in __nfo_data["actors"]:
__tmdbid = __actor["tmdbid"]
__actor_name = __actor["name"]
__name = __actor_name[1].lower()
__path_dir = os.path.join(__output, __name, __actor_name)
if not os.path.exists(__path_dir):
os.makedirs(__path_dir)
if ".nfo" not in os.listdir(__path_dir):
__actor_info = Tmdb(tmdb_id=__tmdbid, actor_path=__path_dir).get_actor_info()
print(__actor_info)
if "folder" not in os.listdir(__path_dir):
Tmdb(tmdb_id=__tmdbid, actor_path=__path_dir).get_actor_image()