From 520cb0bb43c7298dea4921ca1ba61b8e4d524540 Mon Sep 17 00:00:00 2001 From: Nicolas Pomepuy Date: Thu, 24 Oct 2024 13:08:04 +0200 Subject: [PATCH] Clean obsolete subtitle downloader code --- .../java/org/videolan/vlc/util/TestUtil.kt | 22 ------- .../opensubtitles/IOpenSubtitleService.kt | 14 +---- .../resources/opensubtitles/Models.kt | 63 ------------------- .../opensubtitles/OpenSubtitleRepository.kt | 1 - .../opensubtitles/OpenSubtitleService.kt | 1 - .../videolan/vlc/viewmodels/SubtitlesModel.kt | 1 - .../vlc/viewmodels/SubtitlesModelTest.kt | 2 +- 7 files changed, 2 insertions(+), 102 deletions(-) diff --git a/application/app/src/androidTest/java/org/videolan/vlc/util/TestUtil.kt b/application/app/src/androidTest/java/org/videolan/vlc/util/TestUtil.kt index 6109cb5ea..514ad06de 100644 --- a/application/app/src/androidTest/java/org/videolan/vlc/util/TestUtil.kt +++ b/application/app/src/androidTest/java/org/videolan/vlc/util/TestUtil.kt @@ -25,8 +25,6 @@ import androidx.core.net.toUri import org.videolan.libvlc.interfaces.IMedia import org.videolan.resources.TYPE_LOCAL_FAV import org.videolan.resources.TYPE_NETWORK_FAV -import org.videolan.resources.opensubtitles.OpenSubtitle -import org.videolan.resources.opensubtitles.QueryParameters import org.videolan.vlc.gui.dialogs.State import org.videolan.vlc.gui.dialogs.SubtitleItem @@ -112,24 +110,4 @@ object TestUtil { movieReleaseName: String, zipDownloadLink: String): SubtitleItem = SubtitleItem(idSubtitle, mediaUri, subLanguageID, movieReleaseName, State.Downloading, zipDownloadLink) - fun createDownloadingSubtitleItem( - idSubtitle: String, - mediaPath: String, - subLanguageID: String, - movieReleaseName: String, - zipDownloadLink: String): SubtitleItem = createDownloadingSubtitleItem(idSubtitle, mediaPath.toUri(), subLanguageID, movieReleaseName, zipDownloadLink) - - fun createOpenSubtitle( - idSubtitle: String, - subLanguageID: String, - movieReleaseName: String, - zipDownloadLink: String) = OpenSubtitle( - idSubtitle = idSubtitle, subLanguageID = subLanguageID, movieReleaseName = movieReleaseName, zipDownloadLink = zipDownloadLink, - idMovie = "", idMovieImdb = "", idSubMovieFile = "", idSubtitleFile = "", infoFormat = "", infoOther = "", infoReleaseGroup = "", - userID = "", iSO639 = "", movieFPS = "", languageName = "", subActualCD = "", subSumVotes = "", subAuthorComment = "", subComments = "", - score = 0.0, seriesEpisode = "", seriesIMDBParent = "", seriesSeason = "", subAddDate = "", subAutoTranslation = "", subBad = "", subDownloadLink = "", - subDownloadsCnt = "", subEncoding = "", subFeatured = "", subFileName = "", subForeignPartsOnly = "", subFormat = "", subFromTrusted = "", subHash = "", - subHD = "", subHearingImpaired = "", subLastTS = "", subRating = "", subSize = "", subSumCD = "", subtitlesLink = "", subTranslator = "", subTSGroup = "", - subTSGroupHash = "", movieByteSize = "", movieHash = "", movieTimeMS = "", queryParameters = QueryParameters("", "", ""), queryNumber = "", - userNickName = "", userRank = "", matchedBy = "", movieImdbRating = "", movieKind = "", movieName = "", movieNameEng = "", movieYear = "") } diff --git a/application/resources/src/main/java/org/videolan/resources/opensubtitles/IOpenSubtitleService.kt b/application/resources/src/main/java/org/videolan/resources/opensubtitles/IOpenSubtitleService.kt index d958f4dd7..d1a572fa7 100644 --- a/application/resources/src/main/java/org/videolan/resources/opensubtitles/IOpenSubtitleService.kt +++ b/application/resources/src/main/java/org/videolan/resources/opensubtitles/IOpenSubtitleService.kt @@ -1,22 +1,10 @@ package org.videolan.resources.opensubtitles +import org.videolan.resources.opensubtitles.OpenSubV1 import retrofit2.http.GET -import retrofit2.http.Path import retrofit2.http.Query -//Passing 0 for numbers and "" for strings ignores that parameters interface IOpenSubtitleService { -// @GET("episode-{episode}/imdbid-{imdbId}/moviebytesize-{movieByteSize}/moviehash-{movieHash}/query-{name}/season-{season}/sublanguageid-{subLanguageId}/tag_{tag}") -// suspend fun query( @Path("movieByteSize") movieByteSize: String = "", -// @Path("movieHash") movieHash: String = "", -// @Path("name") name: String = "", -// @Path("imdbId") imdbId: String = "" , -// @Path("tag") tag: String = "", -// @Path("episode") episode: Int = 0, -// @Path("season") season: Int = 0, -// @Path("subLanguageId") languageId: String = ""): List - - @GET("subtitles") suspend fun query( @Query("episode_number") episode: Int? = null, diff --git a/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt b/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt index 2cc604c74..9522cd2f7 100644 --- a/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt +++ b/application/resources/src/main/java/org/videolan/resources/opensubtitles/Models.kt @@ -1,68 +1,5 @@ package org.videolan.resources.opensubtitles import com.squareup.moshi.Json -import com.squareup.moshi.JsonClass - - -data class OpenSubtitle( - @field:Json(name = "MatchedBy") val matchedBy: String, - @field:Json(name = "IDSubMovieFile") val idSubMovieFile: String, - @field:Json(name = "MovieHash") val movieHash: String, - @field:Json(name = "MovieByteSize") val movieByteSize: String, - @field:Json(name = "MovieTimeMS") val movieTimeMS: String, - @field:Json(name = "IDSubtitleFile") val idSubtitleFile: String, - @field:Json(name = "SubFileName") val subFileName: String, - @field:Json(name = "SubActualCD") val subActualCD: String, - @field:Json(name = "SubSize") val subSize: String, - @field:Json(name = "SubHash") val subHash: String, - @field:Json(name = "SubLastTS") val subLastTS: String, - @field:Json(name = "SubTSGroup") val subTSGroup: String, - @field:Json(name = "InfoReleaseGroup") val infoReleaseGroup: String, - @field:Json(name = "InfoFormat") val infoFormat: String, - @field:Json(name = "InfoOther") val infoOther: String, - @field:Json(name = "IDSubtitle") val idSubtitle: String, - @field:Json(name = "UserID") val userID: String, - @field:Json(name = "SubLanguageID") val subLanguageID: String, - @field:Json(name = "SubFormat") val subFormat: String, - @field:Json(name = "SubSumCD") val subSumCD: String, - @field:Json(name = "SubAuthorComment") val subAuthorComment: String, - @field:Json(name = "SubAddDate") val subAddDate: String, - @field:Json(name = "SubBad") val subBad: String, - @field:Json(name = "SubRating") val subRating: String, - @field:Json(name = "SubSumVotes") val subSumVotes: String, - @field:Json(name = "SubDownloadsCnt") val subDownloadsCnt: String, - @field:Json(name = "MovieReleaseName") val movieReleaseName: String, - @field:Json(name = "MovieFPS") val movieFPS: String, - @field:Json(name = "IDMovie") val idMovie: String, - @field:Json(name = "IDMovieImdb") val idMovieImdb: String, - @field:Json(name = "MovieName") val movieName: String, - @field:Json(name = "MovieNameEng") val movieNameEng: Any, - @field:Json(name = "MovieYear") val movieYear: String, - @field:Json(name = "MovieImdbRating") val movieImdbRating: Any, - @field:Json(name = "SubFeatured") val subFeatured: String, - @field:Json(name = "UserNickName") val userNickName: String, - @field:Json(name = "SubTranslator") val subTranslator: String, - @field:Json(name = "ISO639") val iSO639: String, - @field:Json(name = "LanguageName") val languageName: String, - @field:Json(name = "SubComments") val subComments: String, - @field:Json(name = "SubHearingImpaired") val subHearingImpaired: String, - @field:Json(name = "UserRank") val userRank: String, - @field:Json(name = "SeriesSeason") val seriesSeason: String, - @field:Json(name = "SeriesEpisode") val seriesEpisode: String, - @field:Json(name = "MovieKind") val movieKind: String, - @field:Json(name = "SubHD") val subHD: String, - @field:Json(name = "SeriesIMDBParent") val seriesIMDBParent: String, - @field:Json(name = "SubEncoding") val subEncoding: String, - @field:Json(name = "SubAutoTranslation") val subAutoTranslation: String, - @field:Json(name = "SubForeignPartsOnly") val subForeignPartsOnly: String, - @field:Json(name = "SubFromTrusted") val subFromTrusted: String, - @field:Json(name = "QueryParameters") val queryParameters: QueryParameters, - @field:Json(name = "SubTSGroupHash") val subTSGroupHash: String, - @field:Json(name = "SubDownloadLink") val subDownloadLink: String, - @field:Json(name = "ZipDownloadLink") val zipDownloadLink: String, - @field:Json(name = "SubtitlesLink") val subtitlesLink: String, - @field:Json(name = "QueryNumber") val queryNumber: String, - @field:Json(name = "Score") val score: Double -) data class QueryParameters( @field:Json(name = "query") val query: String, diff --git a/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleRepository.kt b/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleRepository.kt index e3467f582..2e1e6fbc5 100644 --- a/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleRepository.kt +++ b/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleRepository.kt @@ -20,7 +20,6 @@ class OpenSubtitleRepository(private val openSubtitleService: IOpenSubtitleServi languageIds?.toSet()?.run { if (contains("") || isEmpty()) setOf("") else this } ?: setOf("") return openSubtitleService.query( -// movieByteSize = movieByteSize.toString(), movieHash = movieHash ?: "", languageId = actualLanguageIds.sorted().joinToString(","), hearingImpaired = if (hearingImpaired) "only" else "include" diff --git a/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleService.kt b/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleService.kt index 07154d4fe..6f0b8c61d 100644 --- a/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleService.kt +++ b/application/resources/src/main/java/org/videolan/resources/opensubtitles/OpenSubtitleService.kt @@ -3,7 +3,6 @@ package org.videolan.resources.opensubtitles import android.util.Log import com.moczul.ok2curl.CurlInterceptor import com.moczul.ok2curl.logger.Logger -import com.squareup.moshi.Moshi import okhttp3.Interceptor import okhttp3.OkHttpClient import okhttp3.Request diff --git a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt index b052f9106..0d0971712 100644 --- a/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt +++ b/application/vlc-android/src/org/videolan/vlc/viewmodels/SubtitlesModel.kt @@ -16,7 +16,6 @@ import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import org.videolan.resources.opensubtitles.Data import org.videolan.resources.opensubtitles.OpenSubV1 -import org.videolan.resources.opensubtitles.OpenSubtitle import org.videolan.resources.opensubtitles.OpenSubtitleClient import org.videolan.resources.opensubtitles.OpenSubtitleRepository import org.videolan.resources.util.NoConnectivityException diff --git a/application/vlc-android/test/org/videolan/vlc/viewmodels/SubtitlesModelTest.kt b/application/vlc-android/test/org/videolan/vlc/viewmodels/SubtitlesModelTest.kt index 6e39661f6..5d0cd61ad 100644 --- a/application/vlc-android/test/org/videolan/vlc/viewmodels/SubtitlesModelTest.kt +++ b/application/vlc-android/test/org/videolan/vlc/viewmodels/SubtitlesModelTest.kt @@ -10,7 +10,7 @@ import junit.framework.TestCase.assertEquals import org.junit.Rule import org.junit.Test import org.junit.rules.TemporaryFolder -import org.videolan.resources.opensubtitles.OpenSubtitleRepository +import main.java.org.videolan.resources.opensubtitles.OpenSubtitleRepository import org.videolan.resources.util.NoConnectivityException import org.videolan.tools.FileUtils import org.videolan.vlc.BaseTest