Skip to content

📝 Add docstrings to feat/import-subtitle-from-stream#222

Merged
mkdir700 merged 1 commit intofeat/import-subtitle-from-streamfrom
coderabbitai/docstrings/629af64
Oct 17, 2025
Merged

📝 Add docstrings to feat/import-subtitle-from-stream#222
mkdir700 merged 1 commit intofeat/import-subtitle-from-streamfrom
coderabbitai/docstrings/629af64

Conversation

@coderabbitai
Copy link
Contributor

@coderabbitai coderabbitai bot commented Oct 17, 2025

Docstrings generation was requested by @mkdir700.

The following files were modified:

  • src/main/ipc.ts
  • src/renderer/src/pages/player/PlayerPage.tsx
  • src/renderer/src/pages/player/components/SubtitleListPanel.tsx
These file types are not supported
  • src/renderer/src/i18n/locales/en-us.json
  • src/renderer/src/i18n/locales/ja-jp.json
  • src/renderer/src/i18n/locales/ru-ru.json
  • src/renderer/src/i18n/locales/zh-cn.json
  • src/renderer/src/i18n/locales/zh-tw.json
ℹ️ Note

CodeRabbit cannot perform edits on its own pull requests yet.

Docstrings generation was requested by @mkdir700.

* #221 (comment)

The following files were modified:

* `src/main/ipc.ts`
* `src/renderer/src/pages/player/PlayerPage.tsx`
* `src/renderer/src/pages/player/components/SubtitleListPanel.tsx`
@coderabbitai coderabbitai bot requested a review from mkdir700 October 17, 2025 01:40
@coderabbitai coderabbitai bot added this to the 1.2.0 milestone Oct 17, 2025
@coderabbitai
Copy link
Contributor Author

coderabbitai bot commented Oct 17, 2025

Important

Review skipped

CodeRabbit bot authored PR detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

@mkdir700 mkdir700 merged commit 0da82d9 into feat/import-subtitle-from-stream Oct 17, 2025
2 checks passed
@mkdir700 mkdir700 deleted the coderabbitai/docstrings/629af64 branch October 17, 2025 01:45
mkdir700 added a commit that referenced this pull request Oct 17, 2025
* feat(media): add subtitle stream handling and extraction

- Added new IPC channels for handling subtitle streams: Media_GetSubtitleStreams and Media_ExtractSubtitle
- Implemented SubtitleExtractorService to manage subtitle extraction
- Updated MediaParserService to include methods for retrieving subtitle stream information using ffprobe
- Integrated subtitle stream handling in ipc.ts with appropriate handlers
- Introduced SubtitleTrackSelector component for UI interaction with subtitle streams

* feat(player): enhance subtitle import with caching

- integrate SubtitleLibraryService to cache parsed subtitles
- add current video context to enable subtitle persistence
- log caching success and handle potential errors gracefully
- ensure subtitles are stored with associated video ID

* 📝 Add docstrings to `feat/import-subtitle-from-stream` (#222)

Docstrings generation was requested by @mkdir700.

* #221 (comment)

The following files were modified:

* `src/main/ipc.ts`
* `src/renderer/src/pages/player/PlayerPage.tsx`
* `src/renderer/src/pages/player/components/SubtitleListPanel.tsx`

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* refactor: make subtitle temp cleanup async

* refactor: replace blocking fs.existsSync with async fs.promises.access in SubtitleExtractorService

* refactor: replace blocking fs.existsSync with async fs.promises in critical paths

- Replace fs.existsSync with fs.promises.access in IPC handler
- Optimize MediaParserService by merging existsSync + statSync into single stat call
- Convert FFmpegService.fastCheckFFmpegExists to async method
- Replace all blocking file checks in async methods across services

This eliminates event loop blocking in hot paths and improves I/O performance.

* fix: add context object to subtitle detection logger for searchability

Add path and videoId to logger.info when no subtitle streams detected,
improving log searchability and debugging capabilities.

* refactor: consolidate path conversion logic to use PathConverter

- Remove duplicate convertFileUrlToLocalPath from MediaParserService
- Remove duplicate convertFileUrlToLocalPath from FFmpegService
- Remove convertFileUrlToLocalPathAsync from ParallelVideoProcessor
- Replace all calls with PathConverter.convertToLocalPath for consistency
- Add proper error handling for path conversion failures
- Remove ~100+ lines of duplicate code

* refactor(MediaParser): fix ffprobe service usage and prevent double settle

- Use this.ffmpegService.getFFprobePath() instead of inline new FFmpegService()
- Add -select_streams 's' to only return subtitle streams for better performance
- Implement settled flag to prevent double settle race conditions
- Change timeout handler to resolve(null) instead of reject for consistency
- Add settled checks in all handlers (timeout/close/error) before resolving/rejecting
- Ensure ffprobe process is killed on timeout with proper logging context

* refactor(player): replace hardcoded Chinese text with i18n in subtitle empty state

- Replace hardcoded Chinese text in SubtitleListPanel empty state options
- Update embedded subtitle option: title, description, and action button
- Update external subtitle option: title and description
- Update AI-generated subtitle option: title, description, and action button
- All i18n keys already exist in language packs (zh-cn, zh-tw, en-us, ja-jp, ru-ru)

* feat(SubtitleExtractor): implement temporary subtitle file cleanup functionality

- Add new IPC channel `subtitle-extractor:cleanup-temp` for cleaning up temporary subtitle files.
- Implement `cleanupTempFiles` method in `SubtitleExtractorService` to remove subtitle files matching the pattern from the system's temporary directory.
- Enhance logging for cleanup operations, including success and error messages.
- Add unit tests for `cleanupTempFiles` to ensure correct functionality and logging behavior.

* docs: update CLAUDE.md with testing and resource management guidelines

- Add important notes on mocking `node:fs` and `node:fs/promises` in the global test setup.
- Include examples for unmocking these modules in test files for real filesystem operations.
- Introduce resource management and cleanup section detailing temporary file cleanup practices.
- Outline best practices for implementing `cleanupTempFiles()` and IPC channel usage for manual cleanup triggers.
- Specify naming conventions for temporary files to facilitate pattern matching and cleanup.

* fix(SubtitleExtractorService): refactor cleanupTempFiles to use async/await

- Update cleanupTempFiles method to be asynchronous, ensuring non-blocking file operations.
- Replace synchronous file reading and deletion with their asynchronous counterparts to prevent event loop blocking.
- Enhance error handling during file deletion and log the number of cleaned files.
- Update related IPC handlers and unit tests to accommodate the async changes, ensuring proper functionality and logging behavior.

* test(FFmpegService): refactor integration tests to use async/await for filesystem checks

- Update FFmpegService integration tests to utilize async/await for filesystem operations, ensuring non-blocking behavior.
- Mock fs.promises.stat to simulate various scenarios, including existing files, non-existent files, and directories.
- Enhance error handling in tests to gracefully manage filesystem errors.
- Ensure all tests correctly await the results of fastCheckFFmpegExists, improving test reliability and performance.

* refactor(SubtitleExtractorService): enhance temporary subtitle filename generation and update unit tests

- Modify the random string generation in generateTempSubtitlePath to ensure it only contains lowercase letters and numbers.
- Update unit tests to improve validation of log messages and regex patterns for subtitle filenames.
- Remove redundant test cases and streamline the cleanupTempFile tests for better clarity and efficiency.

* refactor(ipc): enhance cleanupTemp IPC handler with logging and return count

- Update the cleanupTemp IPC handler to log the number of cleaned temporary subtitle files.
- Refactor the useSubtitleOverlay hook to remove unnecessary memoization and improve clarity by directly using currentSubtitleData.
- Ensure consistent handling of subtitle data across the component, enhancing performance and readability.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
mkdir700 added a commit that referenced this pull request Oct 17, 2025
* feat(media): add subtitle stream handling and extraction

- Added new IPC channels for handling subtitle streams: Media_GetSubtitleStreams and Media_ExtractSubtitle
- Implemented SubtitleExtractorService to manage subtitle extraction
- Updated MediaParserService to include methods for retrieving subtitle stream information using ffprobe
- Integrated subtitle stream handling in ipc.ts with appropriate handlers
- Introduced SubtitleTrackSelector component for UI interaction with subtitle streams

* feat(player): enhance subtitle import with caching

- integrate SubtitleLibraryService to cache parsed subtitles
- add current video context to enable subtitle persistence
- log caching success and handle potential errors gracefully
- ensure subtitles are stored with associated video ID

* 📝 Add docstrings to `feat/import-subtitle-from-stream` (#222)

Docstrings generation was requested by @mkdir700.

* #221 (comment)

The following files were modified:

* `src/main/ipc.ts`
* `src/renderer/src/pages/player/PlayerPage.tsx`
* `src/renderer/src/pages/player/components/SubtitleListPanel.tsx`

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* refactor: make subtitle temp cleanup async

* refactor: replace blocking fs.existsSync with async fs.promises.access in SubtitleExtractorService

* refactor: replace blocking fs.existsSync with async fs.promises in critical paths

- Replace fs.existsSync with fs.promises.access in IPC handler
- Optimize MediaParserService by merging existsSync + statSync into single stat call
- Convert FFmpegService.fastCheckFFmpegExists to async method
- Replace all blocking file checks in async methods across services

This eliminates event loop blocking in hot paths and improves I/O performance.

* fix: add context object to subtitle detection logger for searchability

Add path and videoId to logger.info when no subtitle streams detected,
improving log searchability and debugging capabilities.

* refactor: consolidate path conversion logic to use PathConverter

- Remove duplicate convertFileUrlToLocalPath from MediaParserService
- Remove duplicate convertFileUrlToLocalPath from FFmpegService
- Remove convertFileUrlToLocalPathAsync from ParallelVideoProcessor
- Replace all calls with PathConverter.convertToLocalPath for consistency
- Add proper error handling for path conversion failures
- Remove ~100+ lines of duplicate code

* refactor(MediaParser): fix ffprobe service usage and prevent double settle

- Use this.ffmpegService.getFFprobePath() instead of inline new FFmpegService()
- Add -select_streams 's' to only return subtitle streams for better performance
- Implement settled flag to prevent double settle race conditions
- Change timeout handler to resolve(null) instead of reject for consistency
- Add settled checks in all handlers (timeout/close/error) before resolving/rejecting
- Ensure ffprobe process is killed on timeout with proper logging context

* refactor(player): replace hardcoded Chinese text with i18n in subtitle empty state

- Replace hardcoded Chinese text in SubtitleListPanel empty state options
- Update embedded subtitle option: title, description, and action button
- Update external subtitle option: title and description
- Update AI-generated subtitle option: title, description, and action button
- All i18n keys already exist in language packs (zh-cn, zh-tw, en-us, ja-jp, ru-ru)

* feat(SubtitleExtractor): implement temporary subtitle file cleanup functionality

- Add new IPC channel `subtitle-extractor:cleanup-temp` for cleaning up temporary subtitle files.
- Implement `cleanupTempFiles` method in `SubtitleExtractorService` to remove subtitle files matching the pattern from the system's temporary directory.
- Enhance logging for cleanup operations, including success and error messages.
- Add unit tests for `cleanupTempFiles` to ensure correct functionality and logging behavior.

* docs: update CLAUDE.md with testing and resource management guidelines

- Add important notes on mocking `node:fs` and `node:fs/promises` in the global test setup.
- Include examples for unmocking these modules in test files for real filesystem operations.
- Introduce resource management and cleanup section detailing temporary file cleanup practices.
- Outline best practices for implementing `cleanupTempFiles()` and IPC channel usage for manual cleanup triggers.
- Specify naming conventions for temporary files to facilitate pattern matching and cleanup.

* fix(SubtitleExtractorService): refactor cleanupTempFiles to use async/await

- Update cleanupTempFiles method to be asynchronous, ensuring non-blocking file operations.
- Replace synchronous file reading and deletion with their asynchronous counterparts to prevent event loop blocking.
- Enhance error handling during file deletion and log the number of cleaned files.
- Update related IPC handlers and unit tests to accommodate the async changes, ensuring proper functionality and logging behavior.

* test(FFmpegService): refactor integration tests to use async/await for filesystem checks

- Update FFmpegService integration tests to utilize async/await for filesystem operations, ensuring non-blocking behavior.
- Mock fs.promises.stat to simulate various scenarios, including existing files, non-existent files, and directories.
- Enhance error handling in tests to gracefully manage filesystem errors.
- Ensure all tests correctly await the results of fastCheckFFmpegExists, improving test reliability and performance.

* refactor(SubtitleExtractorService): enhance temporary subtitle filename generation and update unit tests

- Modify the random string generation in generateTempSubtitlePath to ensure it only contains lowercase letters and numbers.
- Update unit tests to improve validation of log messages and regex patterns for subtitle filenames.
- Remove redundant test cases and streamline the cleanupTempFile tests for better clarity and efficiency.

* refactor(ipc): enhance cleanupTemp IPC handler with logging and return count

- Update the cleanupTemp IPC handler to log the number of cleaned temporary subtitle files.
- Refactor the useSubtitleOverlay hook to remove unnecessary memoization and improve clarity by directly using currentSubtitleData.
- Ensure consistent handling of subtitle data across the component, enhancing performance and readability.

---------

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
github-actions bot pushed a commit that referenced this pull request Oct 17, 2025
# [1.2.0](v1.1.1...v1.2.0) (2025-10-17)

### Features

* add subtitle stream handling and extraction([#221](#221)) ([87d11bd](87d11bd)), closes [#222](#222)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant