[Feature] Use subtitle filename, instead of movie title for Opensubtitles search. (#223)

* [Feature] Use subtitle filename, instead of movie title for Opensubtitles search.

* Optimize iteration for first not null value
This commit is contained in:
Jace 2022-12-03 22:48:56 +08:00 committed by GitHub
parent eb90b79bf9
commit 42d1dd9f7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 2 deletions

View File

@ -200,8 +200,12 @@ class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi
it.data?.forEach { item ->
val attr = item.attributes ?: return@forEach
val featureDetails = attr.featDetails
//Use filename as name, if its valid
val filename = attr.files?.firstNotNullOfOrNull { subfile ->
subfile.fileName
}
//Use any valid name/title in hierarchy
val name = featureDetails?.movieName ?: featureDetails?.title
val name = filename ?: featureDetails?.movieName ?: featureDetails?.title
?: featureDetails?.parentTitle ?: attr.release ?: ""
val lang = fixLanguageReverse(attr.language)?: ""
val resEpNum = featureDetails?.episodeNumber ?: query.epNumber
@ -330,4 +334,4 @@ class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi
@JsonProperty("parent_tmdb_id") var parentTmdbId: Int? = null,
@JsonProperty("parent_feature_id") var parentFeatureId: Int? = null
)
}
}