Skip to content

Commit

Permalink
Dual audio Fixes for issue 53
Browse files Browse the repository at this point in the history
  • Loading branch information
Kha-kis authored Oct 8, 2024
1 parent 09f5148 commit 0b51bc2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 28 deletions.
1 change: 1 addition & 0 deletions src/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ def parse(self, args, meta):
parser.add_argument('--no-aka', dest='no_aka', action='store_true', required=False, help="Remove AKA from title")
parser.add_argument('--no-dub', dest='no_dub', action='store_true', required=False, help="Remove Dubbed from title")
parser.add_argument('--no-tag', dest='no_tag', action='store_true', required=False, help="Remove Group Tag from title")
parser.add_argument('--dual-audio', dest='dual_audio', action='store_true', required=False, help="Add Dual-Audio to the title")
parser.add_argument('-ns', '--no-seed', action='store_true', required=False, help="Do not add torrent to the client")
parser.add_argument('-year', '--year', dest='manual_year', nargs='?', required=False, help="Year", type=int, default=0)
parser.add_argument('-ptp', '--ptp', nargs='*', required=False, help="PTP torrent id/permalink", type=str)
Expand Down
57 changes: 30 additions & 27 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1924,42 +1924,45 @@ def get_audio_v2(self, mi, meta, bdinfo):
else:
chan = f"{channels}.0"

if meta.get('original_language', '') != 'en':
eng, orig = False, False
try:
for t in mi.get('media', {}).get('track', []):
if t.get('@type') != "Audio":
continue
if meta.get('dual_audio', False): # If dual_audio flag is set, skip other checks
dual = "Dual-Audio"
else:
if meta.get('original_language', '') != 'en':
eng, orig = False, False
try:
for t in mi.get('media', {}).get('track', []):
if t.get('@type') != "Audio":
continue

audio_language = t.get('Language', '')
audio_language = t.get('Language', '')

# Check for English Language Track
if audio_language == "en" and "commentary" not in t.get('Title', '').lower():
eng = True
# Check for English Language Track
if audio_language.startswith("en") and "commentary" not in t.get('Title', '').lower():
eng = True

# Check for original Language Track
if audio_language == meta['original_language'] and "commentary" not in t.get('Title', '').lower():
orig = True
# Check for original Language Track
if not audio_language.startswith("en") and audio_language.startswith(meta['original_language']) and "commentary" not in t.get('Title', '').lower():
orig = True

# Catch Chinese / Norwegian / Spanish variants
variants = ['zh', 'cn', 'cmn', 'no', 'nb', 'es-419', 'es-ES', 'es']
if audio_language in variants and meta['original_language'] in variants:
orig = True
# Catch Chinese / Norwegian Variants
variants = ['zh', 'cn', 'cmn', 'no', 'nb']
if any(audio_language.startswith(var) for var in variants) and any(meta['original_language'].startswith(var) for var in variants):
orig = True

# Check for additional, bloated Tracks
if audio_language != meta['original_language'] and audio_language != "en":
if meta['original_language'] not in variants and audio_language not in variants:
# Check for additional, bloated Tracks
if audio_language != meta['original_language'] and not audio_language.startswith("en"):
# If audio_language is empty, set to 'und' (undefined)
audio_language = "und" if audio_language == "" else audio_language
console.print(f"[bold red]This release has a(n) {audio_language} audio track, and may be considered bloated")
time.sleep(5)

if eng and orig:
dual = "Dual-Audio"
elif eng and not orig and meta['original_language'] not in ['zxx', 'xx', None] and not meta.get('no_dub', False):
dual = "Dubbed"
except Exception:
console.print(traceback.format_exc())
pass
if eng and orig:
dual = "Dual-Audio"
elif eng and not orig and meta['original_language'] not in ['zxx', 'xx', None] and not meta.get('no_dub', False):
dual = "Dubbed"
except Exception:
console.print(traceback.format_exc())
pass

for t in mi.get('media', {}).get('track', []):
if t.get('@type') != "Audio":
Expand Down
2 changes: 1 addition & 1 deletion upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ async def do_the_thing(base_dir):
overwrite_list = [
'trackers', 'dupe', 'debug', 'anon', 'category', 'type', 'screens', 'nohash', 'manual_edition', 'imdb', 'tmdb_manual', 'mal', 'manual',
'hdb', 'ptp', 'blu', 'no_season', 'no_aka', 'no_year', 'no_dub', 'no_tag', 'no_seed', 'client', 'desclink', 'descfile', 'desc', 'draft', 'modq', 'region', 'freeleech',
'personalrelease', 'unattended', 'season', 'episode', 'torrent_creation', 'qbit_tag', 'qbit_cat', 'skip_imghost_upload', 'imghost', 'manual_source', 'webdv', 'hardcoded-subs'
'personalrelease', 'unattended', 'season', 'episode', 'torrent_creation', 'qbit_tag', 'qbit_cat', 'skip_imghost_upload', 'imghost', 'manual_source', 'webdv', 'hardcoded-subs', 'dual_audio'
]
if meta.get(key, None) != value and key in overwrite_list:
saved_meta[key] = meta[key]
Expand Down

0 comments on commit 0b51bc2

Please sign in to comment.