diff --git a/__pycache__/check_srt.cpython-311.pyc b/__pycache__/check_srt.cpython-311.pyc deleted file mode 100644 index cc4eab1..0000000 Binary files a/__pycache__/check_srt.cpython-311.pyc and /dev/null differ diff --git a/__pycache__/fix_srt.cpython-311.pyc b/__pycache__/fix_srt.cpython-311.pyc deleted file mode 100644 index 9948dcd..0000000 Binary files a/__pycache__/fix_srt.cpython-311.pyc and /dev/null differ diff --git a/check_srt.py b/check_srt.py deleted file mode 100644 index 382663b..0000000 --- a/check_srt.py +++ /dev/null @@ -1,109 +0,0 @@ -import re - -def check_srt_format(file_path): - """SRT dosyasını kontrol eder ve hataları bulur.""" - - errors = [] - warnings = [] - - with open(file_path, 'r', encoding='utf-8') as f: - lines = f.readlines() - - i = 0 - subtitle_count = 0 - - while i < len(lines): - # Boş satırları atla - while i < len(lines) and lines[i].strip() == '': - i += 1 - - if i >= len(lines): - break - - subtitle_count += 1 - expected_number = subtitle_count - - # Satır 1: Altyazı numarası - line_num = i + 1 - if not lines[i].strip().isdigit(): - errors.append(f"Satır {line_num}: Altyazı numarası bekleniyor, bulunan: '{lines[i].strip()}'") - else: - actual_number = int(lines[i].strip()) - if actual_number != expected_number: - warnings.append(f"Satır {line_num}: Altyazı numarası {expected_number} olmalı, {actual_number} bulundu") - - i += 1 - - if i >= len(lines): - errors.append(f"Altyazı {subtitle_count}: Zaman damgası eksik") - break - - # Satır 2: Zaman damgası - line_num = i + 1 - timestamp_pattern = r'^\d{2}:\d{2}:\d{2},\d{3}\s*-->\s*\d{2}:\d{2}:\d{2},\d{3}$' - - if not re.match(timestamp_pattern, lines[i].strip()): - # Hatalı formatları tespit et - timestamp_line = lines[i].strip() - - # Yaygın hatalar - if '-->' in timestamp_line: - # Virgül yerine nokta kullanımı - if '.' in timestamp_line and ',' not in timestamp_line: - errors.append(f"Satır {line_num}: Milisaniye ayırıcı virgül (,) olmalı, nokta (.) değil: '{timestamp_line}'") - # Eksik sıfırlar - elif re.search(r'\d{1}:\d{2}:\d{2}', timestamp_line): - errors.append(f"Satır {line_num}: Saat/dakika/saniye 2 haneli olmalı: '{timestamp_line}'") - # Eksik/fazla milisaniye basamağı - elif re.search(r',\d{1,2}[^\d]|,\d{1,2}$', timestamp_line): - errors.append(f"Satır {line_num}: Milisaniye 3 haneli olmalı: '{timestamp_line}'") - elif re.search(r',\d{4,}', timestamp_line): - errors.append(f"Satır {line_num}: Milisaniye 3 haneli olmalı (fazla basamak): '{timestamp_line}'") - else: - errors.append(f"Satır {line_num}: Geçersiz zaman damgası formatı: '{timestamp_line}'") - else: - errors.append(f"Satır {line_num}: Zaman damgası bekleniyor (-->), bulunan: '{timestamp_line}'") - - i += 1 - - # Satır 3+: Altyazı metni - text_lines = [] - while i < len(lines) and lines[i].strip() != '': - text_lines.append(lines[i]) - i += 1 - - if not text_lines: - warnings.append(f"Altyazı {subtitle_count} (satır {line_num}): Metin içeriği boş") - - print(f"Toplam altyazı sayısı: {subtitle_count}") - print(f"\n{'='*60}") - - if errors: - print(f"\nHATALAR ({len(errors)} adet):") - print("="*60) - for error in errors[:50]: # İlk 50 hatayı göster - print(f" - {error}") - if len(errors) > 50: - print(f"\n ... ve {len(errors) - 50} hata daha") - else: - print("\nKritik hata bulunamadi!") - - if warnings: - print(f"\nUYARILAR ({len(warnings)} adet):") - print("="*60) - for warning in warnings[:20]: # İlk 20 uyarıyı göster - print(f" - {warning}") - if len(warnings) > 20: - print(f"\n ... ve {len(warnings) - 20} uyari daha") - - return errors, warnings - -if __name__ == "__main__": - import sys - file_path = sys.argv[1] if len(sys.argv) > 1 else "public/ses.srt" - errors, warnings = check_srt_format(file_path) - - if not errors and not warnings: - print("\nSRT dosyasi tamamen dogru formatta!") - else: - print(f"\nOzet: {len(errors)} hata, {len(warnings)} uyari") diff --git a/comprehensive_srt_check.py b/comprehensive_srt_check.py deleted file mode 100644 index 7285e45..0000000 --- a/comprehensive_srt_check.py +++ /dev/null @@ -1,281 +0,0 @@ -import re -from datetime import datetime, timedelta - -def comprehensive_srt_check(file_path): - """Kapsamlı SRT format kontrolü - tüm olası hataları yakalar.""" - - errors = [] - warnings = [] - - with open(file_path, 'r', encoding='utf-8') as f: - lines = f.readlines() - - i = 0 - subtitle_count = 0 - prev_end_time = None - - while i < len(lines): - # Boş satırları atla - while i < len(lines) and lines[i].strip() == '': - i += 1 - - if i >= len(lines): - break - - subtitle_count += 1 - start_line = i + 1 - - # ===== 1. ALTYAZI NUMARASI KONTROLÜ ===== - line_num = i + 1 - line_content = lines[i].strip() - - if not line_content: - errors.append(f"Satir {line_num}: Bos satir, altyazi numarasi bekleniyor") - i += 1 - continue - - if not line_content.isdigit(): - errors.append(f"Satir {line_num}: Altyazi numarasi olmali, bulunan: '{line_content[:50]}'") - # Sonraki geçerli numarayı bulmaya çalış - while i < len(lines) and not lines[i].strip().isdigit(): - i += 1 - if i >= len(lines): - break - else: - actual_number = int(line_content) - if actual_number != subtitle_count: - warnings.append(f"Satir {line_num}: Numara sırası bozuk - beklenen: {subtitle_count}, bulunan: {actual_number}") - - i += 1 - - # ===== 2. ZAMAN DAMGASI KONTROLÜ ===== - if i >= len(lines): - errors.append(f"Altyazi {subtitle_count}: Zaman damgasi eksik (dosya sonu)") - break - - line_num = i + 1 - timestamp_line = lines[i].strip() - - if not timestamp_line: - errors.append(f"Satir {line_num}: Bos satir, zaman damgasi bekleniyor") - i += 1 - continue - - # Zaman damgası formatını detaylı kontrol et - if '-->' not in timestamp_line: - errors.append(f"Satir {line_num}: '-->' ayirici bulunamadi: '{timestamp_line[:50]}'") - i += 1 - continue - - parts = timestamp_line.split('-->') - if len(parts) != 2: - errors.append(f"Satir {line_num}: Gecersiz zaman damgasi formati: '{timestamp_line[:50]}'") - i += 1 - continue - - start_time_str = parts[0].strip() - end_time_str = parts[1].strip() - - # Başlangıç zamanı kontrolü - start_errors = validate_timestamp(start_time_str, "baslangic") - if start_errors: - for err in start_errors: - errors.append(f"Satir {line_num} {err}: '{start_time_str}'") - - # Bitiş zamanı kontrolü - end_errors = validate_timestamp(end_time_str, "bitis") - if end_errors: - for err in end_errors: - errors.append(f"Satir {line_num} {err}: '{end_time_str}'") - - # Zamanları parse et ve mantıksal kontroller yap - if not start_errors and not end_errors: - start_ms = parse_timestamp_to_ms(start_time_str) - end_ms = parse_timestamp_to_ms(end_time_str) - - if start_ms is None or end_ms is None: - errors.append(f"Satir {line_num}: Zaman parse edilemedi: '{timestamp_line}'") - else: - # Başlangıç >= Bitiş kontrolü - if start_ms >= end_ms: - errors.append(f"Satir {line_num}: Baslangic zamani bitis zamanindan buyuk/esit: {start_time_str} >= {end_time_str}") - - # Negatif zaman kontrolü - if start_ms < 0 or end_ms < 0: - errors.append(f"Satir {line_num}: Negatif zaman degeri: '{timestamp_line}'") - - # Çok uzun altyazı kontrolü (>10 saniye) - duration_ms = end_ms - start_ms - if duration_ms > 10000: - warnings.append(f"Satir {line_num}: Cok uzun altyazi suresi ({duration_ms/1000:.1f} saniye): {start_time_str} --> {end_time_str}") - - # Çok kısa altyazı kontrolü (<0.1 saniye) - if duration_ms < 100: - warnings.append(f"Satir {line_num}: Cok kisa altyazi suresi ({duration_ms}ms): {start_time_str} --> {end_time_str}") - - # Önceki altyazı ile çakışma kontrolü - if prev_end_time is not None and start_ms < prev_end_time: - time_overlap = prev_end_time - start_ms - warnings.append(f"Satir {line_num}: Onceki altyazi ile cakisma ({time_overlap}ms): {start_time_str}") - - prev_end_time = end_ms - - i += 1 - - # ===== 3. METİN İÇERİĞİ KONTROLÜ ===== - text_lines = [] - text_start_line = i + 1 - - while i < len(lines) and lines[i].strip() != '': - # Bir sonraki satır numara mı kontrol et (yeni altyazı başlangıcı) - if (i + 1 < len(lines) and - lines[i].strip().isdigit() and - '-->' in lines[i + 1]): - break - - text_lines.append(lines[i].rstrip()) - i += 1 - - if not text_lines: - warnings.append(f"Altyazi {subtitle_count} (satir {start_line}): Metin icerigi bos") - else: - # Metin kontrolü - full_text = ' '.join([t.strip() for t in text_lines]) - - # Çok uzun metin kontrolü - if len(full_text) > 200: - warnings.append(f"Altyazi {subtitle_count}: Cok uzun metin ({len(full_text)} karakter)") - - # HTML tag kontrolü - if re.search(r'<[^>]+>', full_text): - warnings.append(f"Altyazi {subtitle_count}: HTML/XML tag iceriyor (bazi oynaticilar desteklemeyebilir)") - - # Garip karakterler - if re.search(r'[\x00-\x08\x0B-\x0C\x0E-\x1F]', full_text): - warnings.append(f"Altyazi {subtitle_count}: Kontrol karakterleri iceriyor") - - return errors, warnings, subtitle_count - - -def validate_timestamp(time_str, time_type): - """Tek bir zaman damgasını (HH:MM:SS,mmm) doğrular.""" - errors = [] - - # Format: HH:MM:SS,mmm - pattern = r'^(\d{2}):(\d{2}):(\d{2}),(\d{3})$' - match = re.match(pattern, time_str) - - if not match: - # Hangi kısım hatalı bul - if ',' not in time_str and '.' not in time_str: - errors.append(f"({time_type}): Milisaniye ayirici eksik (virgul)") - elif '.' in time_str: - errors.append(f"({time_type}): Milisaniye ayirici nokta olmamali, virgul olmali") - elif time_str.count(':') != 2: - errors.append(f"({time_type}): ':' ayirici sayisi yanlis (2 olmali)") - else: - # Rakam sayısı kontrolü - parts = time_str.replace(',', ':').replace('.', ':').split(':') - if len(parts) == 4: - hours, mins, secs, ms = parts - if len(hours) != 2: - errors.append(f"({time_type}): Saat 2 haneli olmali") - if len(mins) != 2: - errors.append(f"({time_type}): Dakika 2 haneli olmali") - if len(secs) != 2: - errors.append(f"({time_type}): Saniye 2 haneli olmali") - if len(ms) != 3: - errors.append(f"({time_type}): Milisaniye 3 haneli olmali") - else: - errors.append(f"({time_type}): Format hatasi (HH:MM:SS,mmm olmali)") - return errors - - # Değer aralığı kontrolü - hours, mins, secs, ms = match.groups() - hours, mins, secs, ms = int(hours), int(mins), int(secs), int(ms) - - if hours > 23: - warnings = [] # Videolar 24 saatten uzun olabilir, warning olarak işaretle - if mins > 59: - errors.append(f"({time_type}): Dakika 59'dan buyuk olamaz ({mins})") - if secs > 59: - errors.append(f"({time_type}): Saniye 59'dan buyuk olamaz ({secs})") - if ms > 999: - errors.append(f"({time_type}): Milisaniye 999'dan buyuk olamaz ({ms})") - - return errors - - -def parse_timestamp_to_ms(time_str): - """Zaman damgasını milisaniyeye çevirir.""" - try: - # Format: HH:MM:SS,mmm - pattern = r'^(\d{2}):(\d{2}):(\d{2}),(\d{3})$' - match = re.match(pattern, time_str) - - if not match: - return None - - hours, mins, secs, ms = match.groups() - total_ms = (int(hours) * 3600 + int(mins) * 60 + int(secs)) * 1000 + int(ms) - return total_ms - except: - return None - - -def print_results(errors, warnings, subtitle_count, file_path): - """Sonuçları yazdır.""" - print(f"Dosya: {file_path}") - print(f"Toplam altyazi sayisi: {subtitle_count}") - print(f"\n{'='*70}") - - if errors: - print(f"\nHATALAR ({len(errors)} adet):") - print("="*70) - for i, error in enumerate(errors[:100], 1): - print(f" {i}. {error}") - if len(errors) > 100: - print(f"\n ... ve {len(errors) - 100} hata daha") - else: - print("\nKritik hata bulunamadi!") - - if warnings: - print(f"\nUYARILAR ({len(warnings)} adet):") - print("="*70) - for i, warning in enumerate(warnings[:50], 1): - print(f" {i}. {warning}") - if len(warnings) > 50: - print(f"\n ... ve {len(warnings) - 50} uyari daha") - else: - print("\nUyari bulunamadi!") - - print(f"\n{'='*70}") - - if not errors and not warnings: - print("\nSonuc: SRT dosyasi MUKEMMEL durumda!") - elif not errors: - print(f"\nSonuc: Format dogru ama {len(warnings)} uyari var") - else: - print(f"\nSonuc: {len(errors)} HATA, {len(warnings)} uyari") - - return errors, warnings - - -if __name__ == "__main__": - import sys - - file_path = sys.argv[1] if len(sys.argv) > 1 else "public/ses.srt" - - print("\nKAPSAMLI SRT FORMAT KONTROLU") - print("="*70) - print("\nKontrol edilen hususlar:") - print(" - Altyazi numara sirasi") - print(" - Zaman damgasi formati (HH:MM:SS,mmm)") - print(" - Baslangic/bitis zaman mantigi") - print(" - Altyazi cakismalari") - print(" - Altyazi sureleri") - print(" - Metin icerigi") - print("="*70) - - errors, warnings, subtitle_count = comprehensive_srt_check(file_path) - print_results(errors, warnings, subtitle_count, file_path) diff --git a/fix_srt.py b/fix_srt.py deleted file mode 100644 index a98625b..0000000 --- a/fix_srt.py +++ /dev/null @@ -1,187 +0,0 @@ -import re - -def fix_srt_file(input_path, output_path): - """SRT dosyasındaki format hatalarını düzeltir.""" - - with open(input_path, 'r', encoding='utf-8') as f: - content = f.read() - - lines = content.split('\n') - fixed_lines = [] - i = 0 - subtitle_number = 1 - errors_fixed = [] - - while i < len(lines): - # Boş satırları atla - while i < len(lines) and lines[i].strip() == '': - i += 1 - - if i >= len(lines): - break - - # Altyazı numarasını ekle/düzelt - fixed_lines.append(str(subtitle_number)) - - # Eğer mevcut satır numara değilse, bu satırı kaybetme - if not lines[i].strip().isdigit(): - # Bu satır muhtemelen yanlış yerleştirilmiş metin, geri al - pass - else: - i += 1 - - if i >= len(lines): - errors_fixed.append(f"Altyazı {subtitle_number}: Zaman damgası eksik (dosya sonu)") - break - - # Zaman damgasını bul ve düzelt - timestamp_line = lines[i].strip() - - if '-->' in timestamp_line: - # Zaman damgasını düzelt - fixed_timestamp = fix_timestamp(timestamp_line, subtitle_number) - if fixed_timestamp != timestamp_line: - errors_fixed.append(f"Altyazı {subtitle_number}: Zaman damgası düzeltildi") - errors_fixed.append(f" Eski: {timestamp_line}") - errors_fixed.append(f" Yeni: {fixed_timestamp}") - fixed_lines.append(fixed_timestamp) - i += 1 - else: - # Zaman damgası bulunamadı, bu bir format hatası - # Bu durumda bu satırı metin olarak kabul et - errors_fixed.append(f"Altyazı {subtitle_number}: Zaman damgası bulunamadı, atlanıyor") - # Sonraki geçerli zaman damgasını bul - found_timestamp = False - while i < len(lines) and not found_timestamp: - if '-->' in lines[i]: - fixed_timestamp = fix_timestamp(lines[i].strip(), subtitle_number) - fixed_lines.append(fixed_timestamp) - i += 1 - found_timestamp = True - else: - i += 1 - - if not found_timestamp: - errors_fixed.append(f"Altyazı {subtitle_number}: Hiç zaman damgası bulunamadı, atlanıyor") - break - - # Metin satırlarını topla - text_lines = [] - while i < len(lines) and lines[i].strip() != '' and '-->' not in lines[i]: - # Bir sonraki satır numara mı kontrol et - if i + 1 < len(lines) and lines[i + 1].strip() != '' and '-->' in lines[i + 1]: - # Bu muhtemelen metin - text_lines.append(lines[i]) - i += 1 - elif lines[i].strip().isdigit() and i + 1 < len(lines) and '-->' in lines[i + 1]: - # Bu bir sonraki altyazının numarası, dur - break - else: - text_lines.append(lines[i]) - i += 1 - - # Metni ekle - for text_line in text_lines: - fixed_lines.append(text_line.rstrip()) - - # Boş satır ekle - fixed_lines.append('') - - subtitle_number += 1 - - # Dosyayı kaydet - with open(output_path, 'w', encoding='utf-8') as f: - f.write('\n'.join(fixed_lines)) - - return errors_fixed, subtitle_number - 1 - - -def fix_timestamp(timestamp, subtitle_num): - """Zaman damgası formatını düzeltir.""" - - # Boşlukları temizle - parts = timestamp.split('-->') - if len(parts) != 2: - return timestamp - - start = parts[0].strip() - end = parts[1].strip() - - # Her iki tarafı da düzelt - start_fixed = fix_time_part(start) - end_fixed = fix_time_part(end) - - return f"{start_fixed} --> {end_fixed}" - - -def fix_time_part(time_str): - """Tek bir zaman bölümünü düzeltir (HH:MM:SS,mmm).""" - - # Virgül ve noktayı ayır - if ',' in time_str: - main_part, ms_part = time_str.rsplit(',', 1) - elif '.' in time_str: - main_part, ms_part = time_str.rsplit('.', 1) - # Noktayı virgüle çevir - else: - # Milisaniye yok, sonuna ekle - main_part = time_str - ms_part = '000' - - # HH:MM:SS kısmını düzelt - time_parts = main_part.split(':') - - # Eksik bölümleri tamamla - while len(time_parts) < 3: - time_parts.insert(0, '00') - - # Her bölümü 2 haneli yap - fixed_parts = [] - for part in time_parts: - # Sadece sayıları al - digits = ''.join(filter(str.isdigit, part)) - if not digits: - digits = '0' - # 2 haneli yap - fixed_parts.append(digits.zfill(2)) - - # Milisaniyeyi 3 haneli yap - ms_digits = ''.join(filter(str.isdigit, ms_part)) - if not ms_digits: - ms_digits = '000' - elif len(ms_digits) > 3: - ms_digits = ms_digits[:3] - else: - ms_digits = ms_digits.ljust(3, '0') - - return f"{':'.join(fixed_parts)},{ms_digits}" - - -if __name__ == "__main__": - print("SRT dosyası düzeltiliyor...") - print("="*60) - - errors_fixed, total_subtitles = fix_srt_file("public/ses.srt", "public/ses_fixed.srt") - - print(f"\nToplam {total_subtitles} altyazı işlendi") - - if errors_fixed: - print(f"\nDüzeltilen hatalar ({len([e for e in errors_fixed if not e.startswith(' ')])} adet):") - print("="*60) - for error in errors_fixed[:30]: - print(f" {error}") - if len(errors_fixed) > 30: - print(f"\n ... ve daha fazlası") - - print(f"\nDüzeltilmiş dosya kaydedildi: public/ses_fixed.srt") - print("\nŞimdi kontrol ediliyor...") - print("="*60) - - # Kontrol et - import check_srt - errors, warnings = check_srt.check_srt_format("public/ses_fixed.srt") - - if not errors: - print("\n✓ Tüm hatalar düzeltildi!") - else: - print(f"\nHala {len(errors)} hata var. Manuel düzeltme gerekebilir.")