fix: 修复演员简介不存在问题
This commit is contained in:
parent
2432d6fa3a
commit
18a49ec65b
38
tmdb.py
38
tmdb.py
|
@ -1,5 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
import logging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
@ -47,22 +49,27 @@ class Tmdb:
|
||||||
url = api_url + "/3/person/" + self.tmdb_id + "/translations"
|
url = api_url + "/3/person/" + self.tmdb_id + "/translations"
|
||||||
headers = self.header
|
headers = self.header
|
||||||
response = requests.get(url, headers=headers)
|
response = requests.get(url, headers=headers)
|
||||||
return response.text
|
if 200 == response.status_code:
|
||||||
|
return response.text
|
||||||
|
else:
|
||||||
|
return "{}"
|
||||||
|
|
||||||
def get_actor_plot(self):
|
def get_actor_plot(self):
|
||||||
translations = self.__translations()
|
|
||||||
translations_list = json.loads(translations)["translations"]
|
|
||||||
translations_json = {}
|
|
||||||
for translation in translations_list:
|
|
||||||
translations_json[translation["iso_3166_1"]] = translation
|
|
||||||
plot = ""
|
plot = ""
|
||||||
if "CN" in translations_json.keys():
|
translations = self.__translations()
|
||||||
zh = translations_json["CN"]
|
translations_json = json.loads(translations)
|
||||||
plot = zh["data"]["biography"]
|
if "translations" in translations_json:
|
||||||
elif "US" in translations_json.keys():
|
translations_list = json.loads(translations)["translations"]
|
||||||
us = translations_json["US"]
|
translations_json = {}
|
||||||
plot = us["data"]["biography"]
|
for translation in translations_list:
|
||||||
plot = plot.replace("\n", "").replace("\r\n", "")
|
translations_json[translation["iso_3166_1"]] = translation
|
||||||
|
if "CN" in translations_json.keys():
|
||||||
|
zh = translations_json["CN"]
|
||||||
|
plot = zh["data"]["biography"]
|
||||||
|
elif "US" in translations_json.keys():
|
||||||
|
us = translations_json["US"]
|
||||||
|
plot = us["data"]["biography"]
|
||||||
|
plot = plot.replace("\n", "").replace("\r\n", "")
|
||||||
return plot
|
return plot
|
||||||
|
|
||||||
def create_actor_nfo(self):
|
def create_actor_nfo(self):
|
||||||
|
@ -103,4 +110,7 @@ class Tmdb:
|
||||||
info_json["known_for_department"])
|
info_json["known_for_department"])
|
||||||
|
|
||||||
actor_data = json.dumps(actor_json)
|
actor_data = json.dumps(actor_json)
|
||||||
Make(xml_path=os.path.join(self.actor_path, "person.nfo"), data=actor_data).create()
|
try:
|
||||||
|
Make(xml_path=os.path.join(self.actor_path, "person.nfo"), data=actor_data).create()
|
||||||
|
except Exception as e:
|
||||||
|
self.log.logger.error("当前处理出现异常:{0}".format(e))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user