|
6 | 6 | import pymediainfo
|
7 | 7 | from loguru import logger
|
8 | 8 |
|
9 |
| -from animepipeline.mediainfo.type import FileNameInfo, MediaInfo |
| 9 | +from animepipeline.mediainfo.type import MediaInfo |
10 | 10 |
|
11 | 11 |
|
12 | 12 | def get_media_info(video_path: Union[str, Path]) -> MediaInfo:
|
@@ -133,49 +133,3 @@ def get_media_info(video_path: Union[str, Path]) -> MediaInfo:
|
133 | 133 | audios=audios,
|
134 | 134 | subtitles=subtitles,
|
135 | 135 | )
|
136 |
| - |
137 |
| - |
138 |
| -def gen_file_name(anime_info: FileNameInfo) -> str: |
139 |
| - """ |
140 |
| - Auto generate the file name, based on the media info of the file |
141 |
| -
|
142 |
| - anime_info: FileNameInfo (path: xx.mkv, episode: 1, name: Fate/Kaleid Liner Prisma Illya, uploader: TensoRaws, type: WEBRip) |
143 |
| -
|
144 |
| - -> [TensoRaws] Fate/Kaleid Liner Prisma Illya [01] [WEBRip 1080p HEVC-10bit FLAC].mkv |
145 |
| -
|
146 |
| - :param anime_info: FileNameInfo |
147 |
| - :return: |
148 |
| - """ |
149 |
| - media_info = get_media_info(anime_info.path) |
150 |
| - resolution_heigh = str(media_info.resolution[1]) + "p" |
151 |
| - bit_depth = str(media_info.bit_depth) + "bit" |
152 |
| - |
153 |
| - video_format = media_info.format |
154 |
| - |
155 |
| - audio_format_list = [audio[2] for audio in media_info.audios] |
156 |
| - audio_format = "FLAC" if "FLAC" in audio_format_list else audio_format_list[0] |
157 |
| - |
158 |
| - file_format = Path(anime_info.path).suffix |
159 |
| - |
160 |
| - return f"[{anime_info.uploader}] {anime_info.name} [{str(anime_info.episode).zfill(2)}] [{anime_info.type} {resolution_heigh} {video_format}-{bit_depth} {audio_format}]{file_format}" |
161 |
| - |
162 |
| - |
163 |
| -def rename_file(anime_info: FileNameInfo) -> Path: |
164 |
| - """ |
165 |
| - Rename the file name, based on the media info of the file |
166 |
| -
|
167 |
| - :param anime_info: FileNameInfo |
168 |
| - :return: |
169 |
| - """ |
170 |
| - anime_path = Path(anime_info.path) |
171 |
| - |
172 |
| - gen_name = gen_file_name(anime_info) |
173 |
| - gen_path = anime_path.parent / gen_name |
174 |
| - |
175 |
| - if gen_path.exists(): |
176 |
| - gen_path.unlink() |
177 |
| - logger.warning(f"Encode File already exists, remove it: {gen_path}") |
178 |
| - |
179 |
| - anime_path.rename(gen_path) |
180 |
| - |
181 |
| - return gen_path |
0 commit comments