From dcbecf876e99a1ae4e5f66fe566aaae450dbc6d0 Mon Sep 17 00:00:00 2001 From: Prinz23 Date: Thu, 22 Feb 2024 10:42:03 +0100 Subject: [PATCH] Fix credits in Kodi episode nfo writer. --- CHANGES.md | 1 + sickgear/metadata/kodi.py | 28 ++++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 52cb42bb..1f139536 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ * Change increase viewable history menu items from 13 to 15 * Change add parsing of 2160p releases that don't have a source tag * Change twitter.com to x.com and Twitter to X (Twitter) branding +* Fix credits in Kodi episode nfo writer ### 3.32.8 (2024-10-07 00:30:00 UTC) diff --git a/sickgear/metadata/kodi.py b/sickgear/metadata/kodi.py index aa9a2bd0..861d8aca 100644 --- a/sickgear/metadata/kodi.py +++ b/sickgear/metadata/kodi.py @@ -21,6 +21,7 @@ from . import generic from .. import logger import sg_helpers from ..indexers.indexer_config import TVINFO_IMDB, TVINFO_TVDB +from lib.tvinfo_base import RoleTypes from lib.tvinfo_base.exceptions import * import sickgear import exceptions_helper @@ -33,6 +34,7 @@ from six import string_types # noinspection PyUnreachableCode if False: from typing import AnyStr, Dict, Optional, Union + from lib.tvinfo_base import PersonBase class KODIMetadata(generic.GenericMetadata): @@ -378,15 +380,25 @@ class KODIMetadata(generic.GenericMetadata): watched = etree.SubElement(ep_node, 'watched') watched.text = 'false' - credits = etree.SubElement(ep_node, 'credits') - credits_text = getattr(ep_info, 'writer', None) - if None is not credits_text: - credits.text = '%s' % credits_text + crew = getattr(ep_info, 'crew', None) + if None is not crew: + for role_type, sub_el_name in [(RoleTypes.CrewWriter, 'credits'), (RoleTypes.CrewDirector, 'director')]: + for credit in (crew[role_type] or []): # type: PersonBase + if credit.name: + sub_el = etree.SubElement(ep_node, sub_el_name) + sub_el.text = '%s' % credit.name - director = etree.SubElement(ep_node, 'director') - director_text = getattr(ep_info, 'director', None) - if None is not director_text: - director.text = '%s' % director_text + # credits_text = getattr(ep_info, 'writer', None) + # if None is not credits_text and ( + # credits_list := [_c.strip() for _c in credits_text.split('|') if _c.strip()]): + # for credit in credits_list: + # credits = etree.SubElement(ep_node, 'credits') + # credits.text = '%s' % credit + + # director = etree.SubElement(ep_node, 'director') + # director_text = getattr(ep_info, 'director', None) + # if None is not director_text: + # director.text = '%s' % director_text ratings = etree.SubElement(ep_node, 'ratings') if None is not getattr(ep_info, 'rating', None):