Hide keyboard shortcuts

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> 

3 

4This file is part of toktokkie. 

5 

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. 

10 

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. 

15 

16You should have received a copy of the GNU General Public License 

17along with toktokkie. If not, see <http://www.gnu.org/licenses/>. 

18LICENSE""" 

19 

20from abc import ABC 

21from typing import List 

22from puffotter.os import listdir, get_ext 

23from toktokkie.metadata.base.components.RenameOperation import RenameOperation 

24from toktokkie.enums import IdType 

25from toktokkie.metadata.base.Renamer import Renamer 

26from toktokkie.metadata.movie.MovieExtras import MovieExtras 

27 

28 

29class MovieRenamer(Renamer, MovieExtras, ABC): 

30 """ 

31 Implements the Renamer functionality for movie metadata 

32 """ 

33 

34 def create_rename_operations(self) -> List[RenameOperation]: 

35 """ 

36 Creates renaming operations for movie metadata 

37 :return: The renaming operations 

38 """ 

39 movie_name, movie_path = listdir(self.directory_path, no_dirs=True)[0] 

40 new_name = f"{self.name}.{get_ext(movie_name)}" 

41 return [RenameOperation(movie_path, new_name)] 

42 

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 name, year = self.load_title_and_year([ 

50 IdType.IMDB, 

51 IdType.ANILIST 

52 ]) 

53 if year is None: 

54 return self.name 

55 else: 

56 return f"{name} ({year})"