@@ -515,6 +515,14 @@ List<String> _availableAudiobooks = [];
515515
516516 vttFiles.sort ();
517517
518+ if (vttFiles.isEmpty) {
519+ print ('=== MD CONVERSION: No VTT files found - check directory path ===' );
520+ setState (() {
521+ _transcriptionStatus = 'No VTT files found for markdown conversion' ;
522+ });
523+ return ;
524+ }
525+
518526 for (int i = 0 ; i < vttFiles.length; i++ ) {
519527 final vttPath = vttFiles[i];
520528 final vttFilename = path.basenameWithoutExtension (vttPath);
@@ -524,7 +532,10 @@ List<String> _availableAudiobooks = [];
524532 await File (vttPath).writeAsString (vttContent + '\n ' );
525533 final paragraphs = _createParagraphsFromVtt (vttContent);
526534
527- if (paragraphs.isEmpty) continue ;
535+ if (paragraphs.isEmpty) {
536+ print ('=== MD CONVERSION: Skipping $vttFilename - no paragraphs parsed ===' );
537+ continue ;
538+ }
528539
529540 final mdContent = StringBuffer ();
530541 mdContent.writeln ('# $vttFilename \n ' );
@@ -549,10 +560,27 @@ List<String> _availableAudiobooks = [];
549560 final mdFilename = '$cleanFilename .md' ;
550561 final mdPath = path.join (chaptersDirectory, mdFilename);
551562
563+ print ('=== MD CONVERSION: Writing to $mdPath ===' );
564+
552565 await File (mdPath).writeAsString (mdContent.toString ());
566+
567+ print ('=== MD CONVERSION: Successfully wrote $mdFilename ===' );
568+ }
569+
570+ print ('=== MD CONVERSION: All done ===' );
571+
572+ setState (() {
573+ _transcriptionStatus = 'Markdown conversion complete!' ;
574+ });
575+
576+ } catch (e, stackTrace) {
577+ print ('=== MD CONVERSION ERROR: $e ===' );
578+ print ('=== STACK TRACE: $stackTrace ===' );
579+ if (mounted) {
580+ setState (() {
581+ _transcriptionStatus = 'MD conversion error: $e ' ;
582+ });
553583 }
554- } catch (e) {
555- print ('Error converting VTT to markdown: $e ' );
556584 }
557585 }
558586
0 commit comments