mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
add imdb functionality for subs
This commit is contained in:
parent
65b5efb848
commit
77688ceb52
2 changed files with 33 additions and 6 deletions
|
@ -113,6 +113,11 @@ android {
|
||||||
checkReleaseBuilds = false
|
checkReleaseBuilds = false
|
||||||
}
|
}
|
||||||
namespace = "com.lagradost.cloudstream3"
|
namespace = "com.lagradost.cloudstream3"
|
||||||
|
packagingOptions {
|
||||||
|
resources {
|
||||||
|
excludes += "META-INF/DEPENDENCIES"
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
|
@ -217,6 +222,9 @@ dependencies {
|
||||||
|
|
||||||
// Library/extensions searching with Levenshtein distance
|
// Library/extensions searching with Levenshtein distance
|
||||||
implementation("me.xdrop:fuzzywuzzy:1.4.0")
|
implementation("me.xdrop:fuzzywuzzy:1.4.0")
|
||||||
|
implementation("com.github.holgerbrandl:themoviedbapi:1.12") {
|
||||||
|
exclude(group = "commons-logging", module = "commons-logging")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.register("androidSourcesJar", Jar::class) {
|
tasks.register("androidSourcesJar", Jar::class) {
|
||||||
|
@ -247,4 +255,4 @@ tasks.withType<DokkaTask>().configureEach {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,6 @@ package com.lagradost.cloudstream3.syncproviders.providers
|
||||||
|
|
||||||
import android.util.Log
|
import android.util.Log
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty
|
import com.fasterxml.jackson.annotation.JsonProperty
|
||||||
import com.google.common.collect.BiMap
|
|
||||||
import com.google.common.collect.HashBiMap
|
|
||||||
import com.lagradost.cloudstream3.*
|
import com.lagradost.cloudstream3.*
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.getKey
|
||||||
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
import com.lagradost.cloudstream3.AcraApplication.Companion.removeKey
|
||||||
|
@ -15,6 +13,8 @@ import com.lagradost.cloudstream3.syncproviders.AuthAPI
|
||||||
import com.lagradost.cloudstream3.syncproviders.InAppAuthAPI
|
import com.lagradost.cloudstream3.syncproviders.InAppAuthAPI
|
||||||
import com.lagradost.cloudstream3.syncproviders.InAppAuthAPIManager
|
import com.lagradost.cloudstream3.syncproviders.InAppAuthAPIManager
|
||||||
import com.lagradost.cloudstream3.utils.AppUtils
|
import com.lagradost.cloudstream3.utils.AppUtils
|
||||||
|
import info.movito.themoviedbapi.TmdbApi
|
||||||
|
|
||||||
|
|
||||||
class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi {
|
||||||
override val idPrefix = "opensubtitles"
|
override val idPrefix = "opensubtitles"
|
||||||
|
@ -163,16 +163,21 @@ class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi
|
||||||
throwIfCantDoRequest()
|
throwIfCantDoRequest()
|
||||||
val fixedLang = fixLanguage(query.lang)
|
val fixedLang = fixLanguage(query.lang)
|
||||||
|
|
||||||
val imdbId = query.imdb ?: 0
|
|
||||||
val queryText = query.query.replace(" ", "+")
|
val queryText = query.query.replace(" ", "+")
|
||||||
val epNum = query.epNumber ?: 0
|
val epNum = query.epNumber ?: 0
|
||||||
val seasonNum = query.seasonNumber ?: 0
|
val seasonNum = query.seasonNumber ?: 0
|
||||||
val yearNum = query.year ?: 0
|
val ans = getImdb(queryText)
|
||||||
|
var imdbId = ""
|
||||||
|
var yearNum = 0
|
||||||
|
if (ans[0] != "" && ans[1] != "" && seasonNum == 0 && epNum == 0) {
|
||||||
|
imdbId = ans[0]
|
||||||
|
yearNum = ans[1].toInt()
|
||||||
|
}
|
||||||
val epQuery = if (epNum > 0) "&episode_number=$epNum" else ""
|
val epQuery = if (epNum > 0) "&episode_number=$epNum" else ""
|
||||||
val seasonQuery = if (seasonNum > 0) "&season_number=$seasonNum" else ""
|
val seasonQuery = if (seasonNum > 0) "&season_number=$seasonNum" else ""
|
||||||
val yearQuery = if (yearNum > 0) "&year=$yearNum" else ""
|
val yearQuery = if (yearNum > 0) "&year=$yearNum" else ""
|
||||||
|
|
||||||
val searchQueryUrl = when (imdbId > 0) {
|
val searchQueryUrl = when (imdbId != "") {
|
||||||
//Use imdb_id to search if its valid
|
//Use imdb_id to search if its valid
|
||||||
true -> "$host/subtitles?imdb_id=$imdbId&languages=${fixedLang}$yearQuery$epQuery$seasonQuery"
|
true -> "$host/subtitles?imdb_id=$imdbId&languages=${fixedLang}$yearQuery$epQuery$seasonQuery"
|
||||||
false -> "$host/subtitles?query=$queryText&languages=${fixedLang}$yearQuery$epQuery$seasonQuery"
|
false -> "$host/subtitles?query=$queryText&languages=${fixedLang}$yearQuery$epQuery$seasonQuery"
|
||||||
|
@ -231,6 +236,20 @@ class OpenSubtitlesApi(index: Int) : InAppAuthAPIManager(index), AbstractSubApi
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getImdb(s: String): Array<String> {
|
||||||
|
val searches = TmdbApi("b2960a64f51310954666c97170072562").search
|
||||||
|
val search = searches.searchMovie(s,0,null,true,0)
|
||||||
|
val movie_id = search.results[0].id
|
||||||
|
val movies = TmdbApi("b2960a64f51310954666c97170072562").movies
|
||||||
|
val movie = movies.getMovie(movie_id, null)
|
||||||
|
if (movie == null) {
|
||||||
|
return arrayOf("", "")
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return arrayOf(movie.imdbID, movie.releaseDate.substring(0,4))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Process data returned from search.
|
Process data returned from search.
|
||||||
Returns string url for the subtitle file.
|
Returns string url for the subtitle file.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue