Skip to content

Fix duplicated subtitle issue-- initialize cache directory + local cached subtitles can be manually downloaded as *.srt#13143

Open
TransZAllen wants to merge 2 commits intoTeamNewPipe:devfrom
TransZAllen:duplicated_subtitle_5_on_newest_dev
Open

Fix duplicated subtitle issue-- initialize cache directory + local cached subtitles can be manually downloaded as *.srt#13143
TransZAllen wants to merge 2 commits intoTeamNewPipe:devfrom
TransZAllen:duplicated_subtitle_5_on_newest_dev

Conversation

@TransZAllen
Copy link
Contributor

@TransZAllen TransZAllen commented Jan 30, 2026

What is it?

  • [ √ ] Bugfix (user facing)
  • Feature (user facing) ⚠️ Your PR must target the refactor branch
  • [ √ ] Codebase improvement (dev facing)
  • Meta improvement to the project (dev facing)

Description of the changes in your PR

This PR is a supporting changes.

  1. Initializes cache/subtitle_cache directory;
  2. Ensures locally cached subtitle files can still be manually downloaded as '*.srt'. Before this change, only remote subtitle URL is supported to be manually downloaded.

Relies on the following changes

Here is the main changes:

Before/After Screenshots/Screen Record

This PR just tests manually download '*.srt', with a YouTube video link: https://www.youtube.com/watch?v=b7vmW_5HSpE
SRT subtitle file is downloaded as 'Violent Vincent_ Land Mines _ OFFICIAL MUSIC VIDEO-en-GB.srt',

  • Before:

      double_subtitle/not_fixed$ cat 'Violent Vincent_ Land Mines _ OFFICIAL MUSIC VIDEO-en-GB.srt' | more
      1
      00:00:01,352 --> 00:00:01,852
       Land mines 
       I've left them everywhere 
      
      2
      00:00:01,352 --> 00:00:01,852
       Land mines 
       I've left them everywhere 
      
      3
      00:00:01,852 --> 00:00:02,619
       Land mines 
       I've left them everywhere 
      
      4
      00:00:01,852 --> 00:00:02,619
       Land mines 
       I've left them everywhere  
    
  • After:

    double_subtitle/fixed$ cat 'Violent Vincent_ Land Mines _ OFFICIAL MUSIC VIDEO-en-GB.srt' | more
    1
    00:00:01,352 --> 00:00:01,852
     Land mines 
     I've left them everywhere 
    
    2
    00:00:01,852 --> 00:00:02,619
     Land mines 
     I've left them everywhere
    

Fixes the following issue(s)

Due diligence

  • [ √ ] I read the contribution guidelines.
  • [ √ ] The proposed changes follow the AI policy.
  • [ √ ] I tested the changes using an emulator or a physical device.

…leDeduplicator`

- Configure cache directory as `/storage/emulated/0/Android/data/<package_name>/cache/subtitle_cache`, otherwise it will be 'null', and subtitle deduplication will be skipped.
- Ensures this initialization is called before `checkAndDeduplicate()` in `SubtitleDeduplicator.java` (NewPipeExtractor).
…lication (`SubtitleDeduplicator`)

- Introduce `SubtitleDeduplicator` into NewPipeExtractor; subtitles are now cached locally.
- Add support for `file://` protocol to process local subtitle files (e.g., file:///storage/emulated/0/Android/data/<package_name>/cache/subtitle_cache/<cached_TTML_subtitle_name>) instead of remote URLs.
- Separate handling of local and remote subtitle in `run()` for better clarity.
  Note: After calling `SubtitleDeduplicator.checkAndDeduplicate()`, all YouTube subtitles are local.
- Clarify the early return logic for single-URL subtitle download.
@github-actions github-actions bot added the size/medium PRs with less than 250 changed lines label Jan 30, 2026
@TransZAllen TransZAllen changed the title Open Fix duplicated subtitle issue-- initialize cache directory + local cached subtitles can be manually downloaded as *.srt Fix duplicated subtitle issue-- initialize cache directory + local cached subtitles can be manually downloaded as *.srt Jan 31, 2026
@ShareASmile ShareASmile added bug Issue is related to a bug subtitles Related to displaying, converting or saving subtitles or captions. labels Feb 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue is related to a bug size/medium PRs with less than 250 changed lines subtitles Related to displaying, converting or saving subtitles or captions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Subtitles appear twice sometimes

2 participants