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"""
20import os
21import logging
22from typing import TYPE_CHECKING
23from puffotter.os import get_ext
24if TYPE_CHECKING: # pragma: no cover
25 from toktokkie.metadata.music.components.MusicAlbum import MusicAlbum
28class MusicVideo:
29 """
30 Class that keeps track of information for music videos
31 """
33 def __init__(self, path: str, album: "MusicAlbum"):
34 """
35 Initializes the music video
36 :param path: The path to the video file
37 :param album: The album to which the music video belongs to
38 """
39 self.logger = logging.getLogger(self.__class__.__name__)
41 self.album = album
42 self.path = path
43 self.format = get_ext(self.path)
45 @property
46 def title(self) -> str:
47 """
48 :return: The title of the song
49 """
50 filename = os.path.basename(self.path)
51 if filename.split(" - ")[0].isnumeric():
52 filename = filename.split(" - ", 1)[1]
53 return filename\
54 .rsplit(f".{self.format}", 1)[0]\
55 .rsplit("-video")[0]