oha
This commit is contained in:
@@ -259,7 +259,34 @@ def process_channel(channel_id: str, max_items: int = 50) -> dict:
|
||||
|
||||
# ÖNCE: Mevcut işlenmiş videoları kontrol et
|
||||
existing_processed = db.get_processed_videos(limit=max_items, channel_id=channel_id)
|
||||
logger.info(f"[PROCESS] Channel {channel_id} için {len(existing_processed)} mevcut işlenmiş video bulundu")
|
||||
logger.info(f"[PROCESS] Channel {channel_id} için {len(existing_processed)} mevcut işlenmiş video bulundu (max_items: {max_items})")
|
||||
|
||||
# Debug: Veritabanında kaç video var (tüm status'ler)
|
||||
try:
|
||||
conn = db.connect()
|
||||
cursor = conn.cursor()
|
||||
cursor.execute("""
|
||||
SELECT transcript_status, COUNT(*) as count
|
||||
FROM videos
|
||||
WHERE channel_id = ?
|
||||
GROUP BY transcript_status
|
||||
""", (channel_id,))
|
||||
rows = cursor.fetchall()
|
||||
status_counts = {}
|
||||
for row in rows:
|
||||
if isinstance(row, dict):
|
||||
status_counts[row['transcript_status']] = row['count']
|
||||
else:
|
||||
# sqlite3.Row formatı
|
||||
status_counts[row[0]] = row[1]
|
||||
logger.info(f"[PROCESS] 📊 Veritabanı durumu - Channel {channel_id}: Status 0 (bekleyen): {status_counts.get(0, 0)}, Status 1 (işlenmiş): {status_counts.get(1, 0)}, Status 2 (başarısız): {status_counts.get(2, 0)}")
|
||||
|
||||
# İşlenmiş videoların video_id'lerini de logla (ilk 5)
|
||||
if len(existing_processed) > 0:
|
||||
video_ids = [v.get('video_id', 'N/A') for v in existing_processed[:5]]
|
||||
logger.info(f"[PROCESS] 📋 İşlenmiş video ID'leri (ilk 5): {', '.join(video_ids)}")
|
||||
except Exception as e:
|
||||
logger.error(f"[PROCESS] ❌ Veritabanı durumu kontrol hatası: {type(e).__name__} - {str(e)}")
|
||||
|
||||
# Eğer yeterli sayıda işlenmiş video varsa, onları hemen döndür
|
||||
if len(existing_processed) >= max_items:
|
||||
@@ -317,7 +344,10 @@ def process_channel(channel_id: str, max_items: int = 50) -> dict:
|
||||
|
||||
# Tüm bekleyen videoları al (channel_id'ye göre filtrele)
|
||||
all_pending_videos = [v for v in db.get_pending_videos() if v['channel_id'] == channel_id]
|
||||
logger.info(f"[PROCESS] Channel {channel_id} için {len(all_pending_videos)} bekleyen video bulundu (max_items: {max_items})")
|
||||
|
||||
# Debug: Tüm videoları kontrol et (bekleyen + işlenmiş)
|
||||
all_videos_count = len([v for v in db.get_processed_videos(limit=1000, channel_id=channel_id)])
|
||||
logger.info(f"[PROCESS] Channel {channel_id} için {len(all_pending_videos)} bekleyen video, {all_videos_count} işlenmiş video bulundu (max_items: {max_items})")
|
||||
|
||||
# Eğer mevcut işlenmiş videolar varsa, sadece eksik kadar işle
|
||||
remaining_needed = max_items - len(videos_to_return)
|
||||
@@ -432,7 +462,10 @@ def process_channel(channel_id: str, max_items: int = 50) -> dict:
|
||||
reverse=True
|
||||
)
|
||||
|
||||
logger.info(f"[PROCESS] ✅ Channel {channel_id} işleme tamamlandı - {len(all_processed_videos)} işlenmiş video döndürülüyor (Mevcut: {len(videos_to_return)}, Yeni işlenen: {len(newly_processed)})")
|
||||
# Debug: Gerçek durumu logla
|
||||
newly_processed_count = len([v for v in newly_processed if v['video_id'] not in {v['video_id'] for v in videos_to_return}])
|
||||
logger.info(f"[PROCESS] ✅ Channel {channel_id} işleme tamamlandı - {len(all_processed_videos)} işlenmiş video döndürülüyor")
|
||||
logger.info(f"[PROCESS] 📊 Detay: Mevcut işlenmiş: {len(videos_to_return)}, Yeni işlenen: {newly_processed_count}, Toplam: {len(all_processed_videos)}")
|
||||
|
||||
return {
|
||||
'videos': all_processed_videos[:max_items],
|
||||
@@ -601,6 +634,13 @@ def generate_feed():
|
||||
}), 404
|
||||
|
||||
# RSS feed oluştur
|
||||
logger.info(f"[FEED] RSS feed oluşturuluyor - Channel: {normalized_channel_id}, Video sayısı: {len(result['videos'])}")
|
||||
|
||||
# Debug: Video ID'lerini logla
|
||||
if result['videos']:
|
||||
video_ids = [v.get('video_id', 'N/A') for v in result['videos'][:5]]
|
||||
logger.info(f"[FEED] 📋 Feed'e eklenecek video ID'leri (ilk 5): {', '.join(video_ids)}")
|
||||
|
||||
channel_info = {
|
||||
'id': normalized_channel_id,
|
||||
'title': f"YouTube Transcript Feed - {normalized_channel_id}",
|
||||
@@ -614,6 +654,8 @@ def generate_feed():
|
||||
for video in result['videos']:
|
||||
generator.add_video_entry(video)
|
||||
|
||||
logger.info(f"[FEED] ✅ RSS feed oluşturuldu - {len(result['videos'])} video eklendi")
|
||||
|
||||
# Format'a göre döndür
|
||||
response_headers = {}
|
||||
if hasattr(g, 'rate_limit_remaining'):
|
||||
|
||||
Reference in New Issue
Block a user