...
 
Commits (2)
......@@ -227,8 +227,9 @@ class Directory:
except MissingMetadata:
logger.warning("{} has no metadata file.".format(path))
except InvalidMetadata:
except InvalidMetadata as e:
logger.warning("{}'s metadata is invalid.".format(path))
logger.warning(e.reason)
return directories
......
......@@ -25,6 +25,7 @@ from bs4 import BeautifulSoup
from typing import List, Optional, Tuple, Dict, Any
from puffotter.subprocess import execute_command
from puffotter.requests import aggressive_request
from puffotter.os import replace_illegal_ntfs_chars
from anime_list_apis.api.AnilistApi import AnilistApi
from anime_list_apis.models.attributes.MediaType import MediaType
......@@ -88,7 +89,9 @@ class AniTheme:
self.episodes = episodes
self.media_url = media_url
self.filename = "{} {} - {}".format(show_name, theme_type, song_name)
self.filename = replace_illegal_ntfs_chars(
"{} {} - {}".format(show_name, theme_type, song_name)
)
self.temp_webm_file = os.path.join("/tmp", self.filename + ".webm")
self.temp_mp3_file = os.path.join("/tmp", self.filename + ".mp3")
self.temp_cover_file = os.path.join("/tmp", self.filename + ".png")
......
......@@ -22,7 +22,12 @@ class InvalidMetadata(Exception):
"""
Exception that is raised whenever metadata is invalid
"""
pass
def __init__(self, reason: str):
"""
:param reason: The reason why the metadata is invalid
"""
self.reason = reason
class MetadataMismatch(Exception):
......
......@@ -127,7 +127,9 @@ class Metadata:
try:
validate(instance=self.json, schema=schema)
except ValidationError as e:
raise InvalidMetadata("Invalid Metadata: {}".format(e))
raise InvalidMetadata(
"Invalid Metadata: {} ({})".format(e, e.message)
)
def write(self):
"""
......
......@@ -287,7 +287,12 @@ class SchemaBuilder:
Creates additional properties for visual novel metadata
:return: The additional properties
"""
return {}
return {
"has_ed": {"type": "boolean"},
"has_op": {"type": "boolean"},
"has_cgs": {"type": "boolean"},
"has_ost": {"type": "boolean"}
}
if __name__ == "__main__":
......
......@@ -173,7 +173,7 @@ class AnimeThemeDlCommand(Command):
@staticmethod
def segmentize(titles: List[str]) -> List[List[str]]:
"""
Segments a list of titles into segments
Segments a list of titles into segments (seasons)
:param titles: The titles to segmentize
:return: The segments
"""
......@@ -183,7 +183,7 @@ class AnimeThemeDlCommand(Command):
for i, title in enumerate(titles):
if i > 0 \
and titles[i - 1] > title \
and titles[i - 1].upper() > title.upper() \
and titles[i - 1][0].lower() != title[0].lower():
segments.append(current_segment)
current_segment = []
......