Spaces:
Sleeping
Sleeping
Fix Gradio compatibility and add HF Spaces secret support for OAuth
Browse files- app.py +22 -4
- requirements.txt +1 -1
app.py
CHANGED
|
@@ -6,7 +6,13 @@ import shutil
|
|
| 6 |
import logging
|
| 7 |
import time
|
| 8 |
from pathlib import Path
|
| 9 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
|
| 11 |
# Set up logging
|
| 12 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
@@ -312,8 +318,20 @@ def download_from_google_drive(file_id, file_display, drive_manager):
|
|
| 312 |
|
| 313 |
# Initialize Google Drive manager
|
| 314 |
try:
|
| 315 |
-
|
| 316 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 317 |
except Exception as e:
|
| 318 |
logger.warning(f"Google Drive initialization failed: {e}")
|
| 319 |
drive_manager = None
|
|
@@ -346,7 +364,7 @@ function seekVideo(slider_value, video_id) {
|
|
| 346 |
}
|
| 347 |
"""
|
| 348 |
|
| 349 |
-
with gr.Blocks(title="Video Trimmer Tool", theme=gr.themes.Soft(), css=custom_css
|
| 350 |
gr.Markdown("""
|
| 351 |
# 🎬 Video Trimmer Demo
|
| 352 |
Upload an MP4 video, set trim points, and generate trimmed video + audio files.
|
|
|
|
| 6 |
import logging
|
| 7 |
import time
|
| 8 |
from pathlib import Path
|
| 9 |
+
try:
|
| 10 |
+
from native_drive_picker import GoogleDrivePickerManager, get_native_picker_instructions, GOOGLE_DRIVE_AVAILABLE
|
| 11 |
+
except ImportError:
|
| 12 |
+
GOOGLE_DRIVE_AVAILABLE = False
|
| 13 |
+
GoogleDrivePickerManager = None
|
| 14 |
+
def get_native_picker_instructions():
|
| 15 |
+
return "Google Drive integration not available in this environment."
|
| 16 |
|
| 17 |
# Set up logging
|
| 18 |
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')
|
|
|
|
| 318 |
|
| 319 |
# Initialize Google Drive manager
|
| 320 |
try:
|
| 321 |
+
if GOOGLE_DRIVE_AVAILABLE and GoogleDrivePickerManager:
|
| 322 |
+
# Check if running on HF Space and use secret
|
| 323 |
+
oauth_json = os.getenv('OAUTH_CREDENTIALS_JSON')
|
| 324 |
+
if oauth_json:
|
| 325 |
+
# Write the secret to a temporary file
|
| 326 |
+
with open('oauth_credentials.json', 'w') as f:
|
| 327 |
+
f.write(oauth_json)
|
| 328 |
+
logger.info("OAuth credentials loaded from HF secret")
|
| 329 |
+
|
| 330 |
+
drive_manager = GoogleDrivePickerManager()
|
| 331 |
+
drive_available = drive_manager.is_available()
|
| 332 |
+
else:
|
| 333 |
+
drive_manager = None
|
| 334 |
+
drive_available = False
|
| 335 |
except Exception as e:
|
| 336 |
logger.warning(f"Google Drive initialization failed: {e}")
|
| 337 |
drive_manager = None
|
|
|
|
| 364 |
}
|
| 365 |
"""
|
| 366 |
|
| 367 |
+
with gr.Blocks(title="Video Trimmer Tool", theme=gr.themes.Soft(), css=custom_css) as demo:
|
| 368 |
gr.Markdown("""
|
| 369 |
# 🎬 Video Trimmer Demo
|
| 370 |
Upload an MP4 video, set trim points, and generate trimmed video + audio files.
|
requirements.txt
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
gradio>=4.
|
| 2 |
numpy>=1.24.0
|
| 3 |
Pillow>=9.0.0
|
| 4 |
watchdog>=3.0.0
|
|
|
|
| 1 |
+
gradio>=4.44.0
|
| 2 |
numpy>=1.24.0
|
| 3 |
Pillow>=9.0.0
|
| 4 |
watchdog>=3.0.0
|