Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1"""LICENSE
2Copyright 2015 Hermann Krumrey <hermann@krumreyh.com>
4This file is part of toktokkie.
6toktokkie is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
11toktokkie is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
16You should have received a copy of the GNU General Public License
17along with toktokkie. If not, see <http://www.gnu.org/licenses/>.
18LICENSE"""
20from abc import ABC
21from typing import List
22from puffotter.os import listdir, get_ext
23from toktokkie.enums import IdType
24from toktokkie.metadata.base.Renamer import Renamer
25from toktokkie.metadata.book.BookExtras import BookExtras
26from toktokkie.metadata.base.components.RenameOperation import RenameOperation
29class BookRenamer(Renamer, BookExtras, ABC):
30 """
31 Implements the Renamer functionality for book metadata
32 """
34 def create_rename_operations(self) -> List[RenameOperation]:
35 """
36 Creates renaming operations for book metadata
37 :return: The renaming operations
38 """
39 book_files = listdir(self.directory_path, no_dirs=True)
40 book_file, path = book_files[0]
41 return [RenameOperation(path, f"{self.name}.{get_ext(book_file)}")]
43 def resolve_title_name(self) -> str:
44 """
45 If possible, will fetch the appropriate name for the
46 metadata based on IDs, falling back to the
47 directory name if this is not possible or supported.
48 """
49 return self.load_title_and_year([
50 IdType.ANILIST
51 ])[0]