diff --git a/README.md b/README.md index 13a70ca..1f9656f 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,22 @@ # tmdb-person -根据nfo文件信息刮削相关演员信息及图片 \ No newline at end of file +根据nfo文件信息刮削相关演员信息及图片 + +## example +> emby 存储于metadata/peopel 中的数据示例 + +> 电视剧tvs 和 电影movies 的保存 `.nfo` 命名格式不一样。movies的 `.nfo` 文件以电影名为前缀, tvs 统一以 `tvshow.nfo` 命名 + +* a: 英文演员信息 +* 张: 中文演员信息 +* person.nfo +* tvshow.nfo + +## data +> 实际刮削的演员信息存放路径 + +## 接口 +> https://developer.themoviedb.org/ + +1. 演员信息刮削:https://developer.themoviedb.org/reference/person-details +2. 图片统一前缀路径:https://www.themoviedb.org/t/p/original \ No newline at end of file diff --git a/example/a/Alan Rickman-tmdb-4566/folder.jpg b/example/a/Alan Rickman-tmdb-4566/folder.jpg new file mode 100755 index 0000000..ec10619 Binary files /dev/null and b/example/a/Alan Rickman-tmdb-4566/folder.jpg differ diff --git a/example/a/Alan Tudyk-tmdb-21088/folder.jpg b/example/a/Alan Tudyk-tmdb-21088/folder.jpg new file mode 100755 index 0000000..6913961 Binary files /dev/null and b/example/a/Alan Tudyk-tmdb-21088/folder.jpg differ diff --git a/example/a/Allen Ai Lun-tmdb-1519031/folder.jpg b/example/a/Allen Ai Lun-tmdb-1519031/folder.jpg new file mode 100755 index 0000000..89824ef Binary files /dev/null and b/example/a/Allen Ai Lun-tmdb-1519031/folder.jpg differ diff --git a/example/a/Andrew Garfield-tmdb-37625/folder.jpg b/example/a/Andrew Garfield-tmdb-37625/folder.jpg new file mode 100755 index 0000000..a2a0731 Binary files /dev/null and b/example/a/Andrew Garfield-tmdb-37625/folder.jpg differ diff --git a/example/a/Andy Samberg-tmdb-62861/folder.jpg b/example/a/Andy Samberg-tmdb-62861/folder.jpg new file mode 100755 index 0000000..975164f Binary files /dev/null and b/example/a/Andy Samberg-tmdb-62861/folder.jpg differ diff --git a/example/a/Andy Umberger-tmdb-142204/folder.jpg b/example/a/Andy Umberger-tmdb-142204/folder.jpg new file mode 100755 index 0000000..3911835 Binary files /dev/null and b/example/a/Andy Umberger-tmdb-142204/folder.jpg differ diff --git a/example/a/Annie Potts-tmdb-8873/folder.jpg b/example/a/Annie Potts-tmdb-8873/folder.jpg new file mode 100755 index 0000000..e11af94 Binary files /dev/null and b/example/a/Annie Potts-tmdb-8873/folder.jpg differ diff --git a/example/person.nfo b/example/person.nfo new file mode 100755 index 0000000..2c3e8ad --- /dev/null +++ b/example/person.nfo @@ -0,0 +1,11 @@ + + + + + false + 2023-08-26 05:05:20 + 朱一龙 + 朱一龙 + 1743471 + 1743471 + \ No newline at end of file diff --git a/example/tvshow.nfo b/example/tvshow.nfo new file mode 100644 index 0000000..1b66857 --- /dev/null +++ b/example/tvshow.nfo @@ -0,0 +1,96 @@ + + + + + false + 2023-09-02 22:49:29 + 一生一世 + 一生一世 + + Ren Jialun + Zhousheng Chen + Actor + 2084465 + + + Bai Lu + Shi Yi + Actor + 1879666 + + + Ci Sha + Mei Xing + Actor + 3167855 + + + Wang Yueyi + Hong Xiaoyu + Actor + 3161424 + + + Luo Mingjie + Zhou Wenchuan + Actor + 2359338 + + + Wang Ruixin + Zhou Wenxing + Actor + 3177467 + + + Luo Haiqiong + Qin Wan + Actor + 1363325 + + + Feng Jia-Yi + Zhou Shengxing + Actor + 1613707 + + + Wang Xiwen + Actor + 3177468 + + + Ye Xiaowei + Actor + 2790196 + + + Liu Ruogu + Zhou Shengren + Actor + 2747081 + + Shen Yang + http://www.youtube.com/watch?v=ZGymduZZhqg + 7.4 + 2021 + 一生一世 + tt14324128 + 130107 + 2021-09-06 + 2021-09-06 + 2021-10-03 + 50 + 剧情 + iQiyi + tt14324128 + 130107 + 402985 + 402985 + {"imdb":"tt14324128","tmdb":"130107","tvdb":"402985"} + 402985 + -1 + -1 + aired + Ended + \ No newline at end of file diff --git a/example/张/张晚意-tmdb-3028958/person.nfo b/example/张/张晚意-tmdb-3028958/person.nfo new file mode 100755 index 0000000..4762114 --- /dev/null +++ b/example/张/张晚意-tmdb-3028958/person.nfo @@ -0,0 +1,13 @@ + + + + + false + 2023-08-26 16:06:51 + 张晚意 + 张晚意 + nm9545744 + 3028958 + 3028958 + nm9545744 + \ No newline at end of file diff --git a/example/神出鬼没 (2023) - 2160p.nfo b/example/神出鬼没 (2023) - 2160p.nfo new file mode 100644 index 0000000..ff9b04b --- /dev/null +++ b/example/神出鬼没 (2023) - 2160p.nfo @@ -0,0 +1,522 @@ + + + + + false + 2023-04-23 19:26:54 + 神出鬼没 + Ghosted + + Chris Evans + Cole Turner + Actor + 16828 + + + Ana de Armas + Sadie Rhodes + Actor + 224513 + + + 艾德里安·布洛迪 + Leveque + Actor + 3490 + + + 麦克·莫 + Wagner + Actor + 1324443 + + + 泰特·多诺万 + Dad + Actor + 15455 + + + 艾米·塞德丽丝 + Mom + Actor + 12110 + + + 丽兹·布罗德威 + Mattie Turner + Actor + 1376782 + + + Mustafa Shakir + Monte Jackson + Actor + 62385 + + + Anthony Mackie + Grandson of Sam + Actor + 53650 + + + John Cho + The Leopard + Actor + 68842 + + + Sebastian Stan + God + Actor + 60898 + + + Ryan Reynolds + Jonas + Actor + 10859 + + + 安娜·迪佛·史密斯 + Claudia Yates + Actor + 63279 + + + Tim Blake Nelson + Borislov + Actor + 1462 + + + 蒂娅·希尔卡 + Patti + Actor + 109046 + + + Steve Park + Utami + Actor + 4025 + + + Burn Gorman + English Cabbie + Actor + 39659 + + + Marwan Kenzari + Marco + Actor + 935235 + + + Victoria Garcia-Kelleher + Edna + Actor + 1500108 + + + Jordan Blair Mangold Brown + Joann + Actor + 1999675 + + + 德克斯特·弗莱彻 + Raoul + Actor + 974 + + 德克斯特·弗莱彻 + plugin://plugin.video.youtube/?action=play_video&videoid=IAdCsNtEuBU + 5.8 + 2023 + 神出鬼没 + PG-13 + tt15326988 + 868759 + 2023-04-21 + 2023-04-21 + 117 + United States of America + 爱情 + 动作 + 喜剧 + Skydance Media + Apple Studios + tt15326988 + 868759 + tt15326988 + + + + + + subrip + subrip + eng + progressive + False + False + + + subrip + subrip + eng + progressive + False + False + + + subrip + subrip + ara + progressive + False + False + + + subrip + subrip + bul + progressive + False + False + + + subrip + subrip + cze + progressive + False + False + + + subrip + subrip + dan + progressive + False + False + + + subrip + subrip + ger + progressive + False + False + + + subrip + subrip + gre + progressive + False + False + + + subrip + subrip + spa + progressive + False + False + + + subrip + subrip + spa + progressive + False + False + + + subrip + subrip + est + progressive + False + False + + + subrip + subrip + fin + progressive + False + False + + + subrip + subrip + fre + progressive + False + False + + + subrip + subrip + fre + progressive + False + False + + + subrip + subrip + heb + progressive + False + False + + + subrip + subrip + hin + progressive + False + False + + + subrip + subrip + hun + progressive + False + False + + + subrip + subrip + ind + progressive + False + False + + + subrip + subrip + ita + progressive + False + False + + + subrip + subrip + jpn + progressive + False + False + + + subrip + subrip + kor + progressive + False + False + + + subrip + subrip + lit + progressive + False + False + + + subrip + subrip + lav + progressive + False + False + + + subrip + subrip + may + progressive + False + False + + + subrip + subrip + dut + progressive + False + False + + + subrip + subrip + nor + progressive + False + False + + + subrip + subrip + pol + progressive + False + False + + + subrip + subrip + por + progressive + False + False + + + subrip + subrip + por + progressive + False + False + + + subrip + subrip + rus + progressive + False + False + + + subrip + subrip + slo + progressive + False + False + + + subrip + subrip + slv + progressive + False + False + + + subrip + subrip + swe + progressive + False + False + + + subrip + subrip + tam + progressive + False + False + + + subrip + subrip + tel + progressive + False + False + + + subrip + subrip + tha + progressive + False + False + + + subrip + subrip + tur + progressive + False + False + + + subrip + subrip + ukr + progressive + False + False + + + subrip + subrip + vie + progressive + False + False + + + subrip + subrip + chi + progressive + False + False + + + subrip + subrip + chi + progressive + False + False + + + subrip + subrip + chi + progressive + False + False + + + + \ No newline at end of file diff --git a/person.py b/person.py new file mode 100644 index 0000000..b049764 --- /dev/null +++ b/person.py @@ -0,0 +1,75 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +import requests +import os +import xml.etree.ElementTree as ET +import json + + +class Analyze: + def __init__(self, file_path): + self.file_path = file_path + + def analyze(self): + tree = ET.parse(self.file_path) + root = tree.getroot() + if "tvshow" in root.tag: + data_json = {} + self.__list_nodes(root, data_json) + return data_json + if "movie" in root.tag: + data_json = {} + self.__list_nodes(root, data_json) + return data_json + + def __list_nodes(self, root, data): + actors = [] + for node in root: + if 0 == len(list(node)): + data[node.tag] = node.text + elif "actor" == node.tag: + actor_json = {} + self.__list_nodes(node, actor_json) + actors.append(actor_json) + data["actors"] = actors + + +class Tmdb: + def __init__(self, tmdb_id, actor_path): + self.image_path = None + self.tmdb_id = tmdb_id + self.actor_path = actor_path + + def get_actor_info(self): + url = "https://api.themoviedb.org/3/person/" + self.tmdb_id + "?language=zh-CN" + headers = { + "accept": "application/json", + "Authorization": "Bearer eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiIxYTU4ODAxMGY5OTUwYWEyNThhYjFhYjJlMjI4NGVmYSIsInN1YiI6IjYxYmRmOGNjMzgzZGYyMDA0MjIzNDhjOSIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.RPG8F8AELlK7MgrXDR2U0YRv61VteZZ9ponilnkQqkE" + } + response = requests.get(url, headers=headers) + return response.text + + def get_actor_image(self): + image_path = json.loads(self.get_actor_info())["profile_path"] + url = 'https://www.themoviedb.org/t/p/original' + image_path + response = requests.get(url) + if response.status_code == 200: + suffix = image_path.split(".")[1] + with open(os.path.join(self.actor_path, "folder." + suffix), 'wb') as f: + f.write(response.content) + + +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()