Spaces:
Running
Running
Update app.py
Browse files
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
|
62 |
|
63 |
except json.JSONDecodeError as e:
|
64 |
-
|
65 |
-
continue
|
66 |
|
67 |
# λͺ¨λ μΈμ΄μμ μλ§μ μ°Ύμ§ λͺ»ν κ²½μ°
|
68 |
-
return {"error": "μ°μ μμ μΈμ΄λ‘ μλ§μ μ°Ύμ μ μμ΅λλ€."
|
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):
|