Skip to content

Commit

Permalink
Fix manual nfo
Browse files Browse the repository at this point in the history
  • Loading branch information
Audionut committed Dec 28, 2024
1 parent 025a1ad commit ac8153b
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions src/prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -608,29 +608,30 @@ async def is_scene(self, video, meta, imdb=None):
meta['keep_folder'] = True

# NFO Download Handling
if first_result.get("hasNFO") == "yes":
try:
release = first_result['release']
release_lower = release.lower()
nfo_url = f"https://www.srrdb.com/download/file/{release}/{release_lower}.nfo"

# Define path and create directory
save_path = os.path.join(meta['base_dir'], 'tmp', meta['uuid'])
os.makedirs(save_path, exist_ok=True)
nfo_file_path = os.path.join(save_path, f"{release_lower}.nfo")

# Download the NFO file
nfo_response = requests.get(nfo_url, timeout=30)
if nfo_response.status_code == 200:
with open(nfo_file_path, 'wb') as f:
f.write(nfo_response.content)
meta['nfo'] = True
meta['auto_nfo'] = True
console.print(f"[green]NFO downloaded to {nfo_file_path}")
else:
console.print("[yellow]NFO file not available for download.")
except Exception as e:
console.print("[yellow]Failed to download NFO file:", e)
if not meta.get('nfo'):
if first_result.get("hasNFO") == "yes":
try:
release = first_result['release']
release_lower = release.lower()
nfo_url = f"https://www.srrdb.com/download/file/{release}/{release_lower}.nfo"

# Define path and create directory
save_path = os.path.join(meta['base_dir'], 'tmp', meta['uuid'])
os.makedirs(save_path, exist_ok=True)
nfo_file_path = os.path.join(save_path, f"{release_lower}.nfo")

# Download the NFO file
nfo_response = requests.get(nfo_url, timeout=30)
if nfo_response.status_code == 200:
with open(nfo_file_path, 'wb') as f:
f.write(nfo_response.content)
meta['nfo'] = True
meta['auto_nfo'] = True
console.print(f"[green]NFO downloaded to {nfo_file_path}")
else:
console.print("[yellow]NFO file not available for download.")
except Exception as e:
console.print("[yellow]Failed to download NFO file:", e)

# IMDb Handling
try:
Expand Down Expand Up @@ -1383,7 +1384,7 @@ def clean_text(text):
if meta['debug']:
console.print(f"specified_dir_path: {specified_dir_path}")
if meta.get('nfo') and not content_written:
if meta['auto_nfo'] is True:
if 'auto_nfo' in meta and meta['auto_nfo'] is True:
nfo_files = glob.glob(specified_dir_path)
scene_nfo = True
else:
Expand Down

0 comments on commit ac8153b

Please sign in to comment.