Added map for episode names (#98)

* Added map for episode names

* Fix
This commit is contained in:
Fede14it 2024-04-11 08:00:51 +02:00 committed by GitHub
parent 1aefa47b6a
commit d942613dd8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 36 additions and 1 deletions

View File

@ -109,6 +109,7 @@ You can change some behaviors by tweaking the configuration file.
"specific_list_subtitles": [ "specific_list_subtitles": [
"eng" "eng"
], ],
"map_episode_name": "%(tv_name)_S%(season)E%(episode)_%(episode_name)",
} }
} }
``` ```
@ -148,6 +149,7 @@ You can change some behaviors by tweaking the configuration file.
| download_subtitles | true | Indicates whether subtitles should be downloaded or not. | false | | download_subtitles | true | Indicates whether subtitles should be downloaded or not. | false |
| specific_list_audio | ["ita"] | A list of specific audio languages to download. | ["eng", "fra"] | | specific_list_audio | ["ita"] | A list of specific audio languages to download. | ["eng", "fra"] |
| specific_list_subtitles | ["eng"] | A list of specific subtitle languages to download. | ["spa", "por"] | | specific_list_subtitles | ["eng"] | A list of specific subtitle languages to download. | ["spa", "por"] |
|map_episode_name |%(tv_name)_S%(season)E%(episode)_%(episode_name)| Mapping to choose the name of all episode of TV Show (see [Episode Name Usage](#Episode-name-usage)).
> [!IMPORTANT] > [!IMPORTANT]
> If you're on **Windows** you'll need to use double black slashes. On Linux/MacOS, one slash is fine. > If you're on **Windows** you'll need to use double black slashes. On Linux/MacOS, one slash is fine.
@ -159,3 +161,11 @@ You can change some behaviors by tweaking the configuration file.
## Tutorial ## Tutorial
For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing) For a detailed walkthrough, refer to the [video tutorial](https://www.youtube.com/watch?v=Ok7hQCgxqLg&ab_channel=Nothing)
#### Episode name usage:
You can choose different vars:
* `%(tv_name)` : Is the name of TV Show
* `%(season)` : Is the number of the season
* `%(episode)` : Is the number of the episode
* `%(episode_name)` : Is the name of the episode
>NOTE: You don't need to add .mp4 at the end

View File

@ -13,6 +13,7 @@ from Src.Util.message import start_message
from Src.Util.os import remove_special_characters from Src.Util.os import remove_special_characters
from Src.Lib.Unidecode import transliterate from Src.Lib.Unidecode import transliterate
from Src.Lib.FFmpeg.my_m3u8 import Downloader from Src.Lib.FFmpeg.my_m3u8 import Downloader
from Src.Util.mapper import map_episode_title
from .Class import VideoSource from .Class import VideoSource
@ -114,7 +115,7 @@ def donwload_video(tv_name: str, index_season_selected: int, index_episode_selec
episode_id = video_source.obj_episode_manager.episodes[index_episode_selected - 1].id episode_id = video_source.obj_episode_manager.episodes[index_episode_selected - 1].id
# Define filename and path for the downloaded video # Define filename and path for the downloaded video
mp4_name = remove_special_characters(f"{index_episode_selected}_{transliterate(video_source.obj_episode_manager.episodes[index_episode_selected - 1].name)}.mp4") mp4_name = remove_special_characters(f"{map_episode_title(tv_name,video_source.obj_episode_manager.episodes[index_episode_selected - 1],index_season_selected)}.mp4")
mp4_path = remove_special_characters(os.path.join(ROOT_PATH, SERIES_FOLDER, tv_name, f"S{index_season_selected}")) mp4_path = remove_special_characters(os.path.join(ROOT_PATH, SERIES_FOLDER, tv_name, f"S{index_season_selected}"))
os.makedirs(mp4_path, exist_ok=True) os.makedirs(mp4_path, exist_ok=True)

23
Src/Util/mapper.py Normal file
View File

@ -0,0 +1,23 @@
from Src.Lib.Unidecode import transliterate
from Src.Util.config import config_manager
map_episode = config_manager.get('M3U8_OPTIONS', 'map_episode_name')
def map_episode_title(tv_name: str, episode, number_season: int):
"""
Maps the episode title to a specific format.
Args:
tv_name (str): The name of the TV show.
episode (Episode): The episode object.
number_season (int): The season number.
Returns:
str: The mapped episode title.
"""
map_episode_temp = map_episode
map_episode_temp = map_episode_temp.replace("%(tv_name)", tv_name)
map_episode_temp = map_episode_temp.replace("%(season)", str(number_season).zfill(2))
map_episode_temp = map_episode_temp.replace("%(episode)", str(episode.number).zfill(2))
map_episode_temp = map_episode_temp.replace("%(episode_name)", episode.name)
return transliterate(map_episode_temp)

View File

@ -40,6 +40,7 @@
"specific_list_subtitles": [ "specific_list_subtitles": [
"eng" "eng"
], ],
"map_episode_name": "%(tv_name)_S%(season)E%(episode)_%(episode_name)",
"request": { "request": {
"index": { "index": {
"authority": "vixcloud.co", "authority": "vixcloud.co",