Plugins: - misc_fixes v2.8: Pre-processing, container remux, stream conforming - stream_organizer v4.8: English priority, subtitle extraction, SRT conversion - combined_audio_standardizer v1.13: AAC/Opus encoding, downmix creation - av1_svt_converter v2.22: AV1 video encoding via SVT-AV1 Structure: - Local/ - Plugin .js files (mount in Tdarr) - agent_notes/ - Development documentation - Latest-Reports/ - Error logs for analysis
4.8 KiB
English First Plugin - Code Review
🔴 Critical Issues
1. Missing error handling for shell command (Line 421)
response.preset = `${ccCmd} && ${command}`;
- No handling if ccextractor fails - entire command chain fails
- Should use
;or||for better error handling
2. Input property inconsistency (Lines 17-86)
- Uses
labelproperty which is non-standard - Should use
namefor consistency with other plugins
3. needsPerStreamCodec variable declared but never used (Line 346)
let needsPerStreamCodec = false; // eslint-disable-line @typescript-eslint/no-unused-vars
- Dead code with eslint disable comment
🟡 Medium Issues
4. No emoji standardization
- Uses plain text messages throughout
- Should use ❌ ✅ ℹ️ ⚠️ like other plugins
5. Inconsistent "Yes"/"No" vs boolean (Lines 18-86)
- All inputs use string "Yes"/"No" instead of "true*"/"false"
- Not consistent with other plugins
6. Missing validation for inputs
- No validateInputs function
- Could have invalid dropdown values pass through
7. Long complex conditional (Lines 313-314)
if (!needsReorder && !needsConversion && extractCount === 0 && !ccActuallyExtracted &&
!(ccExtractedFile && inputs.embedExtractedCC === 'Yes')) {
- Hard to read and maintain
8. No minimum/maximum for customLanguageCodes
- Could cause issues with very long lists
- Should cap at reasonable limit (e.g., 20 codes)
🟢 Potential Improvements
9. Add support for multi-language priority
- Currently English-only
- Could support user-defined priority languages
10. Add option to set default audio/subtitle
- Could set disposition:default flag on first English stream
11. Add subtitle format validation before extraction
- Check if subtitle streams are extractable before attempting
12. Improve file existence checking
- Uses both
extractedFiles.has()andfs.existsSync()(Line 272) - Could consolidate logic
13. Add retry logic for file operations
- File extraction could fail silently
- Should verify extracted files exist
14. Add progress/status logging
- Limited feedback during long operations
- Could add more detailed status updates
15. Sanitization could be more robust
const sanitizeForShell = (str) => {
return str.replace(/[\\\"'$`\n\r\t]/g, ...);
};
- Missing some potentially dangerous characters
- Could use shell-escape library
16. Add optional removal of forced subtitles
- Some users may want to remove forced subtitle flag
- Could add as option
17. No version bump needed
- Currently at 3.2
- No critical issues requiring immediate update
📋 Redundancies
18. Multiple subtitle type checks
isTextSubtitle,needsSRTConversion,isProblematicSubtitleoverlap- Could consolidate logic
19. Duplicate file base name calculation
const baseName = buildSafeBasePath(baseFile); // Line 249
const baseName = buildSafeBasePath(baseFile); // Line 297
- Calculated twice in separate blocks
20. Repeated stream filtering
subtitleStreams.some(isClosedCaption) // Line 294
subtitleStreams.some(isProblematicSubtitle) // Line 227
- Could cache results
🔧 Optimizations
21. Use Set for codec arrays
const TEXT_SUBTITLE_CODECS = ['ass', 'ssa', 'webvtt', 'mov_text', 'text', 'subrip'];
- Convert to Set for O(1) lookups
22. Optimize stream partitioning
const partitionStreams = (streams, predicate) => {
return streams.reduce((acc, s) => {
acc[predicate(s) ? 0 : 1].push(s);
return acc;
}, [[], []]);
};
- Single pass instead of forEach
23. Cache English codes validation
- Validated on every plugin run
- Could memoize
🎯 Priority Fixes Table
| Priority | Line(s) | Issue | Fix |
|---|---|---|---|
| 🔴 High | 421 | No error handling for ccextractor | Use ; or add error check |
| 🔴 High | 346 | Dead code | Remove unused variable |
| 🟡 Medium | throughout | No emoji usage | Add ❌ ✅ ℹ️ ⚠️ |
| 🟡 Medium | 18-86 | String Yes/No | Use true*/false format |
| 🟡 Medium | - | No input validation | Add validateInputs function |
| 🟡 Medium | 313-314 | Complex conditional | Extract to function |
| 🟢 Low | 90-92 | Arrays not Sets | Convert to Sets |
| 🟢 Low | 249, 297 | Duplicate calculation | Extract to variable |
| 🟢 Low | - | Add default flag option | New input feature |
| 🟢 Low | - | Multi-language support | Enhancement |
Summary
Total Issues Found: 23
Critical: 2
Medium: 6
Low/Enhancement: 15
Most pressing fixes:
- Add error handling for ccextractor command
- Remove dead code variable
- Add emoji standardization
- Convert Yes/No to true*/false
- Add input validation
- Convert codec arrays to Sets