AIRider commited on
Commit
6d85d92
β€’
1 Parent(s): bd83a36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -15
app.py CHANGED
@@ -36,36 +36,24 @@ def get_youtube_transcript(youtube_url):
36
  "x-rapidapi-host": AA_HOST
37
  }
38
 
39
- debug_info = []
40
-
41
  # μ–Έμ–΄ μš°μ„ μˆœμœ„μ— 따라 순차적으둜 μš”μ²­μ„ μ‹œλ„
42
  for lang in LANGUAGE_PRIORITY:
43
  querystring = {"video_id": video_id, "lang": lang}
44
  response = requests.get(url, headers=headers, params=querystring)
45
 
46
- debug_info.append(f"Language: {lang}, Status Code: {response.status_code}")
47
-
48
  # μƒνƒœ μ½”λ“œ 확인 및 전체 응닡 λ°˜ν™˜
49
  if response.status_code == 200:
50
  try:
51
  data = response.json()
52
- debug_info.append(f"Response data type: {type(data)}")
53
- debug_info.append(f"Response data: {data[:100]}...") # 처음 100자만 좜λ ₯
54
-
55
- # 응닡이 λΉ„μ–΄μžˆκ±°λ‚˜ μ˜ˆμƒμΉ˜ λͺ»ν•œ ν˜•μ‹μΈ 경우 처리
56
- if not data or (isinstance(data, dict) and not data.get('transcript')):
57
- debug_info.append(f"No transcript found for language: {lang}")
58
- continue
59
 
60
  # 전체 응닡 데이터λ₯Ό κ·ΈλŒ€λ‘œ λ°˜ν™˜
61
- return {"language": lang, "data": data, "debug_info": debug_info}
62
 
63
  except json.JSONDecodeError as e:
64
- debug_info.append(f"JSON decoding error: {str(e)}")
65
- continue
66
 
67
  # λͺ¨λ“  μ–Έμ–΄μ—μ„œ μžλ§‰μ„ 찾지 λͺ»ν•œ 경우
68
- return {"error": "μš°μ„ μˆœμœ„ μ–Έμ–΄λ‘œ μžλ§‰μ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€.", "debug_info": debug_info}
69
 
70
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
71
  def youtube_transcript_interface(youtube_url):
 
36
  "x-rapidapi-host": AA_HOST
37
  }
38
 
 
 
39
  # μ–Έμ–΄ μš°μ„ μˆœμœ„μ— 따라 순차적으둜 μš”μ²­μ„ μ‹œλ„
40
  for lang in LANGUAGE_PRIORITY:
41
  querystring = {"video_id": video_id, "lang": lang}
42
  response = requests.get(url, headers=headers, params=querystring)
43
 
 
 
44
  # μƒνƒœ μ½”λ“œ 확인 및 전체 응닡 λ°˜ν™˜
45
  if response.status_code == 200:
46
  try:
47
  data = response.json()
 
 
 
 
 
 
 
48
 
49
  # 전체 응닡 데이터λ₯Ό κ·ΈλŒ€λ‘œ λ°˜ν™˜
50
+ return {"language": lang, "data": data}
51
 
52
  except json.JSONDecodeError as e:
53
+ return {"error": f"JSON λ””μ½”λ”© 였λ₯˜ λ°œμƒ: {str(e)}"}
 
54
 
55
  # λͺ¨λ“  μ–Έμ–΄μ—μ„œ μžλ§‰μ„ 찾지 λͺ»ν•œ 경우
56
+ return {"error": "μš°μ„ μˆœμœ„ μ–Έμ–΄λ‘œ μžλ§‰μ„ 찾을 수 μ—†μŠ΅λ‹ˆλ‹€."}
57
 
58
  # Gradio μΈν„°νŽ˜μ΄μŠ€ μ •μ˜
59
  def youtube_transcript_interface(youtube_url):