fix scraper
This commit is contained in:
parent
27b65c3ec9
commit
439f7f19d0
@ -182,8 +182,7 @@ class Douban(_ModuleBase):
|
|||||||
# 电视剧
|
# 电视剧
|
||||||
else:
|
else:
|
||||||
# 不存在时才处理
|
# 不存在时才处理
|
||||||
if not file_path.parent.with_name("tvshow.nfo").exists() \
|
if not file_path.parent.with_name("tvshow.nfo").exists():
|
||||||
and not file_path.parent.with_name(file_path.stem + ".nfo").exists():
|
|
||||||
# 根目录描述文件
|
# 根目录描述文件
|
||||||
self.__gen_tv_nfo_file(doubaninfo=doubaninfo,
|
self.__gen_tv_nfo_file(doubaninfo=doubaninfo,
|
||||||
dir_path=file_path.parents[1])
|
dir_path=file_path.parents[1])
|
||||||
@ -191,6 +190,7 @@ class Douban(_ModuleBase):
|
|||||||
self.__save_image(url=doubaninfo.get('poster_path'),
|
self.__save_image(url=doubaninfo.get('poster_path'),
|
||||||
file_path=file_path.with_name(f"poster{Path(doubaninfo.get('poster_path')).suffix}"))
|
file_path=file_path.with_name(f"poster{Path(doubaninfo.get('poster_path')).suffix}"))
|
||||||
# 季目录NFO
|
# 季目录NFO
|
||||||
|
if not file_path.with_name("season.nfo").exists():
|
||||||
self.__gen_tv_season_nfo_file(seasoninfo=doubaninfo,
|
self.__gen_tv_season_nfo_file(seasoninfo=doubaninfo,
|
||||||
season=meta.begin_season,
|
season=meta.begin_season,
|
||||||
season_path=file_path.parent)
|
season_path=file_path.parent)
|
||||||
@ -226,16 +226,12 @@ class Douban(_ModuleBase):
|
|||||||
|
|
||||||
def __gen_movie_nfo_file(self,
|
def __gen_movie_nfo_file(self,
|
||||||
doubaninfo: dict,
|
doubaninfo: dict,
|
||||||
file_path: Path,
|
file_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电影的NFO描述文件
|
生成电影的NFO描述文件
|
||||||
:param doubaninfo: 豆瓣信息
|
:param doubaninfo: 豆瓣信息
|
||||||
:param file_path: 电影文件路径
|
:param file_path: 电影文件路径
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
if not force_nfo and file_path.with_suffix(".nfo").exists():
|
|
||||||
return
|
|
||||||
# 开始生成XML
|
# 开始生成XML
|
||||||
logger.info(f"正在生成电影NFO文件:{file_path.name}")
|
logger.info(f"正在生成电影NFO文件:{file_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
@ -253,16 +249,12 @@ class Douban(_ModuleBase):
|
|||||||
|
|
||||||
def __gen_tv_nfo_file(self,
|
def __gen_tv_nfo_file(self,
|
||||||
doubaninfo: dict,
|
doubaninfo: dict,
|
||||||
dir_path: Path,
|
dir_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电视剧的NFO描述文件
|
生成电视剧的NFO描述文件
|
||||||
:param doubaninfo: 媒体信息
|
:param doubaninfo: 媒体信息
|
||||||
:param dir_path: 电视剧根目录
|
:param dir_path: 电视剧根目录
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
if not force_nfo and dir_path.joinpath("tvshow.nfo").exists():
|
|
||||||
return
|
|
||||||
# 开始生成XML
|
# 开始生成XML
|
||||||
logger.info(f"正在生成电视剧NFO文件:{dir_path.name}")
|
logger.info(f"正在生成电视剧NFO文件:{dir_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
@ -280,19 +272,13 @@ class Douban(_ModuleBase):
|
|||||||
# 保存
|
# 保存
|
||||||
self.__save_nfo(doc, dir_path.joinpath("tvshow.nfo"))
|
self.__save_nfo(doc, dir_path.joinpath("tvshow.nfo"))
|
||||||
|
|
||||||
def __gen_tv_season_nfo_file(self, seasoninfo: dict, season: int, season_path: Path,
|
def __gen_tv_season_nfo_file(self, seasoninfo: dict, season: int, season_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电视剧季的NFO描述文件
|
生成电视剧季的NFO描述文件
|
||||||
:param seasoninfo: TMDB季媒体信息
|
:param seasoninfo: TMDB季媒体信息
|
||||||
:param season: 季号
|
:param season: 季号
|
||||||
:param season_path: 电视剧季的目录
|
:param season_path: 电视剧季的目录
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not force_nfo and season_path.with_name("season.nfo").exists():
|
|
||||||
return
|
|
||||||
|
|
||||||
logger.info(f"正在生成季NFO文件:{season_path.name}")
|
logger.info(f"正在生成季NFO文件:{season_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
root = DomUtils.add_node(doc, doc, "season")
|
root = DomUtils.add_node(doc, doc, "season")
|
||||||
@ -313,7 +299,7 @@ class Douban(_ModuleBase):
|
|||||||
# seasonnumber
|
# seasonnumber
|
||||||
DomUtils.add_node(doc, root, "seasonnumber", str(season))
|
DomUtils.add_node(doc, root, "seasonnumber", str(season))
|
||||||
# 保存
|
# 保存
|
||||||
self.__save_nfo(doc, season_path.with_name("season.nfo"))
|
self.__save_nfo(doc, season_path.joinpath("season.nfo"))
|
||||||
|
|
||||||
def __gen_tv_episode_nfo_file(self,
|
def __gen_tv_episode_nfo_file(self,
|
||||||
episodeinfo: dict,
|
episodeinfo: dict,
|
||||||
|
@ -196,14 +196,13 @@ class TheMovieDb(_ModuleBase):
|
|||||||
and attr_value.startswith("http"):
|
and attr_value.startswith("http"):
|
||||||
image_name = attr_name.replace("_path", "") + Path(attr_value).suffix
|
image_name = attr_name.replace("_path", "") + Path(attr_value).suffix
|
||||||
self.__save_image(url=attr_value,
|
self.__save_image(url=attr_value,
|
||||||
file_path=file_path.parent / image_name)
|
file_path=file_path.with_name(image_name))
|
||||||
# 电视剧
|
# 电视剧
|
||||||
else:
|
else:
|
||||||
# 识别
|
# 识别
|
||||||
meta = MetaInfo(file_path.stem)
|
meta = MetaInfo(file_path.stem)
|
||||||
# 不存在时才处理
|
# 不存在时才处理
|
||||||
if not file_path.parent.with_name("tvshow.nfo").exists() \
|
if not file_path.parent.with_name("tvshow.nfo").exists():
|
||||||
and not file_path.parent.with_name(file_path.stem + ".nfo").exists():
|
|
||||||
# 根目录描述文件
|
# 根目录描述文件
|
||||||
self.__gen_tv_nfo_file(mediainfo=mediainfo,
|
self.__gen_tv_nfo_file(mediainfo=mediainfo,
|
||||||
dir_path=file_path.parents[1])
|
dir_path=file_path.parents[1])
|
||||||
@ -215,11 +214,12 @@ class TheMovieDb(_ModuleBase):
|
|||||||
and attr_value.startswith("http"):
|
and attr_value.startswith("http"):
|
||||||
image_name = attr_name.replace("_path", "") + Path(attr_value).suffix
|
image_name = attr_name.replace("_path", "") + Path(attr_value).suffix
|
||||||
self.__save_image(url=attr_value,
|
self.__save_image(url=attr_value,
|
||||||
file_path=file_path.parents[1] / image_name)
|
file_path=file_path.parent.with_name(image_name))
|
||||||
# 查询季信息
|
# 查询季信息
|
||||||
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, meta.begin_season)
|
seasoninfo = self.tmdb.get_tv_season_detail(mediainfo.tmdb_id, meta.begin_season)
|
||||||
if seasoninfo:
|
if seasoninfo:
|
||||||
# 季目录NFO
|
# 季目录NFO
|
||||||
|
if not file_path.with_name("season.nfo").exists():
|
||||||
self.__gen_tv_season_nfo_file(seasoninfo=seasoninfo,
|
self.__gen_tv_season_nfo_file(seasoninfo=seasoninfo,
|
||||||
season=meta.begin_season,
|
season=meta.begin_season,
|
||||||
season_path=file_path.parent)
|
season_path=file_path.parent)
|
||||||
@ -233,19 +233,20 @@ class TheMovieDb(_ModuleBase):
|
|||||||
f"{str(meta.begin_season).rjust(2, '0')}-")\
|
f"{str(meta.begin_season).rjust(2, '0')}-")\
|
||||||
+ Path(attr_value).suffix
|
+ Path(attr_value).suffix
|
||||||
self.__save_image(url=attr_value,
|
self.__save_image(url=attr_value,
|
||||||
file_path=file_path.parent / image_name)
|
file_path=file_path.parent.with_name(image_name))
|
||||||
# 查询集详情
|
# 查询集详情
|
||||||
episodeinfo = __get_episode_detail(seasoninfo, meta.begin_episode)
|
episodeinfo = __get_episode_detail(seasoninfo, meta.begin_episode)
|
||||||
if episodeinfo:
|
if episodeinfo:
|
||||||
# 集NFO
|
# 集NFO
|
||||||
|
if not file_path.with_suffix(".nfo").exists():
|
||||||
self.__gen_tv_episode_nfo_file(episodeinfo=episodeinfo,
|
self.__gen_tv_episode_nfo_file(episodeinfo=episodeinfo,
|
||||||
season=meta.begin_season,
|
season=meta.begin_season,
|
||||||
episode=meta.begin_episode,
|
episode=meta.begin_episode,
|
||||||
file_path=file_path)
|
file_path=file_path)
|
||||||
# 集的图片
|
# 集的图片
|
||||||
if episodeinfo.get('still_path'):
|
if episodeinfo.get('still_path'):
|
||||||
self.__save_image(f"https://image.tmdb.org/t/p/original{episodeinfo.get('still_path')}",
|
self.__save_image(f"https://{settings.TMDB_IMAGE_DOMAIN}/t/p/original{episodeinfo.get('still_path')}",
|
||||||
file_path.with_suffix(".jpg"))
|
file_path.with_suffix(Path(episodeinfo.get('still_path')).suffix))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"{file_path} 刮削失败:{e}")
|
logger.error(f"{file_path} 刮削失败:{e}")
|
||||||
|
|
||||||
@ -316,16 +317,12 @@ class TheMovieDb(_ModuleBase):
|
|||||||
|
|
||||||
def __gen_movie_nfo_file(self,
|
def __gen_movie_nfo_file(self,
|
||||||
mediainfo: MediaInfo,
|
mediainfo: MediaInfo,
|
||||||
file_path: Path,
|
file_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电影的NFO描述文件
|
生成电影的NFO描述文件
|
||||||
:param mediainfo: 识别后的媒体信息
|
:param mediainfo: 识别后的媒体信息
|
||||||
:param file_path: 电影文件路径
|
:param file_path: 电影文件路径
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
if not force_nfo and file_path.with_suffix(".nfo").exists():
|
|
||||||
return
|
|
||||||
# 开始生成XML
|
# 开始生成XML
|
||||||
logger.info(f"正在生成电影NFO文件:{file_path.name}")
|
logger.info(f"正在生成电影NFO文件:{file_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
@ -346,16 +343,12 @@ class TheMovieDb(_ModuleBase):
|
|||||||
|
|
||||||
def __gen_tv_nfo_file(self,
|
def __gen_tv_nfo_file(self,
|
||||||
mediainfo: MediaInfo,
|
mediainfo: MediaInfo,
|
||||||
dir_path: Path,
|
dir_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电视剧的NFO描述文件
|
生成电视剧的NFO描述文件
|
||||||
:param mediainfo: 媒体信息
|
:param mediainfo: 媒体信息
|
||||||
:param dir_path: 电视剧根目录
|
:param dir_path: 电视剧根目录
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
if not force_nfo and dir_path.joinpath("tvshow.nfo").exists():
|
|
||||||
return
|
|
||||||
# 开始生成XML
|
# 开始生成XML
|
||||||
logger.info(f"正在生成电视剧NFO文件:{dir_path.name}")
|
logger.info(f"正在生成电视剧NFO文件:{dir_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
@ -376,19 +369,13 @@ class TheMovieDb(_ModuleBase):
|
|||||||
# 保存
|
# 保存
|
||||||
self.__save_nfo(doc, dir_path.joinpath("tvshow.nfo"))
|
self.__save_nfo(doc, dir_path.joinpath("tvshow.nfo"))
|
||||||
|
|
||||||
def __gen_tv_season_nfo_file(self, seasoninfo: dict, season: int, season_path: Path,
|
def __gen_tv_season_nfo_file(self, seasoninfo: dict, season: int, season_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电视剧季的NFO描述文件
|
生成电视剧季的NFO描述文件
|
||||||
:param seasoninfo: TMDB季媒体信息
|
:param seasoninfo: TMDB季媒体信息
|
||||||
:param season: 季号
|
:param season: 季号
|
||||||
:param season_path: 电视剧季的目录
|
:param season_path: 电视剧季的目录
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not force_nfo and season_path.with_name("season.nfo").exists():
|
|
||||||
return
|
|
||||||
|
|
||||||
logger.info(f"正在生成季NFO文件:{season_path.name}")
|
logger.info(f"正在生成季NFO文件:{season_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
root = DomUtils.add_node(doc, doc, "season")
|
root = DomUtils.add_node(doc, doc, "season")
|
||||||
@ -409,24 +396,20 @@ class TheMovieDb(_ModuleBase):
|
|||||||
# seasonnumber
|
# seasonnumber
|
||||||
DomUtils.add_node(doc, root, "seasonnumber", str(season))
|
DomUtils.add_node(doc, root, "seasonnumber", str(season))
|
||||||
# 保存
|
# 保存
|
||||||
self.__save_nfo(doc, season_path.with_name("season.nfo"))
|
self.__save_nfo(doc, season_path.joinpath("season.nfo"))
|
||||||
|
|
||||||
def __gen_tv_episode_nfo_file(self,
|
def __gen_tv_episode_nfo_file(self,
|
||||||
episodeinfo: dict,
|
episodeinfo: dict,
|
||||||
season: int,
|
season: int,
|
||||||
episode: int,
|
episode: int,
|
||||||
file_path: Path,
|
file_path: Path):
|
||||||
force_nfo: bool = False):
|
|
||||||
"""
|
"""
|
||||||
生成电视剧集的NFO描述文件
|
生成电视剧集的NFO描述文件
|
||||||
:param episodeinfo: 集TMDB元数据
|
:param episodeinfo: 集TMDB元数据
|
||||||
:param season: 季号
|
:param season: 季号
|
||||||
:param episode: 集号
|
:param episode: 集号
|
||||||
:param file_path: 集文件的路径
|
:param file_path: 集文件的路径
|
||||||
:param force_nfo: 是否强制生成NFO文件
|
|
||||||
"""
|
"""
|
||||||
if not force_nfo and file_path.with_suffix(".nfo").exists():
|
|
||||||
return
|
|
||||||
# 开始生成集的信息
|
# 开始生成集的信息
|
||||||
logger.info(f"正在生成剧集NFO文件:{file_path.name}")
|
logger.info(f"正在生成剧集NFO文件:{file_path.name}")
|
||||||
doc = minidom.Document()
|
doc = minidom.Document()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user