Skip to content

Commit 966baf1

Browse files
committed
Bugs Fixes
1 parent 76c1ce1 commit 966baf1

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

frontend/templates/components/settings_clients_section.html

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,17 @@ <h2 class="client-type-modal-title">Add Download Client</h2>
159159
<div class="client-type-option-icon"><i class="fas fa-download"></i></div>
160160
<div class="client-type-option-body">
161161
<div class="client-type-option-name">SABnzbd <span class="client-type-option-tag" style="background:rgba(245,158,11,0.2);color:#f59e0b;">Beta</span></div>
162-
<div class="client-type-option-desc">External usenet client. Requires host, port, and API key. <span style="color:#f59e0b;">Support is under development and may not be fully stable.</span></div>
162+
<div class="client-type-option-warning" style="display:flex;align-items:center;gap:6px;margin-bottom:4px;font-size:0.8rem;color:#f59e0b;"><i class="fas fa-exclamation-triangle"></i> Support under development</div>
163+
<div class="client-type-option-desc">External usenet client. Requires host, port, and API key. May work but is not fully polished.</div>
163164
</div>
164165
<div class="client-type-option-check"><i class="fas fa-check-circle"></i></div>
165166
</div>
166167
<div class="client-type-option" data-client-type="nzbget" id="client-type-option-nzbget">
167168
<div class="client-type-option-icon"><i class="fas fa-download"></i></div>
168169
<div class="client-type-option-body">
169170
<div class="client-type-option-name">NZBGet <span class="client-type-option-tag" style="background:rgba(245,158,11,0.2);color:#f59e0b;">Beta</span></div>
170-
<div class="client-type-option-desc">External usenet client. Requires host, port, and password. <span style="color:#f59e0b;">Support is under development and may not be fully stable.</span></div>
171+
<div class="client-type-option-warning" style="display:flex;align-items:center;gap:6px;margin-bottom:4px;font-size:0.8rem;color:#f59e0b;"><i class="fas fa-exclamation-triangle"></i> Support under development</div>
172+
<div class="client-type-option-desc">External usenet client. Requires host, port, and password. May work but is not fully polished.</div>
171173
</div>
172174
<div class="client-type-option-check"><i class="fas fa-check-circle"></i></div>
173175
</div>

src/primary/apps/movie_hunt/importer.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,20 @@ def _auto_probe_file(title: str, year: str, file_path: str, instance_id: int = N
323323
_mh_log().debug("Import probe: error for '%s' (%s): %s", title, year, e)
324324

325325

326+
def _cleanup_on_import_failure(local_path: str, root_folder: str, title: str, year: str) -> None:
327+
"""
328+
Remove the source download folder when import fails.
329+
Frees disk space so failed downloads don't accumulate.
330+
"""
331+
if not local_path or not root_folder:
332+
return
333+
try:
334+
_cleanup_source_folder(local_path, root_folder, title, year)
335+
_mh_log().info("Import: discarded failed download for '%s' (%s) to free space", title, year)
336+
except Exception as e:
337+
_mh_log().warning("Import: could not discard failed download folder %s: %s", local_path, e)
338+
339+
326340
def _cleanup_source_folder(local_path: str, root_folder: str, title: str, year: str) -> None:
327341
"""
328342
Remove the source download folder after successful import.
@@ -402,6 +416,7 @@ def import_movie(client: Dict[str, Any], title: str, year: str, download_path: s
402416
video_file = _find_largest_video_file(local_path)
403417
if not video_file:
404418
_mh_log().error("Import: no video file found in %s", local_path)
419+
_cleanup_on_import_failure(local_path, root_folder, title, year)
405420
return False
406421

407422
# 4. Create movie folder and filename using format settings
@@ -429,6 +444,7 @@ def import_movie(client: Dict[str, Any], title: str, year: str, download_path: s
429444
os.makedirs(dest_folder, exist_ok=True)
430445
except Exception as e:
431446
_mh_log().error("Import: failed to create folder %s: %s", dest_folder, e)
447+
_cleanup_on_import_failure(local_path, root_folder, title, year)
432448
return False
433449

434450
dest_file = os.path.join(dest_folder, file_name)
@@ -458,6 +474,7 @@ def import_movie(client: Dict[str, Any], title: str, year: str, download_path: s
458474
"Import: failed to move file: %s. Reason: %s. Check permissions and that destination is writable.",
459475
video_file, e
460476
)
477+
_cleanup_on_import_failure(local_path, root_folder, title, year)
461478
return False
462479

463480
# 8. Update collection status
@@ -481,4 +498,11 @@ def import_movie(client: Dict[str, Any], title: str, year: str, download_path: s
481498

482499
except Exception as e:
483500
_mh_log().exception("Import: error for '%s' (%s): %s", title, year, e)
501+
try:
502+
local_path = locals().get('local_path')
503+
root_folder = locals().get('root_folder')
504+
if local_path and root_folder:
505+
_cleanup_on_import_failure(local_path, root_folder, title, year)
506+
except Exception:
507+
pass
484508
return False

src/primary/apps/tv_hunt/importer.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,19 @@ def _add_import_history(series_title: str, season: int, episode: int,
223223
logger.error("Error adding TV import history: %s", e)
224224

225225

226+
def _cleanup_on_import_failure(local_path: str, root_folder: str,
227+
series_title: str, season: int, episode: int) -> None:
228+
"""Remove the source download folder when import fails. Frees disk space."""
229+
if not local_path or not root_folder:
230+
return
231+
try:
232+
_cleanup_source_folder(local_path, root_folder, series_title, season, episode)
233+
_tv_log().info("Import: discarded failed download for '%s' S%02dE%02d to free space",
234+
series_title, season or 0, episode or 0)
235+
except Exception as e:
236+
_tv_log().warning("Import: could not discard failed download folder %s: %s", local_path, e)
237+
238+
226239
def _cleanup_source_folder(local_path: str, root_folder: str,
227240
series_title: str, season: int, episode: int) -> None:
228241
"""Remove the source download folder after successful import."""
@@ -298,6 +311,7 @@ def import_episode(client: Dict[str, Any], series_title: str, year: str,
298311
video_file = _find_largest_video_file(local_path)
299312
if not video_file:
300313
_tv_log().error("Import: no video file found in %s", local_path)
314+
_cleanup_on_import_failure(local_path, root_folder, series_title, season, episode)
301315
return False
302316

303317
# 4. Generate folder and file names using format settings
@@ -335,6 +349,7 @@ def import_episode(client: Dict[str, Any], series_title: str, year: str,
335349
os.makedirs(dest_season_folder, exist_ok=True)
336350
except Exception as e:
337351
_tv_log().error("Import: failed to create folder %s: %s", dest_season_folder, e)
352+
_cleanup_on_import_failure(local_path, root_folder, series_title, season, episode)
338353
return False
339354

340355
# 5. Check if file already exists
@@ -355,6 +370,7 @@ def import_episode(client: Dict[str, Any], series_title: str, year: str,
355370
shutil.move(video_file, dest_file)
356371
except Exception as e:
357372
_tv_log().error("Import: failed to move file: %s -> %s. Reason: %s", video_file, dest_file, e)
373+
_cleanup_on_import_failure(local_path, root_folder, series_title, season, episode)
358374
return False
359375

360376
# 7. Update collection status
@@ -377,4 +393,11 @@ def import_episode(client: Dict[str, Any], series_title: str, year: str,
377393
except Exception as e:
378394
_tv_log().exception("Import: error for '%s' S%02dE%02d: %s",
379395
series_title, season or 0, episode or 0, e)
396+
try:
397+
local_path = locals().get('local_path')
398+
root_folder = locals().get('root_folder')
399+
if local_path and root_folder:
400+
_cleanup_on_import_failure(local_path, root_folder, series_title, season, episode)
401+
except Exception:
402+
pass
380403
return False

src/primary/routes/media_hunt/discovery_movie.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,10 @@ def _add_nzb_to_download_client(client, nzb_url, nzb_name, category, verify_ssl,
222222
username = (client.get('username') or '').strip()
223223
password = (client.get('password') or '').strip()
224224
auth = (username, password) if (username or password) else None
225+
nzb_filename = (nzb_name or '').strip() or (nzb_url.split('/')[-1].split('?')[0] if nzb_url else '') or 'download.nzb'
225226
payload = {
226227
'method': 'append',
227-
'params': [nzb_name or '', nzb_url, cat, 0, False, False, '', 0, 'SCORE', False, []],
228+
'params': [nzb_filename, nzb_url, cat, 0, False, False, '', 0, 'SCORE', False, []],
228229
'id': 1
229230
}
230231
r = requests.post(jsonrpc_url, json=payload, auth=auth, timeout=15, verify=verify_ssl)

0 commit comments

Comments
 (0)