Skip to content

Commit

Permalink
name sub srt if filename is the same as the language found without th…
Browse files Browse the repository at this point in the history
…e srt extension
  • Loading branch information
courville committed May 9, 2024
1 parent dbaa4c9 commit 794e023
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,12 @@ public List<SubtitleFile> listLocalAndRemotesSubtitles(Uri video, boolean addAll
final String fileExtension = file.getExtension();
if (fileExtension != null) {
String subtitleName = null;
String subtitleFileName = null;
if (SubtitleExtensions.contains(fileExtension.toLowerCase(Locale.US))&&(!fileExtension.toLowerCase(Locale.US).equals("idx") || includeIdx)) {
subList.add(new SubtitleFile(file, getSubLanguageFromSubPath(mContext, file.getUri().getPath())));
subtitleFileName = stripExtensionFromName(getName(file.getName()));
subtitleName = getSubLanguageFromSubPath(mContext, file.getUri().getPath());
if (subtitleFileName.equals(subtitleName)) subtitleName = "SRT";
subList.add(new SubtitleFile(file, subtitleName));
log.trace("listLocalAndRemotesSubtitles: add external " + file.getUri().toString() + " (" + subtitleName +")");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3629,17 +3629,18 @@ public void onSubtitleMetadataUpdated(VideoMetadata vMetadata, int newSubtitleTr
mSubtitleInfoController.addTrack(getText(R.string.unknown_track_name));
}
} else { // name is not null
if (vMetadata.getSubtitleTrack(i).name.equals("SRT") || vMetadata.getSubtitleTrack(i).name.equals("hi")) {
// name is not meaningful, use path
if ( ! vMetadata.getSubtitleTrack(i).isExternal && (vMetadata.getSubtitleTrack(i).name.equals("SRT") || vMetadata.getSubtitleTrack(i).name.equals("hi"))) {
// name is not meaningful
if (lang != null) {
log.debug("onSubtitleMetadataUpdated: set track name to lang=" + lang);
log.debug("onSubtitleMetadataUpdated: int sub set track name to lang=" + lang);
mSubtitleInfoController.addTrack(lang);
} else {
log.debug("onSubtitleMetadataUpdated: lang is null, set track name to name=" + vMetadata.getSubtitleTrack(i).name);
log.debug("onSubtitleMetadataUpdated: int sub lang is null, set track name to name=" + vMetadata.getSubtitleTrack(i).name);
mSubtitleInfoController.addTrack(replaceLanguageCodeInString(mContext, vMetadata.getSubtitleTrack(i).name));
}
} else { // name can be meaningful add it only if not external
if (lang != null) {
// if ext sub and name is SRT it means that the sub filename is the same as the language reported thus we can use SRT without ambiguity
if (! vMetadata.getSubtitleTrack(i).name.equalsIgnoreCase("srt") && lang != null) {
if (vMetadata.getSubtitleTrack(i).isExternal) {
log.debug("onSubtitleMetadataUpdated: ext sub set track name to lang=" + lang);
mSubtitleInfoController.addTrack(lang);
Expand Down

0 comments on commit 794e023

Please sign in to comment.