@@ -16,13 +16,16 @@ def __init__(self, scene_path, defaults=None, folder_mode=False):
1616 self ._defaults = defaults
1717 # Finds nfo file
1818 self ._nfo_file = None
19+ dir_path = os .path .dirname (scene_path )
1920 if config .nfo_location .lower () == "with files" :
2021 if folder_mode :
2122 # look in current dir & parents for a folder.nfo file...
22- dir_path = os .path .dirname (scene_path )
2323 self ._nfo_file = self ._find_in_parents (dir_path , "folder.nfo" )
2424 else :
25- self ._nfo_file = os .path .splitext (scene_path )[0 ] + ".nfo"
25+ if len (getattr (config , "custom_nfo_name" , "" )) > 0 :
26+ self ._nfo_file = os .path .join (dir_path , config .custom_nfo_name )
27+ else :
28+ self ._nfo_file = os .path .splitext (scene_path )[0 ] + ".nfo"
2629 # else:
2730 # TODO: support dedicated dir instead of "with files" (compatibility with nfo exporters)
2831 self ._nfo_root = None
@@ -56,7 +59,7 @@ def __read_cover_image_file(self):
5659 # Not found? Look tor folder image...
5760 path_dir = os .path .dirname (self ._nfo_file )
5861 folder_files = sorted (glob .glob (f"{ glob .escape (path_dir )} { os .path .sep } *.*" ))
59- folder_pattern = re .compile ("^.*(landscape\\ d{0,2}|thumb\\ d{0,2}|poster\\ d{0,2}|cover\\ d{0,2})\\ .(jpe?g|png|webp)$" , re .I )
62+ folder_pattern = re .compile ("^.*(landscape\\ d{0,2}|thumb\\ d{0,2}|poster\\ d{0,2}|folder \\ d{0,2}| cover\\ d{0,2})\\ .(jpe?g|png|webp)$" , re .I )
6063 result = self .__match_image_files (folder_files , folder_pattern )
6164 return result
6265
@@ -103,7 +106,8 @@ def __extract_cover_images_b64(self):
103106 return file_images
104107
105108 def __extract_nfo_rating (self ):
106- user_rating = round (float (self ._nfo_root .findtext ("userrating" ) or 0 ))
109+ multiplier = getattr (config , "user_rating_multiplier" , 1 )
110+ user_rating = round (float (self ._nfo_root .findtext (getattr (config , "user_rating_field" , "userrating" )) or 0 ) * multiplier )
107111 if user_rating > 0 :
108112 return user_rating
109113 # <rating> is converted to a scale of 5 if needed
@@ -124,17 +128,20 @@ def __extract_nfo_date(self):
124128 return self ._nfo_root .findtext ("premiered" ) or year
125129
126130 def __extract_nfo_tags (self ):
131+ source = getattr (config , "load_tags_from" , "both" ).lower ()
127132 file_tags = []
128- # from nfo <tag>
129- tags = self ._nfo_root .findall ("tag" )
130- for tag in tags :
131- if tag .text :
132- file_tags .append (tag .text )
133- # from nfo <genre>
134- genres = self ._nfo_root .findall ("genre" )
135- for genre in genres :
136- if genre .text :
137- file_tags .append (genre .text )
133+ if source in ["tags" , "both" ]:
134+ # from nfo <tag>
135+ tags = self ._nfo_root .findall ("tag" )
136+ for tag in tags :
137+ if tag .text :
138+ file_tags .append (tag .text )
139+ if source in ["genres" , "both" ]:
140+ # from nfo <genre>
141+ genres = self ._nfo_root .findall ("genre" )
142+ for genre in genres :
143+ if genre .text :
144+ file_tags .append (genre .text )
138145 return list (set (file_tags ))
139146
140147 def __extract_nfo_actors (self ):
@@ -147,6 +154,8 @@ def __extract_nfo_actors(self):
147154
148155 def parse (self ):
149156 if not self ._nfo_file or not os .path .exists (self ._nfo_file ):
157+ if self ._nfo_file :
158+ log .LogDebug (f"The NFO file \" { os .path .split (self ._nfo_file )[1 ]} \" was not found" )
150159 return {}
151160 log .LogDebug ("Parsing '{}'" .format (self ._nfo_file ))
152161 # Parse NFO xml content
0 commit comments