Rthur2003 commited on
Commit
0406dc2
·
1 Parent(s): 4c4829f

refactor: update model version in Gemini AI Service and optimize transcript fetching in YouTube Service

Browse files
app/routes/commend/gemini_service.py CHANGED
@@ -97,7 +97,7 @@ Rules: 1-2 sentences, natural, specific to video, max 1 emoji.
97
  Comment:"""
98
 
99
  response = client.models.generate_content(
100
- model="gemini-1.5-flash",
101
  contents=prompt
102
  )
103
 
 
97
  Comment:"""
98
 
99
  response = client.models.generate_content(
100
+ model="gemini-2.5-flash-lite",
101
  contents=prompt
102
  )
103
 
app/routes/commend/youtube_service.py CHANGED
@@ -233,22 +233,16 @@ def get_video_transcript(video_id: str) -> Tuple[Optional[str], Optional[str]]:
233
  try:
234
  from youtube_transcript_api import YouTubeTranscriptApi
235
 
236
- transcript_list = YouTubeTranscriptApi.list_transcripts(video_id)
237
-
238
- # Dil önceliği: tr -> en -> auto
239
- for lang in ['tr', 'en']:
240
- try:
241
- transcript = transcript_list.find_transcript([lang])
242
- break
243
- except:
244
- continue
245
- else:
246
  try:
247
- transcript = transcript_list.find_generated_transcript(['tr', 'en'])
248
- except:
249
  return None, "No transcript available"
250
 
251
- transcript_data = transcript.fetch()
252
  full_text = ' '.join([entry['text'] for entry in transcript_data])
253
 
254
  # Token limiti için kısalt
 
233
  try:
234
  from youtube_transcript_api import YouTubeTranscriptApi
235
 
236
+ # Yeni API: doğrudan get_transcript kullan
237
+ try:
238
+ transcript_data = YouTubeTranscriptApi.get_transcript(video_id, languages=['tr', 'en'])
239
+ except Exception:
240
+ # Otomatik oluşturulan altyazıyı dene
 
 
 
 
 
241
  try:
242
+ transcript_data = YouTubeTranscriptApi.get_transcript(video_id)
243
+ except Exception:
244
  return None, "No transcript available"
245
 
 
246
  full_text = ' '.join([entry['text'] for entry in transcript_data])
247
 
248
  # Token limiti için kısalt