This commit is contained in:
+42
-7
@@ -541,12 +541,33 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
raise HTTPException(status_code=400, detail="scan_type must be 'both', 'tv', or 'movies'")
|
||||
|
||||
async def run_scan():
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
import time
|
||||
import os
|
||||
start_time = datetime.now()
|
||||
# Get local time for display
|
||||
local_start = datetime.fromtimestamp(start_time.timestamp())
|
||||
print(f"🚀 MANUAL SCAN STARTED: {scan_type} scan initiated at {local_start.strftime('%Y-%m-%d %H:%M:%S')} (local time)")
|
||||
|
||||
# Try to get local timezone - handle Docker container case
|
||||
try:
|
||||
# Check if TZ environment variable is set
|
||||
tz_name = os.environ.get('TZ')
|
||||
if tz_name:
|
||||
import zoneinfo
|
||||
local_tz = zoneinfo.ZoneInfo(tz_name)
|
||||
local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
|
||||
tz_display = f" ({tz_name})"
|
||||
else:
|
||||
# Fallback: assume EDT/EST based on PostgreSQL logs showing EDT
|
||||
# This is a reasonable assumption for your deployment
|
||||
import zoneinfo
|
||||
local_tz = zoneinfo.ZoneInfo("America/New_York")
|
||||
local_start = start_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
|
||||
tz_display = " (EDT/EST)"
|
||||
except:
|
||||
# Ultimate fallback - just show UTC with note
|
||||
local_start = start_time
|
||||
tz_display = " (UTC - container time)"
|
||||
|
||||
print(f"🚀 MANUAL SCAN STARTED: {scan_type} scan initiated at {local_start.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}")
|
||||
|
||||
paths_to_scan = []
|
||||
if path:
|
||||
@@ -632,9 +653,23 @@ async def manual_scan(background_tasks: BackgroundTasks, path: Optional[str] = N
|
||||
end_time = datetime.now()
|
||||
duration = end_time - start_time
|
||||
duration_str = str(duration).split('.')[0] # Remove microseconds
|
||||
# Get local time for display
|
||||
local_end = datetime.fromtimestamp(end_time.timestamp())
|
||||
print(f"✅ MANUAL SCAN COMPLETED: {scan_type} scan finished at {local_end.strftime('%Y-%m-%d %H:%M:%S')} (local time)")
|
||||
|
||||
# Use same timezone logic as start
|
||||
try:
|
||||
tz_name = os.environ.get('TZ')
|
||||
if tz_name:
|
||||
local_tz = zoneinfo.ZoneInfo(tz_name)
|
||||
local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
|
||||
tz_display = f" ({tz_name})"
|
||||
else:
|
||||
local_tz = zoneinfo.ZoneInfo("America/New_York")
|
||||
local_end = end_time.replace(tzinfo=timezone.utc).astimezone(local_tz)
|
||||
tz_display = " (EDT/EST)"
|
||||
except:
|
||||
local_end = end_time
|
||||
tz_display = " (UTC - container time)"
|
||||
|
||||
print(f"✅ MANUAL SCAN COMPLETED: {scan_type} scan finished at {local_end.strftime('%Y-%m-%d %H:%M:%S')}{tz_display}")
|
||||
print(f"⏱️ MANUAL SCAN DURATION: {duration_str} (total time: {duration.total_seconds():.1f} seconds)")
|
||||
|
||||
background_tasks.add_task(run_scan)
|
||||
|
||||
Reference in New Issue
Block a user