From 28209747ea56a4dddb515a81ada8c6302d4f0e00 Mon Sep 17 00:00:00 2001 From: Audionut Date: Fri, 4 Oct 2024 09:14:34 +1000 Subject: [PATCH 1/2] Aither DVD naming --- .github/workflows/docker-image.yml | 2 +- src/trackers/AITHER.py | 49 +++++++++++------------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 0a33e0f0..068e2952 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -5,7 +5,7 @@ on: branches: - master - develop - - tik + - aither-naming env: REGISTRY: ghcr.io diff --git a/src/trackers/AITHER.py b/src/trackers/AITHER.py index 693379d0..ad5a5039 100644 --- a/src/trackers/AITHER.py +++ b/src/trackers/AITHER.py @@ -119,13 +119,12 @@ async def get_flag(self, meta, flag_name): async def edit_name(self, meta): aither_name = meta['name'] + media_info_tracks = meta.get('media_info_tracks', []) # noqa #F841 + resolution = meta.get('resolution') + video_codec = meta.get('video_codec') def has_english_audio(tracks=None, media_info_text=None): - if meta['is_disc'] == "BDMV" and tracks: - for track in tracks: - if track.get('language', '').lower() == 'english': - return True - elif media_info_text: + if media_info_text: audio_section = re.findall(r'Audio[\s\S]+?Language\s+:\s+(\w+)', media_info_text) for i, language in enumerate(audio_section): language = language.lower().strip() @@ -133,40 +132,28 @@ def has_english_audio(tracks=None, media_info_text=None): return True return False - # Helper function to extract the audio language from MediaInfo text or BDMV structure def get_audio_lang(tracks=None, is_bdmv=False, media_info_text=None): - if meta['is_disc'] == "BDMV" and tracks: - return tracks[0].get('language', '').upper() if tracks else "" - elif media_info_text: + if media_info_text: match = re.search(r'Audio[\s\S]+?Language\s+:\s+(\w+)', media_info_text) if match: return match.group(1).upper() - return "" # Return empty string if no audio track is found + return "" - is_bdmv = meta['is_disc'] == "BDMV" # noqa #F841 - media_info_tracks = meta.get('media_info_tracks', []) # noqa #F841 + try: + media_info_path = f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO.txt" + with open(media_info_path, 'r', encoding='utf-8') as f: + media_info_text = f.read() - if meta['is_disc'] == "BDMV": - bdinfo_audio = meta.get('bdinfo', {}).get('audio', []) - has_eng_audio = has_english_audio(bdinfo_audio) - if not has_eng_audio: - audio_lang = get_audio_lang(bdinfo_audio) + if not has_english_audio(media_info_text=media_info_text): + audio_lang = get_audio_lang(media_info_text=media_info_text) if audio_lang: aither_name = aither_name.replace(meta['resolution'], f"{audio_lang} {meta['resolution']}", 1) - else: - # Handle non-BDMV content - try: - media_info_path = f"{meta['base_dir']}/tmp/{meta['uuid']}/MEDIAINFO.txt" - with open(media_info_path, 'r', encoding='utf-8') as f: - media_info_text = f.read() - - # Check for English audio in the text-based MediaInfo - if not has_english_audio(media_info_text=media_info_text): - audio_lang = get_audio_lang(media_info_text=media_info_text) - if audio_lang: - aither_name = aither_name.replace(meta['resolution'], f"{audio_lang} {meta['resolution']}", 1) - except (FileNotFoundError, KeyError) as e: - print(f"Error processing MEDIAINFO.txt: {e}") + except (FileNotFoundError, KeyError) as e: + print(f"Error processing MEDIAINFO.txt: {e}") + + if meta['is_disc'] == "DVD": + aither_name = aither_name.replace(str(meta['year']), f"{meta['year']} {resolution}", 1) + aither_name = aither_name.replace((meta['audio']), f"{video_codec} {meta['audio']}", 1) return aither_name From 35d7cb66a6f6585a7352ca2443d599c10193332a Mon Sep 17 00:00:00 2001 From: Audionut Date: Fri, 4 Oct 2024 09:23:48 +1000 Subject: [PATCH 2/2] Aither TV catch --- src/trackers/AITHER.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/trackers/AITHER.py b/src/trackers/AITHER.py index ad5a5039..02183805 100644 --- a/src/trackers/AITHER.py +++ b/src/trackers/AITHER.py @@ -155,6 +155,9 @@ def get_audio_lang(tracks=None, is_bdmv=False, media_info_text=None): aither_name = aither_name.replace(str(meta['year']), f"{meta['year']} {resolution}", 1) aither_name = aither_name.replace((meta['audio']), f"{video_codec} {meta['audio']}", 1) + if meta['category'] == "TV" and meta.get('tv_pack', 0) == 0 and meta.get('episode_title_storage', '').strip() != '' and meta['episode'].strip() != '': + aither_name = aither_name.replace(meta['episode'], f"{meta['episode']} {meta['episode_title_storage']}", 1) + return aither_name async def get_cat_id(self, category_name):