Skip to content

Commit

Permalink
Merge branch 'master' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Dec 14, 2024
2 parents 15934de + fbaa41e commit 7e1f872
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
6 changes: 2 additions & 4 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1619,8 +1619,8 @@ def capture_dvd_screenshot(self, task):
console.print(f"[red]Screenshot creation failed for {image}[/red]")
return None

except ffmpeg.Error as e:
console.print(f"[red]Error capturing screenshot for {input_file} at {seek_time}s: {e.stderr.decode()}[/red]")
except Exception as e:
console.print(f"[red]Error capturing screenshot for {input_file} at {seek_time}s: {e}[/red]")
return None

def screenshots(self, path, filename, folder_id, base_dir, meta, num_screens=None, force_screenshots=False, manual_frames=None):
Expand Down Expand Up @@ -1881,8 +1881,6 @@ def capture_screenshot(self, args):
return f"Error: Screenshot not generated or is empty at {image_path}"

return image_path
except ffmpeg.Error as e:
return f"FFmpeg Error: {e.stderr.decode()}"
except Exception as e:
return f"Error: {str(e)}"

Expand Down
16 changes: 13 additions & 3 deletions src/trackers/BHD.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,12 +383,18 @@ async def edit_desc(self, meta):
else:
images = meta['image_list']
if len(images) > 0:
desc.write("[center]")
desc.write("[align=center]")
for each in range(len(images[:int(meta['screens'])])):
web_url = images[each]['web_url']
img_url = images[each]['img_url']
desc.write(f"[url={web_url}][img width=350]{img_url}[/img][/url]")
desc.write("[/center]")
if (each == len(images) - 1):
desc.write(f"[url={web_url}][img width=350]{img_url}[/img][/url]")
elif (each + 1) % 2 == 0:
desc.write(f"[url={web_url}][img width=350]{img_url}[/img][/url]\n")
desc.write("\n")
else:
desc.write(f"[url={web_url}][img width=350]{img_url}[/img][/url] ")
desc.write("[/align]")
desc.write(self.signature)
desc.close()
return
Expand All @@ -399,6 +405,10 @@ async def search_existing(self, meta, disctype):
console.print("[bold red]This is an internal BHD release, skipping upload[/bold red]")
meta['skipping'] = "BHD"
return
if meta['type'] == "DVDRIP":
console.print("[bold red]No DVDRIP at BHD, skipping upload[/bold red]")
meta['skipping'] = "BHD"
return
dupes = []
console.print("[yellow]Searching for existing torrents on site...")
category = meta['category']
Expand Down
2 changes: 1 addition & 1 deletion src/trackers/COMMON.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async def unit3d_edit_desc(self, meta, tracker, signature, comparison=False, des
if not new_screens:
if meta['debug']:
console.print(f"[yellow]No existing screenshots for {new_images_key}; generating new ones.")
s = multiprocessing.Process(target=prep.screenshots, args=(file, f"FILE_{i}", meta['uuid'], meta['base_dir'], meta, multi_screens + 1, True, None))
s = multiprocessing.Process(target=prep.screenshots, args=(file, f"FILE_{i}", meta['uuid'], meta['base_dir'], meta, multi_screens, True, None))
s.start()
while s.is_alive():
await asyncio.sleep(1)
Expand Down
42 changes: 29 additions & 13 deletions src/trackers/HUNO.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,30 +115,46 @@ def get_audio(self, meta):
if dual:
language = "DUAL"
else:
if not meta['is_disc']:
# Read the MEDIAINFO.txt file
if meta['is_disc'] == "BDMV":
summary_path = f"{meta['base_dir']}/tmp/{meta['uuid']}/BD_SUMMARY_00.txt"
with open(summary_path, 'r', encoding='utf-8') as f:
summary_text = f.read()

audio_tracks = re.findall(r'Audio:\s*(.+)', summary_text)
if audio_tracks:
first_audio = audio_tracks[0]
language_match = re.search(r'([A-Za-z]+)\s*/', first_audio)
if language_match:
language = language_match.group(1).strip()
else:
print("DEBUG: No language found in the first audio track.")

else:
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()

# Extract the first audio section
first_audio_section = re.search(r'Audio\s+ID\s+:\s+2(.*?)\n\n', media_info_text, re.DOTALL)
if not first_audio_section: # Fallback in case of a different structure
first_audio_section = re.search(r'Audio(.*?)Text', media_info_text, re.DOTALL)
audio_sections = re.findall(r'Audio\s+.*?(?=\n\n|Text|Menu|$)', media_info_text, re.DOTALL)
if audio_sections:
first_audio_section = audio_sections[0]
language_match = re.search(r'Language\s*:\s*(\w+.*)', first_audio_section)

if first_audio_section:
# Extract language information from the first audio track
language_match = re.search(r'Language\s*:\s*(.+)', first_audio_section.group(1))
if language_match:
language = language_match.group(1).strip()
language = re.sub(r'\(.+\)', '', language) # Remove text in parentheses
language = re.sub(r'\(.+\)', '', language)
else:
print("DEBUG: No Language match found in the first audio section.")
else:
print("DEBUG: No Audio sections found in MEDIAINFO.txt.")

# Handle special cases
if language == "zxx":
language = "Silent"
elif not language:
language = cli_ui.ask_string('No audio language present, you must enter one:')
if not language:
if not meta['unattended'] or (meta['unattended'] and meta.get('unattended-confirm', False)):
language = cli_ui.ask_string('No audio language present, you must enter one:')
if not language:
language = "Unknown"
else:
language = "Unknown"

return f'{codec} {channels} {language}'
Expand Down
2 changes: 1 addition & 1 deletion src/trackers/PTP.py
Original file line number Diff line number Diff line change
Expand Up @@ -804,7 +804,7 @@ async def edit_desc(self, meta):
meta[new_images_key] = []
new_screens = glob.glob1(f"{meta['base_dir']}/tmp/{meta['uuid']}", f"FILE_{i}-*.png")
if not new_screens:
s = multiprocessing.Process(target=prep.screenshots, args=(file, f"FILE_{i}", meta['uuid'], meta['base_dir'], meta, multi_screens + 1, True, None))
s = multiprocessing.Process(target=prep.screenshots, args=(file, f"FILE_{i}", meta['uuid'], meta['base_dir'], meta, multi_screens, True, None))
s.start()
while s.is_alive() is True:
await asyncio.sleep(3)
Expand Down

0 comments on commit 7e1f872

Please sign in to comment.