From f57ee77c56cbf329f5cc96c3dd86ff5245454171 Mon Sep 17 00:00:00 2001 From: hibna Date: Thu, 12 Feb 2026 17:29:23 +0300 Subject: [PATCH] . --- __pycache__/check_srt.cpython-311.pyc | Bin 6017 -> 0 bytes __pycache__/fix_srt.cpython-311.pyc | Bin 8510 -> 0 bytes check_srt.py | 109 ---------- comprehensive_srt_check.py | 281 -------------------------- fix_srt.py | 187 ----------------- 5 files changed, 577 deletions(-) delete mode 100644 __pycache__/check_srt.cpython-311.pyc delete mode 100644 __pycache__/fix_srt.cpython-311.pyc delete mode 100644 check_srt.py delete mode 100644 comprehensive_srt_check.py delete mode 100644 fix_srt.py diff --git a/__pycache__/check_srt.cpython-311.pyc b/__pycache__/check_srt.cpython-311.pyc deleted file mode 100644 index cc4eab1daca5910b79655bf44e686808c0073484..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6017 zcmbsrTWk|ocE-=KJ$@wENyvjt0&U`uID|(V!ZYR3v?WvpS~WC~PCSz^*dCjiF$rdj z_}EGgV%31CaCbpox~W^Z?Ka%Yhuh1 z6QU3fnJ^Y-EO&7XyAOY(4Z_+<^GOS97QL)RbOVi*v6j=|An`b+uh;jQ+a|p5NCagO+fNcWuPFFwrt*8aEGMV>pftz%2M~ zO+!S|HrXm!7ldH)5?>?w(xh29yB0d(glv(m>lei37W`P4f=;>JjIEf*H)JbgPq{HH zZC#VD4X>_i8gxC^Yds=@Y0||1N46EMvdOlzUAGZ@NE0uwJ!dJ6!hF9x8sZKa&z0n3 zo(h9KClj#q951gIxSY%PD}O|SSkJeYms(ycX@~5P?GZiSLZfVYt`9ER4mOdp1F-wH zy<8HGt$809S*lw#VjkHB8oalc)HRMlUQLUcWPE9-1gFn@J3D{!V6yWS;!;+Blek#< z@-oscrb2d|$AmmnsehZ8b@0W7hE;tvc86bft&;73lzE8GBfT*J*;RgGyiiBgsyc43 zqNDnyb=0h?BeIH)^)IcXc2ylaUl8TGRXOWlz*)Z<=i;7+dx3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r_xjsM$22LwOpK1g2PXnVf1EcBy zrwwq$rP`=U#xydf=Amh%sEbprfB^p9XnYmsT(Lu4RDH7MlNFylOE@wgOxQB`tcxslbivRgIbNwfVt`8a zYh=Gd_Cpv-{jUF5A=W?kR$LudYJyWcrYpYh{?p#?_NtqAX`6Sc-rbsa_s^K$A>gwO z&AF~yAAfcFcc;~c4y~aha}?zG0$GpZeH~zST~#)utZN0BI{t%4={O9K_t)O+zurHG zVH^8QQ+>vF0gvH_ObY`bF#11ZSl}JguR4Yq=o|QPp!&vu(ztEG_51rE+(L`57g zYEYWvQ+OD*>^)kbXAU!$vX3G5F$5!0vC}-J`o}f@xT3?X5elU_hA3kQ2G15d%`w%_ zYkpqQVb)i5(|z5oY)DKIfDjDDik%G!)pt(wol|`07Sa!CsH(|0^J}f7s-MV)8L}bE z=6Y|PQOOpKY*EOT#R{{owZaI@R}1CtV4ybqpTB?QeWiYQ$^!`CuQkROuu6tCGOUo{ zxr;dFB1^0Pzn5^#>QtO><}LvOP%Yh>rCYIdKe9M79hvj+?@%o@nx#gu)Xdu5kaX+j zM}%APY`J|PXZ!NKTkk>F0F~&{h%SZbg7wVEg!`&HsbDV}WxsKj=S*sc)U zOYN*~%$akQIrEJ)GI5iRGH>hpo3qtQWixVZ|l-(+{tu3P5YOTD?=N-lNvVb+*_E4vPUAAMPOt4{H}1u%7d>iBfc dx2L{`tfDc1N*vIL1Ij$ixiL#E=oipq@PFF&n5h5& diff --git a/__pycache__/fix_srt.cpython-311.pyc b/__pycache__/fix_srt.cpython-311.pyc deleted file mode 100644 index 9948dcd0f3cc7b331d98fca3a6ec35f90c4d1167..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8510 zcmbt3ZEPDycDv+~T#`$1DN)vkEplnev}nnc+ulNKsl)VcO@wyqw(-MVcsZfhxt}>Y^?Xz&Ri&4(KkifOrc8Ao_vA|5T*G z<@~E}c14M#s90`Bv%~p#Z|2RLH*em1`qXB#V2}>47=mXSFzi22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oa=`nufEBOVx(8cxX#rzFCeJee9SSRJdF-Y|l%ZF?hz0$~)$ m1&td+89n@+{H682Rje7(vP2Hc= 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.")