hakandinger commited on
Commit
b0609ef
·
1 Parent(s): 3bec35d

disable external URL access on Hugging Face Spaces

Browse files
Files changed (1) hide show
  1. app.py +35 -8
app.py CHANGED
@@ -20,13 +20,26 @@ import tempfile
20
  from urllib.parse import urlparse
21
  import logging
22
 
23
-
24
  logging.basicConfig(
25
  level=logging.INFO,
26
  format='%(asctime)s - %(levelname)s - %(message)s'
27
  )
28
  logger = logging.getLogger(__name__)
29
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  try:
32
  import yt_dlp
@@ -541,6 +554,9 @@ def process_video_gradio(video_file, video_url, progress=gr.Progress()):
541
  try:
542
  progress(0, desc="İşlem başlatılıyor...")
543
 
 
 
 
544
  if video_url and video_url.strip():
545
  video_source = video_url.strip()
546
  is_url = True
@@ -664,13 +680,24 @@ with gr.Blocks(title="Yüz Tanıma Sistemi", theme=gr.themes.Soft()) as demo:
664
  with gr.Row():
665
  with gr.Column():
666
  video_input = gr.Video(label="📁 Yerel Video Yükle",height=300)
667
- gr.Markdown("**VEYA**")
668
- url_input = gr.Textbox(
669
- label="🌐 Video URL'si",
670
- placeholder="https://example.com/video.mp4",
671
- lines=1
672
- )
673
- gr.Markdown("*URL girilirse öncelikle o kullanılır*")
 
 
 
 
 
 
 
 
 
 
 
674
 
675
  process_btn = gr.Button("🚀 İşlemi Başlat", variant="primary", size="lg")
676
  status_text = gr.Textbox(label="Durum", interactive=False)
 
20
  from urllib.parse import urlparse
21
  import logging
22
 
 
23
  logging.basicConfig(
24
  level=logging.INFO,
25
  format='%(asctime)s - %(levelname)s - %(message)s'
26
  )
27
  logger = logging.getLogger(__name__)
28
 
29
+ IS_HUGGINGFACE = os.getenv("SPACE_ID") is not None
30
+
31
+ if IS_HUGGINGFACE:
32
+ YOUTUBE_SUPPORT = False
33
+ logger.info("🌐 Hugging Face Spaces modunda çalışıyor - YouTube desteği kapalı")
34
+ else:
35
+ try:
36
+ import yt_dlp
37
+ YOUTUBE_SUPPORT = True
38
+ logger.info("✅ YouTube desteği aktif")
39
+ except ImportError:
40
+ YOUTUBE_SUPPORT = False
41
+ logger.warning("⚠️ yt-dlp yüklü değil")
42
+
43
 
44
  try:
45
  import yt_dlp
 
554
  try:
555
  progress(0, desc="İşlem başlatılıyor...")
556
 
557
+ if IS_HUGGINGFACE and video_url and video_url.strip():
558
+ return [], "❌ Hugging Face Spaces'te URL/YouTube desteği bulunmamaktadır. Lütfen video dosyası yükleyin.", "❌ URL desteği yok"
559
+
560
  if video_url and video_url.strip():
561
  video_source = video_url.strip()
562
  is_url = True
 
680
  with gr.Row():
681
  with gr.Column():
682
  video_input = gr.Video(label="📁 Yerel Video Yükle",height=300)
683
+
684
+ if not IS_HUGGINGFACE:
685
+ gr.Markdown("**VEYA**")
686
+ url_input = gr.Textbox(
687
+ label="🌐 Video URL'si",
688
+ placeholder="https://example.com/video.mp4 veya YouTube linki",
689
+ lines=1,
690
+ interactive=True
691
+ )
692
+ gr.Markdown("*URL girilirse öncelikle o kullanılır*")
693
+ else:
694
+ url_input = gr.Textbox(
695
+ label="🌐 Video URL'si (Devre Dışı)",
696
+ placeholder="Hugging Face Spaces'te URL desteği yok",
697
+ lines=1,
698
+ interactive=False,
699
+ visible=True
700
+ )
701
 
702
  process_btn = gr.Button("🚀 İşlemi Başlat", variant="primary", size="lg")
703
  status_text = gr.Textbox(label="Durum", interactive=False)