From 42d1dd9f7d2e81a2688f98b249a5b0a291662a7a Mon Sep 17 00:00:00 2001 From: Jace <54625750+Jacekun@users.noreply.github.com> Date: Sat, 3 Dec 2022 22:48:56 +0800 Subject: [PATCH] [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 --- .../syncproviders/providers/OpenSubtitlesApi.kt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt index f22fdd8b..d5d6400c 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/syncproviders/providers/OpenSubtitlesApi.kt @@ -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 ) -} \ No newline at end of file +}