Compare commits
9 Commits
528e74fda4
...
a505315781
Author | SHA1 | Date | |
---|---|---|---|
a505315781 | |||
d76538cf28 | |||
309a991007 | |||
0340c83b47 | |||
9dfd2cf70b | |||
26d2da923b | |||
c66c725ee3 | |||
44f99295e9 | |||
d417181b70 |
@ -11,7 +11,7 @@ android {
|
|||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 4200 //00.04.200
|
versionCode 4200 //00.04.200
|
||||||
versionName "0.4.2"
|
versionName "0.5.0-alpha1"
|
||||||
|
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
resValue "string", "build_time", buildTime()
|
resValue "string", "build_time", buildTime()
|
||||||
@ -46,7 +46,7 @@ dependencies {
|
|||||||
|
|
||||||
implementation 'androidx.core:core-ktx:1.6.0'
|
implementation 'androidx.core:core-ktx:1.6.0'
|
||||||
implementation 'androidx.appcompat:appcompat:1.3.1'
|
implementation 'androidx.appcompat:appcompat:1.3.1'
|
||||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
|
||||||
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
|
||||||
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
|
||||||
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
|
implementation 'androidx.security:security-crypto:1.1.0-alpha03'
|
||||||
|
@ -49,7 +49,9 @@ object AoDParser {
|
|||||||
private var loginSuccess = false
|
private var loginSuccess = false
|
||||||
|
|
||||||
private val mediaList = arrayListOf<Media>() // actual media (data)
|
private val mediaList = arrayListOf<Media>() // actual media (data)
|
||||||
val itemMediaList = arrayListOf<ItemMedia>() // gui media
|
|
||||||
|
// gui media
|
||||||
|
val guiMediaList = arrayListOf<ItemMedia>()
|
||||||
val highlightsList = arrayListOf<ItemMedia>()
|
val highlightsList = arrayListOf<ItemMedia>()
|
||||||
val newEpisodesList = arrayListOf<ItemMedia>()
|
val newEpisodesList = arrayListOf<ItemMedia>()
|
||||||
val newSimulcastsList = arrayListOf<ItemMedia>()
|
val newSimulcastsList = arrayListOf<ItemMedia>()
|
||||||
@ -110,8 +112,8 @@ object AoDParser {
|
|||||||
* get a media by it's ID (int)
|
* get a media by it's ID (int)
|
||||||
* @return Media
|
* @return Media
|
||||||
*/
|
*/
|
||||||
suspend fun getMediaById(mediaId: Int): Media {
|
suspend fun getMediaById(aodId: Int): Media {
|
||||||
val media = mediaList.first { it.id == mediaId }
|
val media = mediaList.first { it.id == aodId }
|
||||||
|
|
||||||
if (media.episodes.isEmpty()) {
|
if (media.episodes.isEmpty()) {
|
||||||
loadStreams(media).join()
|
loadStreams(media).join()
|
||||||
@ -180,24 +182,39 @@ object AoDParser {
|
|||||||
val resAnimes = Jsoup.connect(baseUrl + libraryPath).get()
|
val resAnimes = Jsoup.connect(baseUrl + libraryPath).get()
|
||||||
//println(resAnimes)
|
//println(resAnimes)
|
||||||
|
|
||||||
itemMediaList.clear()
|
guiMediaList.clear()
|
||||||
mediaList.clear()
|
mediaList.clear()
|
||||||
resAnimes.select("div.animebox").forEach {
|
val animes = resAnimes.select("div.animebox")
|
||||||
val type = if (it.select("p.animebox-link").select("a").text().lowercase(Locale.ROOT) == "zur serie") {
|
|
||||||
MediaType.TVSHOW
|
|
||||||
} else {
|
|
||||||
MediaType.MOVIE
|
|
||||||
}
|
|
||||||
val mediaTitle = it.select("h3.animebox-title").text()
|
|
||||||
val mediaLink = it.select("p.animebox-link").select("a").attr("href")
|
|
||||||
val mediaImage = it.select("p.animebox-image").select("img").attr("src")
|
|
||||||
val mediaShortText = it.select("p.animebox-shorttext").text()
|
|
||||||
val mediaId = mediaLink.substringAfterLast("/").toInt()
|
|
||||||
|
|
||||||
itemMediaList.add(ItemMedia(mediaId, mediaTitle, mediaImage))
|
guiMediaList.addAll(
|
||||||
mediaList.add(Media(mediaId, mediaLink, type).apply {
|
animes.map {
|
||||||
info.title = mediaTitle
|
ItemMedia(
|
||||||
info.posterUrl = mediaImage
|
id = it.select("p.animebox-link").select("a")
|
||||||
|
.attr("href").substringAfterLast("/").toInt(),
|
||||||
|
title = it.select("h3.animebox-title").text(),
|
||||||
|
posterUrl = it.select("p.animebox-image").select("img")
|
||||||
|
.attr("src")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// TODO legacy
|
||||||
|
resAnimes.select("div.animebox").forEach {
|
||||||
|
val id = it.select("p.animebox-link").select("a").attr("href")
|
||||||
|
.substringAfterLast("/").toInt()
|
||||||
|
val title = it.select("h3.animebox-title").text()
|
||||||
|
val image = it.select("p.animebox-image").select("img").attr("src")
|
||||||
|
val link = it.select("p.animebox-link").select("a").attr("href")
|
||||||
|
val type = when (it.select("p.animebox-link").select("a").text().lowercase(Locale.ROOT)) {
|
||||||
|
"zur serie" -> MediaType.TVSHOW
|
||||||
|
"zum film" -> MediaType.MOVIE
|
||||||
|
else -> MediaType.OTHER
|
||||||
|
}
|
||||||
|
val mediaShortText = it.select("p.animebox-shorttext").text()
|
||||||
|
|
||||||
|
mediaList.add(Media(id, link, type).apply {
|
||||||
|
info.title = title
|
||||||
|
info.posterUrl = image
|
||||||
info.shortDesc = mediaShortText
|
info.shortDesc = mediaShortText
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -327,23 +344,16 @@ object AoDParser {
|
|||||||
}.awaitAll()
|
}.awaitAll()
|
||||||
|
|
||||||
playlists.forEach { aod ->
|
playlists.forEach { aod ->
|
||||||
// TODO improve language handling
|
aod.list.forEach { ep ->
|
||||||
val locale = when (aod.extLanguage) {
|
|
||||||
"ger" -> Locale.GERMAN
|
|
||||||
"jap" -> Locale.JAPANESE
|
|
||||||
else -> Locale.ROOT
|
|
||||||
}
|
|
||||||
|
|
||||||
aod.playlist.forEach { ep ->
|
|
||||||
try {
|
try {
|
||||||
if (media.hasEpisode(ep.mediaid)) {
|
if (media.hasEpisode(ep.mediaid)) {
|
||||||
media.getEpisodeById(ep.mediaid).streams.add(
|
media.getEpisodeById(ep.mediaid).streams.add(
|
||||||
Stream(ep.sources.first().file, locale)
|
Stream(ep.sources.first().file, aod.language)
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
media.episodes.add(Episode(
|
media.episodes.add(Episode(
|
||||||
id = ep.mediaid,
|
id = ep.mediaid,
|
||||||
streams = mutableListOf(Stream(ep.sources.first().file, locale)),
|
streams = mutableListOf(Stream(ep.sources.first().file, aod.language)),
|
||||||
posterUrl = ep.image,
|
posterUrl = ep.image,
|
||||||
title = ep.title,
|
title = ep.title,
|
||||||
description = ep.description,
|
description = ep.description,
|
||||||
@ -410,9 +420,9 @@ object AoDParser {
|
|||||||
/**
|
/**
|
||||||
* don't use Gson().fromJson() as we don't have any control over the api and it may change
|
* don't use Gson().fromJson() as we don't have any control over the api and it may change
|
||||||
*/
|
*/
|
||||||
private fun parsePlaylistAsync(playlistPath: String, language: String): Deferred<AoDObject> {
|
private fun parsePlaylistAsync(playlistPath: String, language: String): Deferred<AoDPlaylist> {
|
||||||
if (playlistPath == "[]") {
|
if (playlistPath == "[]") {
|
||||||
return CompletableDeferred(AoDObject(listOf(), language))
|
return CompletableDeferred(AoDPlaylist(listOf(), Locale.ROOT))
|
||||||
}
|
}
|
||||||
|
|
||||||
return CoroutineScope(Dispatchers.IO).async(Dispatchers.IO) {
|
return CoroutineScope(Dispatchers.IO).async(Dispatchers.IO) {
|
||||||
@ -435,7 +445,7 @@ object AoDParser {
|
|||||||
|
|
||||||
//Gson().fromJson(res.body(), AoDObject::class.java)
|
//Gson().fromJson(res.body(), AoDObject::class.java)
|
||||||
|
|
||||||
return@async AoDObject(JsonParser.parseString(res.body()).asJsonObject
|
return@async AoDPlaylist(JsonParser.parseString(res.body()).asJsonObject
|
||||||
.get("playlist").asJsonArray.map {
|
.get("playlist").asJsonArray.map {
|
||||||
Playlist(
|
Playlist(
|
||||||
sources = it.asJsonObject.get("sources").asJsonArray.map { source ->
|
sources = it.asJsonObject.get("sources").asJsonArray.map { source ->
|
||||||
@ -447,7 +457,12 @@ object AoDParser {
|
|||||||
mediaid = it.asJsonObject.get("mediaid").asInt
|
mediaid = it.asJsonObject.get("mediaid").asInt
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
language
|
// TODO improve language handling (via display language etc.)
|
||||||
|
language = when (language) {
|
||||||
|
"ger" -> Locale.GERMAN
|
||||||
|
"jap" -> Locale.JAPANESE
|
||||||
|
else -> Locale.ROOT
|
||||||
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,7 @@ import org.mosad.teapod.ui.activity.onboarding.OnboardingActivity
|
|||||||
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
import org.mosad.teapod.ui.activity.player.PlayerActivity
|
||||||
import org.mosad.teapod.ui.components.LoginDialog
|
import org.mosad.teapod.ui.components.LoginDialog
|
||||||
import org.mosad.teapod.util.DataTypes
|
import org.mosad.teapod.util.DataTypes
|
||||||
|
import org.mosad.teapod.util.MetaDBController
|
||||||
import org.mosad.teapod.util.StorageController
|
import org.mosad.teapod.util.StorageController
|
||||||
import org.mosad.teapod.util.exitAndRemoveTask
|
import org.mosad.teapod.util.exitAndRemoveTask
|
||||||
import java.net.SocketTimeoutException
|
import java.net.SocketTimeoutException
|
||||||
@ -137,8 +138,12 @@ class MainActivity : AppCompatActivity(), NavigationBarView.OnItemSelectedListen
|
|||||||
*/
|
*/
|
||||||
private fun load() {
|
private fun load() {
|
||||||
val time = measureTimeMillis {
|
val time = measureTimeMillis {
|
||||||
|
// start the initial loading
|
||||||
val loadingJob = CoroutineScope(Dispatchers.IO + CoroutineName("InitialLoadingScope"))
|
val loadingJob = CoroutineScope(Dispatchers.IO + CoroutineName("InitialLoadingScope"))
|
||||||
.async { AoDParser.initialLoading() } // start the initial loading
|
.async {
|
||||||
|
launch { AoDParser.initialLoading() }
|
||||||
|
launch { MetaDBController.list() }
|
||||||
|
}
|
||||||
|
|
||||||
// load all saved stuff here
|
// load all saved stuff here
|
||||||
Preferences.load(this)
|
Preferences.load(this)
|
||||||
|
@ -120,24 +120,24 @@ class HomeFragment : Fragment() {
|
|||||||
activity?.showFragment(MediaFragment(highlightMedia.id))
|
activity?.showFragment(MediaFragment(highlightMedia.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
adapterMyList.onItemClick = { mediaId, _ ->
|
adapterMyList.onItemClick = { id, _ ->
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
adapterNewEpisodes.onItemClick = { mediaId, _ ->
|
adapterNewEpisodes.onItemClick = { id, _ ->
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
adapterNewSimulcasts.onItemClick = { mediaId, _ ->
|
adapterNewSimulcasts.onItemClick = { id, _ ->
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
adapterNewTitles.onItemClick = { mediaId, _ ->
|
adapterNewTitles.onItemClick = { id, _ ->
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
adapterTopTen.onItemClick = { mediaId, _ ->
|
adapterTopTen.onItemClick = { id, _ ->
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(id))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ class HomeFragment : Fragment() {
|
|||||||
|
|
||||||
private fun mapMyListToItemMedia(): List<ItemMedia> {
|
private fun mapMyListToItemMedia(): List<ItemMedia> {
|
||||||
return StorageController.myList.mapNotNull { elementId ->
|
return StorageController.myList.mapNotNull { elementId ->
|
||||||
AoDParser.itemMediaList.firstOrNull { it.id == elementId }.also {
|
AoDParser.guiMediaList.firstOrNull { it.id == elementId }.also {
|
||||||
// it the my list entry wasn't found in itemMediaList Log it
|
// it the my list entry wasn't found in itemMediaList Log it
|
||||||
if (it == null) {
|
if (it == null) {
|
||||||
Log.w(javaClass.name, "The element with the id $elementId was not found.")
|
Log.w(javaClass.name, "The element with the id $elementId was not found.")
|
||||||
|
@ -30,7 +30,7 @@ class LibraryFragment : Fragment() {
|
|||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
// create and set the adapter, needs context
|
// create and set the adapter, needs context
|
||||||
context?.let {
|
context?.let {
|
||||||
adapter = MediaItemAdapter(AoDParser.itemMediaList)
|
adapter = MediaItemAdapter(AoDParser.guiMediaList)
|
||||||
adapter.onItemClick = { mediaId, _ ->
|
adapter.onItemClick = { mediaId, _ ->
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(mediaId))
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,8 @@ import org.mosad.teapod.ui.activity.main.viewmodel.MediaFragmentViewModel
|
|||||||
import org.mosad.teapod.util.DataTypes.MediaType
|
import org.mosad.teapod.util.DataTypes.MediaType
|
||||||
import org.mosad.teapod.util.Episode
|
import org.mosad.teapod.util.Episode
|
||||||
import org.mosad.teapod.util.StorageController
|
import org.mosad.teapod.util.StorageController
|
||||||
|
import org.mosad.teapod.util.tmdb.TMDBMovie
|
||||||
|
import org.mosad.teapod.util.tmdb.TMDBApiController
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The media detail fragment.
|
* The media detail fragment.
|
||||||
@ -62,7 +64,6 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
|
|||||||
}
|
}
|
||||||
}.attach()
|
}.attach()
|
||||||
|
|
||||||
|
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
model.load(mediaId) // load the streams and tmdb for the selected media
|
model.load(mediaId) // load the streams and tmdb for the selected media
|
||||||
|
|
||||||
@ -85,21 +86,25 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
|
|||||||
*/
|
*/
|
||||||
private fun updateGUI() = with(model) {
|
private fun updateGUI() = with(model) {
|
||||||
// generic gui
|
// generic gui
|
||||||
val backdropUrl = if (tmdb.backdropUrl.isNotEmpty()) tmdb.backdropUrl else media.info.posterUrl
|
val backdropUrl = tmdbResult?.backdropPath?.let { TMDBApiController.imageUrl + it }
|
||||||
val posterUrl = if (tmdb.posterUrl.isNotEmpty()) tmdb.posterUrl else media.info.posterUrl
|
?: media.info.posterUrl
|
||||||
|
val posterUrl = tmdbResult?.posterPath?.let { TMDBApiController.imageUrl + it }
|
||||||
|
?: media.info.posterUrl
|
||||||
|
|
||||||
|
// load poster and backdrop
|
||||||
|
Glide.with(requireContext()).load(posterUrl)
|
||||||
|
.into(binding.imagePoster)
|
||||||
Glide.with(requireContext()).load(backdropUrl)
|
Glide.with(requireContext()).load(backdropUrl)
|
||||||
.apply(RequestOptions.placeholderOf(ColorDrawable(Color.DKGRAY)))
|
.apply(RequestOptions.placeholderOf(ColorDrawable(Color.DKGRAY)))
|
||||||
.apply(RequestOptions.bitmapTransform(BlurTransformation(20, 3)))
|
.apply(RequestOptions.bitmapTransform(BlurTransformation(20, 3)))
|
||||||
.into(binding.imageBackdrop)
|
.into(binding.imageBackdrop)
|
||||||
|
|
||||||
Glide.with(requireContext()).load(posterUrl)
|
|
||||||
.into(binding.imagePoster)
|
|
||||||
|
|
||||||
binding.textTitle.text = media.info.title
|
binding.textTitle.text = media.info.title
|
||||||
binding.textYear.text = media.info.year.toString()
|
binding.textYear.text = media.info.year.toString()
|
||||||
binding.textAge.text = media.info.age.toString()
|
binding.textAge.text = media.info.age.toString()
|
||||||
binding.textOverview.text = media.info.shortDesc
|
binding.textOverview.text = media.info.shortDesc
|
||||||
|
|
||||||
|
// set "my list" indicator
|
||||||
if (StorageController.myList.contains(media.id)) {
|
if (StorageController.myList.contains(media.id)) {
|
||||||
Glide.with(requireContext()).load(R.drawable.ic_baseline_check_24).into(binding.imageMyListAction)
|
Glide.with(requireContext()).load(R.drawable.ic_baseline_check_24).into(binding.imageMyListAction)
|
||||||
} else {
|
} else {
|
||||||
@ -133,12 +138,13 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
|
|||||||
fragments.add(MediaFragmentEpisodes())
|
fragments.add(MediaFragmentEpisodes())
|
||||||
pagerAdapter.notifyDataSetChanged()
|
pagerAdapter.notifyDataSetChanged()
|
||||||
} else if (media.type == MediaType.MOVIE) {
|
} else if (media.type == MediaType.MOVIE) {
|
||||||
|
val tmdbMovie = (tmdbResult as TMDBMovie?)
|
||||||
|
|
||||||
if (tmdb.runtime > 0) {
|
if (tmdbMovie?.runtime != null) {
|
||||||
binding.textEpisodesOrRuntime.text = resources.getQuantityString(
|
binding.textEpisodesOrRuntime.text = resources.getQuantityString(
|
||||||
R.plurals.text_runtime,
|
R.plurals.text_runtime,
|
||||||
tmdb.runtime,
|
tmdbMovie.runtime,
|
||||||
tmdb.runtime
|
tmdbMovie.runtime
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
binding.textEpisodesOrRuntime.visibility = View.GONE
|
binding.textEpisodesOrRuntime.visibility = View.GONE
|
||||||
@ -165,7 +171,7 @@ class MediaFragment(private val mediaId: Int) : Fragment() {
|
|||||||
when (media.type) {
|
when (media.type) {
|
||||||
MediaType.MOVIE -> playEpisode(media.episodes.first())
|
MediaType.MOVIE -> playEpisode(media.episodes.first())
|
||||||
MediaType.TVSHOW -> playEpisode(nextEpisode)
|
MediaType.TVSHOW -> playEpisode(nextEpisode)
|
||||||
else -> Log.e(javaClass.name, "Wrong Type: $media.type")
|
else -> Log.e(javaClass.name, "Wrong Type: ${media.type}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ class MediaFragmentEpisodes : Fragment() {
|
|||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
adapterRecEpisodes = EpisodeItemAdapter(model.media.episodes)
|
adapterRecEpisodes = EpisodeItemAdapter(model.media.episodes, model.tmdbTVSeason?.episodes)
|
||||||
binding.recyclerEpisodes.adapter = adapterRecEpisodes
|
binding.recyclerEpisodes.adapter = adapterRecEpisodes
|
||||||
|
|
||||||
// set onItemClick only in adapter is initialized
|
// set onItemClick only in adapter is initialized
|
||||||
|
@ -30,7 +30,7 @@ class SearchFragment : Fragment() {
|
|||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
// create and set the adapter, needs context
|
// create and set the adapter, needs context
|
||||||
context?.let {
|
context?.let {
|
||||||
adapter = MediaItemAdapter(AoDParser.itemMediaList)
|
adapter = MediaItemAdapter(AoDParser.guiMediaList)
|
||||||
adapter!!.onItemClick = { mediaId, _ ->
|
adapter!!.onItemClick = { mediaId, _ ->
|
||||||
binding.searchText.clearFocus()
|
binding.searchText.clearFocus()
|
||||||
activity?.showFragment(MediaFragment(mediaId))
|
activity?.showFragment(MediaFragment(mediaId))
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package org.mosad.teapod.ui.activity.main.viewmodel
|
package org.mosad.teapod.ui.activity.main.viewmodel
|
||||||
|
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
|
import android.util.Log
|
||||||
import androidx.lifecycle.AndroidViewModel
|
import androidx.lifecycle.AndroidViewModel
|
||||||
import org.mosad.teapod.parser.AoDParser
|
import org.mosad.teapod.parser.AoDParser
|
||||||
import org.mosad.teapod.util.*
|
import org.mosad.teapod.util.*
|
||||||
import org.mosad.teapod.util.DataTypes.MediaType
|
import org.mosad.teapod.util.DataTypes.MediaType
|
||||||
|
import org.mosad.teapod.util.tmdb.TMDBApiController
|
||||||
|
import org.mosad.teapod.util.tmdb.TMDBResult
|
||||||
|
import org.mosad.teapod.util.tmdb.TMDBTVSeason
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* handle media, next ep and tmdb
|
* handle media, next ep and tmdb
|
||||||
|
* TODO this lives in activity, is this correct?
|
||||||
*/
|
*/
|
||||||
class MediaFragmentViewModel(application: Application) : AndroidViewModel(application) {
|
class MediaFragmentViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
|
|
||||||
@ -15,22 +20,55 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
|||||||
internal set
|
internal set
|
||||||
var nextEpisode = Episode()
|
var nextEpisode = Episode()
|
||||||
internal set
|
internal set
|
||||||
var tmdb = TMDBResponse()
|
var tmdbResult: TMDBResult? = null // TODO rename
|
||||||
|
internal set
|
||||||
|
var tmdbTVSeason: TMDBTVSeason? =null
|
||||||
|
internal set
|
||||||
|
var mediaMeta: Meta? = null
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set media, tmdb and nextEpisode
|
* set media, tmdb and nextEpisode
|
||||||
|
* TODO run aod and tmdb load parallel
|
||||||
*/
|
*/
|
||||||
suspend fun load(mediaId: Int) {
|
suspend fun load(mediaId: Int) {
|
||||||
|
val tmdbApiController = TMDBApiController()
|
||||||
media = AoDParser.getMediaById(mediaId)
|
media = AoDParser.getMediaById(mediaId)
|
||||||
tmdb = TMDBApiController().search(media.info.title, media.type)
|
|
||||||
|
// check if metaDB knows the title
|
||||||
|
val tmdbId: Int = if (MetaDBController.mediaList.media.contains(media.id)) {
|
||||||
|
// load media info from metaDB
|
||||||
|
val metaDB = MetaDBController()
|
||||||
|
mediaMeta = when (media.type) {
|
||||||
|
MediaType.MOVIE -> metaDB.getMovieMetadata(media.id)
|
||||||
|
MediaType.TVSHOW -> metaDB.getTVShowMetadata(media.id)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
|
||||||
|
mediaMeta?.tmdbId ?: -1
|
||||||
|
} else {
|
||||||
|
// use tmdb search to get media info
|
||||||
|
mediaMeta = null // set mediaMeta to null, if metaDB doesn't know the media
|
||||||
|
tmdbApiController.search(stripTitleInfo(media.info.title), media.type)
|
||||||
|
}
|
||||||
|
|
||||||
|
tmdbResult = when (media.type) {
|
||||||
|
MediaType.MOVIE -> tmdbApiController.getMovieDetails(tmdbId)
|
||||||
|
MediaType.TVSHOW -> tmdbApiController.getTVShowDetails(tmdbId)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
println(tmdbResult) // TODO
|
||||||
|
|
||||||
|
// get season info, if metaDB knows the tv show
|
||||||
|
tmdbTVSeason = if (media.type == MediaType.TVSHOW && mediaMeta != null) {
|
||||||
|
val tvShowMeta = mediaMeta as TVShowMeta
|
||||||
|
tmdbApiController.getTVSeasonDetails(tvShowMeta.tmdbId, tvShowMeta.tmdbSeasonNumber)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
|
||||||
if (media.type == MediaType.TVSHOW) {
|
if (media.type == MediaType.TVSHOW) {
|
||||||
nextEpisode = if (media.episodes.firstOrNull{ !it.watched } != null) {
|
nextEpisode = media.episodes.firstOrNull{ !it.watched } ?: media.episodes.first()
|
||||||
media.episodes.first{ !it.watched }
|
|
||||||
} else {
|
|
||||||
media.episodes.first()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,4 +83,30 @@ class MediaFragmentViewModel(application: Application) : AndroidViewModel(applic
|
|||||||
?: media.episodes.first()
|
?: media.episodes.first()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// remove unneeded info from the media title before searching
|
||||||
|
private fun stripTitleInfo(title: String): String {
|
||||||
|
return title.replace("(Sub)", "")
|
||||||
|
.replace(Regex("-?\\s?[0-9]+.\\s?(Staffel|Season)"), "")
|
||||||
|
.replace(Regex("(Staffel|Season)\\s?[0-9]+"), "")
|
||||||
|
.trim()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** guess Season from title
|
||||||
|
* if the title ends with a number, that could be the season
|
||||||
|
* if the title ends with Regex("-?\\s?[0-9]+.\\s?(Staffel|Season)") or
|
||||||
|
* Regex("(Staffel|Season)\\s?[0-9]+"), that is the season information
|
||||||
|
*/
|
||||||
|
private fun guessSeasonFromTitle(title: String): Int {
|
||||||
|
val helpTitle = title.replace("(Sub)", "").trim()
|
||||||
|
Log.d("test", "helpTitle: $helpTitle")
|
||||||
|
|
||||||
|
return if (helpTitle.last().isDigit()) {
|
||||||
|
helpTitle.last().digitToInt()
|
||||||
|
} else {
|
||||||
|
Regex("([0-9]+.\\s?(Staffel|Season))|((Staffel|Season)\\s?[0-9]+)")
|
||||||
|
.find(helpTitle)
|
||||||
|
?.value?.filter { it.isDigit() }?.toInt() ?: 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -32,10 +32,7 @@ import org.mosad.teapod.R
|
|||||||
import org.mosad.teapod.preferences.Preferences
|
import org.mosad.teapod.preferences.Preferences
|
||||||
import org.mosad.teapod.ui.components.EpisodesListPlayer
|
import org.mosad.teapod.ui.components.EpisodesListPlayer
|
||||||
import org.mosad.teapod.ui.components.LanguageSettingsPlayer
|
import org.mosad.teapod.ui.components.LanguageSettingsPlayer
|
||||||
import org.mosad.teapod.util.DataTypes
|
import org.mosad.teapod.util.*
|
||||||
import org.mosad.teapod.util.hideBars
|
|
||||||
import org.mosad.teapod.util.isInPiPMode
|
|
||||||
import org.mosad.teapod.util.navToLauncherTask
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import kotlin.concurrent.scheduleAtFixedRate
|
import kotlin.concurrent.scheduleAtFixedRate
|
||||||
@ -226,7 +223,10 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
// when the player controls get hidden, hide the bars too
|
// when the player controls get hidden, hide the bars too
|
||||||
video_view.setControllerVisibilityListener {
|
video_view.setControllerVisibilityListener {
|
||||||
when (it) {
|
when (it) {
|
||||||
View.GONE -> hideBars()
|
View.GONE -> {
|
||||||
|
hideBars()
|
||||||
|
// TODO also hide the skip op button
|
||||||
|
}
|
||||||
View.VISIBLE -> updateControls()
|
View.VISIBLE -> updateControls()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -244,6 +244,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
rwd_10.setOnButtonClickListener { rewind() }
|
rwd_10.setOnButtonClickListener { rewind() }
|
||||||
ffwd_10.setOnButtonClickListener { fastForward() }
|
ffwd_10.setOnButtonClickListener { fastForward() }
|
||||||
button_next_ep.setOnClickListener { playNextEpisode() }
|
button_next_ep.setOnClickListener { playNextEpisode() }
|
||||||
|
button_skip_op.setOnClickListener { skipOpening() }
|
||||||
button_language.setOnClickListener { showLanguageSettings() }
|
button_language.setOnClickListener { showLanguageSettings() }
|
||||||
button_episodes.setOnClickListener { showEpisodesList() }
|
button_episodes.setOnClickListener { showEpisodesList() }
|
||||||
button_next_ep_c.setOnClickListener { playNextEpisode() }
|
button_next_ep_c.setOnClickListener { playNextEpisode() }
|
||||||
@ -262,16 +263,20 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
timerUpdates = Timer().scheduleAtFixedRate(0, 500) {
|
timerUpdates = Timer().scheduleAtFixedRate(0, 500) {
|
||||||
lifecycleScope.launch {
|
lifecycleScope.launch {
|
||||||
|
val currentPosition = model.player.currentPosition
|
||||||
val btnNextEpIsVisible = button_next_ep.isVisible
|
val btnNextEpIsVisible = button_next_ep.isVisible
|
||||||
val controlsVisible = controller.isVisible
|
val controlsVisible = controller.isVisible
|
||||||
|
|
||||||
|
// make sure remaining time is > 0
|
||||||
if (model.player.duration > 0) {
|
if (model.player.duration > 0) {
|
||||||
remainingTime = model.player.duration - model.player.currentPosition
|
remainingTime = model.player.duration - currentPosition
|
||||||
remainingTime = if (remainingTime < 0) 0 else remainingTime
|
remainingTime = if (remainingTime < 0) 0 else remainingTime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO add metaDB ending_start support
|
||||||
|
// if remaining time < 20 sec, a next ep is set, autoplay is enabled and not in pip:
|
||||||
|
// show next ep button
|
||||||
if (remainingTime in 1..20000) {
|
if (remainingTime in 1..20000) {
|
||||||
// if the next ep button is not visible, make it visible. Don't show in pip mode
|
|
||||||
if (!btnNextEpIsVisible && model.nextEpisode != null && Preferences.autoplay && !isInPiPMode()) {
|
if (!btnNextEpIsVisible && model.nextEpisode != null && Preferences.autoplay && !isInPiPMode()) {
|
||||||
showButtonNextEp()
|
showButtonNextEp()
|
||||||
}
|
}
|
||||||
@ -279,6 +284,19 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
hideButtonNextEp()
|
hideButtonNextEp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if meta data is present and opening_start & opening_duration are valid, show skip opening
|
||||||
|
model.currentEpisodeMeta?.let {
|
||||||
|
if (it.openingDuration > 0 &&
|
||||||
|
currentPosition in it.openingStart..(it.openingStart + 10000) &&
|
||||||
|
!button_skip_op.isVisible
|
||||||
|
) {
|
||||||
|
showButtonSkipOp()
|
||||||
|
} else if (button_skip_op.isVisible && currentPosition !in it.openingStart..(it.openingStart + 10000)) {
|
||||||
|
// the button should only be visible, if currentEpisodeMeta != null
|
||||||
|
hideButtonSkipOp()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if controls are visible, update them
|
// if controls are visible, update them
|
||||||
if (controlsVisible) {
|
if (controlsVisible) {
|
||||||
updateControls()
|
updateControls()
|
||||||
@ -376,12 +394,21 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
hideButtonNextEp()
|
hideButtonNextEp()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun skipOpening() {
|
||||||
|
// calculate the seek time
|
||||||
|
model.currentEpisodeMeta?.let {
|
||||||
|
val seekTime = (it.openingStart + it.openingDuration) - model.player.currentPosition
|
||||||
|
model.seekToOffset(seekTime)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* show the next episode button
|
* show the next episode button
|
||||||
* TODO improve the show animation
|
* TODO improve the show animation
|
||||||
*/
|
*/
|
||||||
private fun showButtonNextEp() {
|
private fun showButtonNextEp() {
|
||||||
button_next_ep.visibility = View.VISIBLE
|
button_next_ep.isVisible = true
|
||||||
button_next_ep.alpha = 0.0f
|
button_next_ep.alpha = 0.0f
|
||||||
|
|
||||||
button_next_ep.animate()
|
button_next_ep.animate()
|
||||||
@ -399,7 +426,28 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
.setListener(object : AnimatorListenerAdapter() {
|
.setListener(object : AnimatorListenerAdapter() {
|
||||||
override fun onAnimationEnd(animation: Animator?) {
|
override fun onAnimationEnd(animation: Animator?) {
|
||||||
super.onAnimationEnd(animation)
|
super.onAnimationEnd(animation)
|
||||||
button_next_ep.visibility = View.GONE
|
button_next_ep.isVisible = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun showButtonSkipOp() {
|
||||||
|
button_skip_op.isVisible = true
|
||||||
|
button_skip_op.alpha = 0.0f
|
||||||
|
|
||||||
|
button_skip_op.animate()
|
||||||
|
.alpha(1.0f)
|
||||||
|
.setListener(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun hideButtonSkipOp() {
|
||||||
|
button_skip_op.animate()
|
||||||
|
.alpha(0.0f)
|
||||||
|
.setListener(object : AnimatorListenerAdapter() {
|
||||||
|
override fun onAnimationEnd(animation: Animator?) {
|
||||||
|
super.onAnimationEnd(animation)
|
||||||
|
button_skip_op.isVisible = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -437,7 +485,7 @@ class PlayerActivity : AppCompatActivity() {
|
|||||||
*/
|
*/
|
||||||
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
override fun onSingleTapConfirmed(e: MotionEvent?): Boolean {
|
||||||
if (!isInPiPMode()) {
|
if (!isInPiPMode()) {
|
||||||
if (controller.isVisible) controller.hide() else controller.show()
|
if (controller.isVisible) controller.hide() else controller.show()
|
||||||
}
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
|
@ -19,9 +19,7 @@ import kotlinx.coroutines.runBlocking
|
|||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.parser.AoDParser
|
import org.mosad.teapod.parser.AoDParser
|
||||||
import org.mosad.teapod.preferences.Preferences
|
import org.mosad.teapod.preferences.Preferences
|
||||||
import org.mosad.teapod.util.DataTypes
|
import org.mosad.teapod.util.*
|
||||||
import org.mosad.teapod.util.Episode
|
|
||||||
import org.mosad.teapod.util.Media
|
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import kotlin.collections.ArrayList
|
import kotlin.collections.ArrayList
|
||||||
|
|
||||||
@ -29,6 +27,9 @@ import kotlin.collections.ArrayList
|
|||||||
* PlayerViewModel handles all stuff related to media/episodes.
|
* PlayerViewModel handles all stuff related to media/episodes.
|
||||||
* When currentEpisode is changed the player will start playing it (not initial media),
|
* When currentEpisode is changed the player will start playing it (not initial media),
|
||||||
* the next episode will be update and the callback is handled.
|
* the next episode will be update and the callback is handled.
|
||||||
|
*
|
||||||
|
* TODO rework don't use episodes for everything, use media instead
|
||||||
|
* this is a major rework of the AoDParser/Player/Media architecture
|
||||||
*/
|
*/
|
||||||
class PlayerViewModel(application: Application) : AndroidViewModel(application) {
|
class PlayerViewModel(application: Application) : AndroidViewModel(application) {
|
||||||
|
|
||||||
@ -45,6 +46,10 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
internal set
|
internal set
|
||||||
var nextEpisode: Episode? = null
|
var nextEpisode: Episode? = null
|
||||||
internal set
|
internal set
|
||||||
|
var mediaMeta: Meta? = null
|
||||||
|
internal set
|
||||||
|
var currentEpisodeMeta: EpisodeMeta? = null
|
||||||
|
internal set
|
||||||
var currentLanguage: Locale = Locale.ROOT
|
var currentLanguage: Locale = Locale.ROOT
|
||||||
internal set
|
internal set
|
||||||
|
|
||||||
@ -75,10 +80,12 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
fun loadMedia(mediaId: Int, episodeId: Int) {
|
fun loadMedia(mediaId: Int, episodeId: Int) {
|
||||||
runBlocking {
|
runBlocking {
|
||||||
media = AoDParser.getMediaById(mediaId)
|
media = AoDParser.getMediaById(mediaId)
|
||||||
|
mediaMeta = loadMediaMeta(media.id) // can be done blocking, since it should be cached
|
||||||
}
|
}
|
||||||
|
|
||||||
currentEpisode = media.getEpisodeById(episodeId)
|
currentEpisode = media.getEpisodeById(episodeId)
|
||||||
nextEpisode = selectNextEpisode()
|
nextEpisode = selectNextEpisode()
|
||||||
|
currentEpisodeMeta = getEpisodeMetaByAoDMediaId(currentEpisode.id)
|
||||||
currentLanguage = currentEpisode.getPreferredStream(preferredLanguage).language
|
currentLanguage = currentEpisode.getPreferredStream(preferredLanguage).language
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +127,7 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
currentLanguage = preferredStream.language // update current language, since it may have changed
|
currentLanguage = preferredStream.language // update current language, since it may have changed
|
||||||
currentEpisode = episode
|
currentEpisode = episode
|
||||||
nextEpisode = selectNextEpisode()
|
nextEpisode = selectNextEpisode()
|
||||||
|
currentEpisodeMeta = getEpisodeMetaByAoDMediaId(episode.id)
|
||||||
currentEpisodeChangedListener.forEach { it() } // update player gui (title)
|
currentEpisodeChangedListener.forEach { it() } // update player gui (title)
|
||||||
|
|
||||||
val mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(
|
val mediaSource = HlsMediaSource.Factory(dataSourceFactory).createMediaSource(
|
||||||
@ -159,6 +167,23 @@ class PlayerViewModel(application: Application) : AndroidViewModel(application)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getEpisodeMetaByAoDMediaId(aodMediaId: Int): EpisodeMeta? {
|
||||||
|
val meta = mediaMeta
|
||||||
|
return if (meta is TVShowMeta) {
|
||||||
|
meta.episodes.firstOrNull { it.aodMediaId == aodMediaId }
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private suspend fun loadMediaMeta(aodId: Int): Meta? {
|
||||||
|
return if (media.type == DataTypes.MediaType.TVSHOW) {
|
||||||
|
MetaDBController().getTVShowMetadata(aodId)
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Based on the current episodeId, get the next episode. If there is no next
|
* Based on the current episodeId, get the next episode. If there is no next
|
||||||
* episode, return null
|
* episode, return null
|
||||||
|
@ -36,7 +36,7 @@ data class ThirdPartyComponent(
|
|||||||
* it is uses in the ItemMediaAdapter (RecyclerView)
|
* it is uses in the ItemMediaAdapter (RecyclerView)
|
||||||
*/
|
*/
|
||||||
data class ItemMedia(
|
data class ItemMedia(
|
||||||
val id: Int,
|
val id: Int, // aod path id
|
||||||
val title: String,
|
val title: String,
|
||||||
val posterUrl: String
|
val posterUrl: String
|
||||||
)
|
)
|
||||||
@ -98,24 +98,12 @@ data class Stream(
|
|||||||
val language : Locale
|
val language : Locale
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
|
||||||
* this class is used for tmdb responses
|
|
||||||
*/
|
|
||||||
data class TMDBResponse(
|
|
||||||
val id: Int = 0,
|
|
||||||
val title: String = "",
|
|
||||||
val overview: String = "",
|
|
||||||
val posterUrl: String = "",
|
|
||||||
val backdropUrl: String = "",
|
|
||||||
val runtime: Int = 0
|
|
||||||
)
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this class is used to represent the aod json API?
|
* this class is used to represent the aod json API?
|
||||||
*/
|
*/
|
||||||
data class AoDObject(
|
data class AoDPlaylist(
|
||||||
val playlist: List<Playlist>,
|
val list: List<Playlist>,
|
||||||
val extLanguage: String
|
val language: Locale
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Playlist(
|
data class Playlist(
|
||||||
|
156
app/src/main/java/org/mosad/teapod/util/MetaDBController.kt
Normal file
156
app/src/main/java/org/mosad/teapod/util/MetaDBController.kt
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
/**
|
||||||
|
* Teapod
|
||||||
|
*
|
||||||
|
* Copyright 2020-2021 <seil0@mosad.xyz>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.mosad.teapod.util
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import java.io.FileNotFoundException
|
||||||
|
import java.net.URL
|
||||||
|
|
||||||
|
class MetaDBController {
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
private const val repoUrl = "https://gitlab.com/Seil0/teapodmetadb/-/raw/main/aod/"
|
||||||
|
|
||||||
|
var mediaList = MediaList(listOf())
|
||||||
|
private var metaCacheList = arrayListOf<Meta>()
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
suspend fun list() = withContext(Dispatchers.IO) {
|
||||||
|
val url = URL("$repoUrl/list.json")
|
||||||
|
val json = url.readText()
|
||||||
|
|
||||||
|
mediaList = Gson().fromJson(json, MediaList::class.java)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the meta data for a movie from MetaDB
|
||||||
|
* @param aodId The AoD id of the media
|
||||||
|
* @return A meta movie object, or null if not found
|
||||||
|
*/
|
||||||
|
suspend fun getMovieMetadata(aodId: Int): MovieMeta? {
|
||||||
|
return metaCacheList.firstOrNull {
|
||||||
|
it.aodId == aodId
|
||||||
|
} as MovieMeta? ?: getMovieMetadataFromDB(aodId)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the meta data for a tv show from MetaDB
|
||||||
|
* @param aodId The AoD id of the media
|
||||||
|
* @return A meta tv show object, or null if not found
|
||||||
|
*/
|
||||||
|
suspend fun getTVShowMetadata(aodId: Int): TVShowMeta? {
|
||||||
|
return metaCacheList.firstOrNull {
|
||||||
|
it.aodId == aodId
|
||||||
|
} as TVShowMeta? ?: getTVShowMetadataFromDB(aodId)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
private suspend fun getMovieMetadataFromDB(aodId: Int): MovieMeta? = withContext(Dispatchers.IO) {
|
||||||
|
val url = URL("$repoUrl/movie/$aodId/media.json")
|
||||||
|
return@withContext try {
|
||||||
|
val json = url.readText()
|
||||||
|
val meta = Gson().fromJson(json, MovieMeta::class.java)
|
||||||
|
metaCacheList.add(meta)
|
||||||
|
|
||||||
|
meta
|
||||||
|
} catch (ex: FileNotFoundException) {
|
||||||
|
Log.w(javaClass.name, "Waring: The requested file was not found. Requested ID: $aodId", ex)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
private suspend fun getTVShowMetadataFromDB(aodId: Int): TVShowMeta? = withContext(Dispatchers.IO) {
|
||||||
|
val url = URL("$repoUrl/tv/$aodId/media.json")
|
||||||
|
return@withContext try {
|
||||||
|
val json = url.readText()
|
||||||
|
val meta = Gson().fromJson(json, TVShowMeta::class.java)
|
||||||
|
metaCacheList.add(meta)
|
||||||
|
|
||||||
|
meta
|
||||||
|
} catch (ex: FileNotFoundException) {
|
||||||
|
Log.w(javaClass.name, "Waring: The requested file was not found. Requested ID: $aodId", ex)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// class representing the media list json object
|
||||||
|
data class MediaList(
|
||||||
|
val media: List<Int>
|
||||||
|
)
|
||||||
|
|
||||||
|
// abstract class used for meta data objects (tv, movie)
|
||||||
|
abstract class Meta {
|
||||||
|
abstract val id: Int
|
||||||
|
abstract val aodId: Int
|
||||||
|
abstract val tmdbId: Int
|
||||||
|
}
|
||||||
|
|
||||||
|
// class representing the movie json object
|
||||||
|
data class MovieMeta(
|
||||||
|
override val id: Int,
|
||||||
|
@SerializedName("aod_id")
|
||||||
|
override val aodId: Int,
|
||||||
|
@SerializedName("tmdb_id")
|
||||||
|
override val tmdbId: Int
|
||||||
|
): Meta()
|
||||||
|
|
||||||
|
// class representing the tv show json object
|
||||||
|
data class TVShowMeta(
|
||||||
|
override val id: Int,
|
||||||
|
@SerializedName("aod_id")
|
||||||
|
override val aodId: Int,
|
||||||
|
@SerializedName("tmdb_id")
|
||||||
|
override val tmdbId: Int,
|
||||||
|
@SerializedName("tmdb_season_id")
|
||||||
|
val tmdbSeasonId: Int,
|
||||||
|
@SerializedName("tmdb_season_number")
|
||||||
|
val tmdbSeasonNumber: Int,
|
||||||
|
@SerializedName("episodes")
|
||||||
|
val episodes: List<EpisodeMeta>
|
||||||
|
): Meta()
|
||||||
|
|
||||||
|
// class used in TVShowMeta, part of the tv show json object
|
||||||
|
data class EpisodeMeta(
|
||||||
|
val id: Int,
|
||||||
|
@SerializedName("aod_media_id")
|
||||||
|
val aodMediaId: Int,
|
||||||
|
@SerializedName("tmdb_id")
|
||||||
|
val tmdbId: Int,
|
||||||
|
@SerializedName("tmdb_number")
|
||||||
|
val tmdbNumber: Int,
|
||||||
|
@SerializedName("opening_start")
|
||||||
|
val openingStart: Long,
|
||||||
|
@SerializedName("opening_duration")
|
||||||
|
val openingDuration: Long,
|
||||||
|
@SerializedName("ending_start")
|
||||||
|
val endingStart: Long,
|
||||||
|
@SerializedName("ending_duration")
|
||||||
|
val endingDuration: Long
|
||||||
|
)
|
@ -1,121 +0,0 @@
|
|||||||
package org.mosad.teapod.util
|
|
||||||
|
|
||||||
import android.util.Log
|
|
||||||
import com.google.gson.JsonObject
|
|
||||||
import com.google.gson.JsonParser
|
|
||||||
import kotlinx.coroutines.*
|
|
||||||
import org.mosad.teapod.util.DataTypes.MediaType
|
|
||||||
import java.net.URL
|
|
||||||
import java.net.URLEncoder
|
|
||||||
|
|
||||||
class TMDBApiController {
|
|
||||||
|
|
||||||
private val apiUrl = "https://api.themoviedb.org/3"
|
|
||||||
private val searchMovieUrl = "$apiUrl/search/movie"
|
|
||||||
private val searchTVUrl = "$apiUrl/search/tv"
|
|
||||||
private val getMovieUrl = "$apiUrl/movie"
|
|
||||||
private val apiKey = "de959cf9c07a08b5ca7cb51cda9a40c2"
|
|
||||||
private val language = "de"
|
|
||||||
private val preparedParameters = "?api_key=$apiKey&language=$language"
|
|
||||||
|
|
||||||
private val imageUrl = "https://image.tmdb.org/t/p/w500"
|
|
||||||
|
|
||||||
suspend fun search(title: String, type: MediaType): TMDBResponse {
|
|
||||||
// remove unneeded text from the media title before searching
|
|
||||||
val searchTerm = title.replace("(Sub)", "")
|
|
||||||
.replace(Regex("-?\\s?[0-9]+.\\s?(Staffel|Season)"), "")
|
|
||||||
.replace(Regex("(Staffel|Season)\\s?[0-9]+"), "")
|
|
||||||
.trim()
|
|
||||||
|
|
||||||
return when (type) {
|
|
||||||
MediaType.MOVIE -> searchMovie(searchTerm)
|
|
||||||
MediaType.TVSHOW -> searchTVShow(searchTerm)
|
|
||||||
else -> {
|
|
||||||
Log.e(javaClass.name, "Wrong Type: $type")
|
|
||||||
TMDBResponse()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
|
||||||
private suspend fun searchTVShow(title: String): TMDBResponse = withContext(Dispatchers.IO) {
|
|
||||||
val url = URL("$searchTVUrl$preparedParameters&query=${URLEncoder.encode(title, "UTF-8")}")
|
|
||||||
val response = JsonParser.parseString(url.readText()).asJsonObject
|
|
||||||
// println(response)
|
|
||||||
|
|
||||||
val sortedResults = response.get("results").asJsonArray.toList().sortedBy {
|
|
||||||
getStringNotNull(it.asJsonObject, "name")
|
|
||||||
}
|
|
||||||
|
|
||||||
return@withContext if (sortedResults.isNotEmpty()) {
|
|
||||||
sortedResults.first().asJsonObject.let {
|
|
||||||
val id = getStringNotNull(it, "id").toInt()
|
|
||||||
val overview = getStringNotNull(it, "overview")
|
|
||||||
val posterPath = getStringNotNullPrefix(it, "poster_path", imageUrl)
|
|
||||||
val backdropPath = getStringNotNullPrefix(it, "backdrop_path", imageUrl)
|
|
||||||
|
|
||||||
TMDBResponse(id, "", overview, posterPath, backdropPath)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
TMDBResponse()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
|
||||||
private suspend fun searchMovie(title: String): TMDBResponse = withContext(Dispatchers.IO) {
|
|
||||||
val url = URL("$searchMovieUrl$preparedParameters&query=${URLEncoder.encode(title, "UTF-8")}")
|
|
||||||
val response = JsonParser.parseString(url.readText()).asJsonObject
|
|
||||||
// println(response)
|
|
||||||
|
|
||||||
val sortedResults = response.get("results").asJsonArray.toList().sortedBy {
|
|
||||||
getStringNotNull(it.asJsonObject, "title")
|
|
||||||
}
|
|
||||||
|
|
||||||
return@withContext if (sortedResults.isNotEmpty()) {
|
|
||||||
sortedResults.first().asJsonObject.let {
|
|
||||||
val id = getStringNotNull(it,"id").toInt()
|
|
||||||
val overview = getStringNotNull(it,"overview")
|
|
||||||
val posterPath = getStringNotNullPrefix(it, "poster_path", imageUrl)
|
|
||||||
val backdropPath = getStringNotNullPrefix(it, "backdrop_path", imageUrl)
|
|
||||||
val runtime = getMovieRuntime(id)
|
|
||||||
|
|
||||||
TMDBResponse(id, "", overview, posterPath, backdropPath, runtime)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
TMDBResponse()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* currently only used for runtime, need a rework
|
|
||||||
*/
|
|
||||||
@Suppress("BlockingMethodInNonBlockingContext")
|
|
||||||
suspend fun getMovieRuntime(id: Int): Int = withContext(Dispatchers.IO) {
|
|
||||||
val url = URL("$getMovieUrl/$id?api_key=$apiKey&language=$language")
|
|
||||||
|
|
||||||
val response = JsonParser.parseString(url.readText()).asJsonObject
|
|
||||||
return@withContext getStringNotNull(response,"runtime").toInt()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return memberName as string if it's not JsonNull,
|
|
||||||
* else return an empty string
|
|
||||||
*/
|
|
||||||
private fun getStringNotNull(jsonObject: JsonObject, memberName: String): String {
|
|
||||||
return getStringNotNullPrefix(jsonObject, memberName, "")
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return memberName as string with a prefix if it's not JsonNull,
|
|
||||||
* else return an empty string
|
|
||||||
*/
|
|
||||||
private fun getStringNotNullPrefix(jsonObject: JsonObject, memberName: String, prefix: String): String {
|
|
||||||
return if (!jsonObject.get(memberName).isJsonNull) {
|
|
||||||
prefix + jsonObject.get(memberName).asString
|
|
||||||
} else {
|
|
||||||
""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -12,8 +12,9 @@ import jp.wasabeef.glide.transformations.RoundedCornersTransformation
|
|||||||
import org.mosad.teapod.R
|
import org.mosad.teapod.R
|
||||||
import org.mosad.teapod.databinding.ItemEpisodeBinding
|
import org.mosad.teapod.databinding.ItemEpisodeBinding
|
||||||
import org.mosad.teapod.util.Episode
|
import org.mosad.teapod.util.Episode
|
||||||
|
import org.mosad.teapod.util.tmdb.TMDBTVEpisode
|
||||||
|
|
||||||
class EpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerView.Adapter<EpisodeItemAdapter.EpisodeViewHolder>() {
|
class EpisodeItemAdapter(private val episodes: List<Episode>, private val tmdbEpisodes: List<TMDBTVEpisode>?) : RecyclerView.Adapter<EpisodeItemAdapter.EpisodeViewHolder>() {
|
||||||
|
|
||||||
var onImageClick: ((String, Int) -> Unit)? = null
|
var onImageClick: ((String, Int) -> Unit)? = null
|
||||||
|
|
||||||
@ -32,7 +33,13 @@ class EpisodeItemAdapter(private val episodes: List<Episode>) : RecyclerView.Ada
|
|||||||
}
|
}
|
||||||
|
|
||||||
holder.binding.textEpisodeTitle.text = titleText
|
holder.binding.textEpisodeTitle.text = titleText
|
||||||
holder.binding.textEpisodeDesc.text = ep.shortDesc
|
holder.binding.textEpisodeDesc.text = if (ep.shortDesc.isNotEmpty()) {
|
||||||
|
ep.shortDesc
|
||||||
|
} else if (tmdbEpisodes != null && position < tmdbEpisodes.size){
|
||||||
|
tmdbEpisodes[position].overview
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
|
||||||
if (episodes[position].posterUrl.isNotEmpty()) {
|
if (episodes[position].posterUrl.isNotEmpty()) {
|
||||||
Glide.with(context).load(ep.posterUrl)
|
Glide.with(context).load(ep.posterUrl)
|
||||||
|
@ -0,0 +1,137 @@
|
|||||||
|
/**
|
||||||
|
* Teapod
|
||||||
|
*
|
||||||
|
* Copyright 2020-2021 <seil0@mosad.xyz>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.mosad.teapod.util.tmdb
|
||||||
|
|
||||||
|
import android.util.Log
|
||||||
|
import com.google.gson.Gson
|
||||||
|
import com.google.gson.JsonParser
|
||||||
|
import kotlinx.coroutines.*
|
||||||
|
import org.mosad.teapod.util.DataTypes.MediaType
|
||||||
|
import java.io.FileNotFoundException
|
||||||
|
import java.net.URL
|
||||||
|
import java.net.URLEncoder
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Controller for tmdb api integration.
|
||||||
|
* Data types are in TMDBDataTypes. For the type definitions see:
|
||||||
|
* https://developers.themoviedb.org/3/getting-started/introduction
|
||||||
|
*
|
||||||
|
* TODO evaluate Klaxon
|
||||||
|
*/
|
||||||
|
class TMDBApiController {
|
||||||
|
|
||||||
|
private val apiUrl = "https://api.themoviedb.org/3"
|
||||||
|
private val searchMovieUrl = "$apiUrl/search/movie"
|
||||||
|
private val searchTVUrl = "$apiUrl/search/tv"
|
||||||
|
private val detailsMovieUrl = "$apiUrl/movie"
|
||||||
|
private val detailsTVUrl = "$apiUrl/tv"
|
||||||
|
private val apiKey = "de959cf9c07a08b5ca7cb51cda9a40c2"
|
||||||
|
private val language = "de"
|
||||||
|
private val preparedParameters = "?api_key=$apiKey&language=$language"
|
||||||
|
|
||||||
|
companion object{
|
||||||
|
const val imageUrl = "https://image.tmdb.org/t/p/w500"
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
/**
|
||||||
|
* Search for a media(movie or tv show) in tmdb
|
||||||
|
* @param query The query text
|
||||||
|
* @param type The media type (movie or tv show)
|
||||||
|
* @return The media tmdb id, or -1 if not found
|
||||||
|
*/
|
||||||
|
suspend fun search(query: String, type: MediaType): Int = withContext(Dispatchers.IO) {
|
||||||
|
val searchUrl = when (type) {
|
||||||
|
MediaType.MOVIE -> searchMovieUrl
|
||||||
|
MediaType.TVSHOW -> searchTVUrl
|
||||||
|
else -> {
|
||||||
|
Log.e(javaClass.name, "Wrong Type: $type")
|
||||||
|
return@withContext -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
val url = URL("$searchUrl$preparedParameters&query=${URLEncoder.encode(query, "UTF-8")}")
|
||||||
|
val response = JsonParser.parseString(url.readText()).asJsonObject
|
||||||
|
val sortedResults = response.get("results").asJsonArray.toList().sortedBy {
|
||||||
|
it.asJsonObject.get("title")?.asString
|
||||||
|
}
|
||||||
|
|
||||||
|
return@withContext sortedResults.firstOrNull()?.asJsonObject?.get("id")?.asInt ?: -1
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
/**
|
||||||
|
* Get details for a movie from tmdb
|
||||||
|
* @param movieId The tmdb ID of the movie
|
||||||
|
* @return A tmdb movie object, or null if not found
|
||||||
|
*/
|
||||||
|
suspend fun getMovieDetails(movieId: Int): TMDBMovie? = withContext(Dispatchers.IO) {
|
||||||
|
val url = URL("$detailsMovieUrl/$movieId?api_key=$apiKey&language=$language")
|
||||||
|
|
||||||
|
return@withContext try {
|
||||||
|
val json = url.readText()
|
||||||
|
Gson().fromJson(json, TMDBMovie::class.java)
|
||||||
|
} catch (ex: FileNotFoundException) {
|
||||||
|
Log.w(javaClass.name, "Waring: The requested media was not found. Requested ID: $movieId", ex)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
/**
|
||||||
|
* Get details for a tv show from tmdb
|
||||||
|
* @param tvId The tmdb ID of the tv show
|
||||||
|
* @return A tmdb tv show object, or null if not found
|
||||||
|
*/
|
||||||
|
suspend fun getTVShowDetails(tvId: Int): TMDBTVShow? = withContext(Dispatchers.IO) {
|
||||||
|
val url = URL("$detailsTVUrl/$tvId?api_key=$apiKey&language=$language")
|
||||||
|
|
||||||
|
return@withContext try {
|
||||||
|
val json = url.readText()
|
||||||
|
Gson().fromJson(json, TMDBTVShow::class.java)
|
||||||
|
} catch (ex: FileNotFoundException) {
|
||||||
|
Log.w(javaClass.name, "Waring: The requested media was not found. Requested ID: $tvId", ex)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Suppress("BlockingMethodInNonBlockingContext")
|
||||||
|
/**
|
||||||
|
* Get details for a tv show season from tmdb
|
||||||
|
* @param tvId The tmdb ID of the tv show
|
||||||
|
* @param seasonNumber The tmdb season number
|
||||||
|
* @return A tmdb tv season object, or null if not found
|
||||||
|
*/
|
||||||
|
suspend fun getTVSeasonDetails(tvId: Int, seasonNumber: Int): TMDBTVSeason? = withContext(Dispatchers.IO) {
|
||||||
|
val url = URL("$detailsTVUrl/$tvId/season/$seasonNumber?api_key=$apiKey&language=$language")
|
||||||
|
|
||||||
|
return@withContext try {
|
||||||
|
val json = url.readText()
|
||||||
|
Gson().fromJson(json, TMDBTVSeason::class.java)
|
||||||
|
} catch (ex: FileNotFoundException) {
|
||||||
|
Log.w(javaClass.name, "Waring: The requested media was not found. Requested ID: $tvId, Season: $seasonNumber", ex)
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* Teapod
|
||||||
|
*
|
||||||
|
* Copyright 2020-2021 <seil0@mosad.xyz>
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||||
|
* MA 02110-1301, USA.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.mosad.teapod.util.tmdb
|
||||||
|
|
||||||
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
|
/**
|
||||||
|
* These data classes represent the tmdb api json objects.
|
||||||
|
* Fields which are nullable in the tmdb api are also nullable here.
|
||||||
|
*/
|
||||||
|
|
||||||
|
abstract class TMDBResult{
|
||||||
|
abstract val id: Int
|
||||||
|
abstract val name: String
|
||||||
|
abstract val overview: String? // for movies tmdb return string or null
|
||||||
|
abstract val posterPath: String?
|
||||||
|
abstract val backdropPath: String?
|
||||||
|
}
|
||||||
|
|
||||||
|
data class TMDBMovie(
|
||||||
|
override val id: Int,
|
||||||
|
override val name: String,
|
||||||
|
override val overview: String?,
|
||||||
|
@SerializedName("poster_path")
|
||||||
|
override val posterPath: String?,
|
||||||
|
@SerializedName("backdrop_path")
|
||||||
|
override val backdropPath: String?,
|
||||||
|
@SerializedName("release_date")
|
||||||
|
val releaseDate: String,
|
||||||
|
@SerializedName("runtime")
|
||||||
|
val runtime: Int?,
|
||||||
|
// TODO generes
|
||||||
|
): TMDBResult()
|
||||||
|
|
||||||
|
data class TMDBTVShow(
|
||||||
|
override val id: Int,
|
||||||
|
override val name: String,
|
||||||
|
override val overview: String,
|
||||||
|
@SerializedName("poster_path")
|
||||||
|
override val posterPath: String?,
|
||||||
|
@SerializedName("backdrop_path")
|
||||||
|
override val backdropPath: String?,
|
||||||
|
@SerializedName("first_air_date")
|
||||||
|
val firstAirDate: String,
|
||||||
|
@SerializedName("status")
|
||||||
|
val status: String,
|
||||||
|
// TODO generes
|
||||||
|
): TMDBResult()
|
||||||
|
|
||||||
|
data class TMDBTVSeason(
|
||||||
|
val id: Int,
|
||||||
|
val name: String,
|
||||||
|
val overview: String,
|
||||||
|
@SerializedName("poster_path")
|
||||||
|
val posterPath: String?,
|
||||||
|
@SerializedName("air_date")
|
||||||
|
val airDate: String,
|
||||||
|
@SerializedName("episodes")
|
||||||
|
val episodes: List<TMDBTVEpisode>,
|
||||||
|
@SerializedName("season_number")
|
||||||
|
val seasonNumber: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
data class TMDBTVEpisode(
|
||||||
|
val id: Int,
|
||||||
|
val name: String,
|
||||||
|
val overview: String,
|
||||||
|
@SerializedName("air_date")
|
||||||
|
val airDate: String,
|
||||||
|
@SerializedName("episode_number")
|
||||||
|
val episodeNumber: Int
|
||||||
|
)
|
@ -1,5 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<solid android:color="?textBackground"/>
|
<solid android:color="?attr/shapeTextBackground"/>
|
||||||
<corners android:radius="3dp"/>
|
<corners android:radius="3dp"/>
|
||||||
</shape>
|
</shape>
|
@ -89,4 +89,20 @@
|
|||||||
app:backgroundTint="@color/exo_white"
|
app:backgroundTint="@color/exo_white"
|
||||||
app:iconGravity="textStart" />
|
app:iconGravity="textStart" />
|
||||||
|
|
||||||
|
<com.google.android.material.button.MaterialButton
|
||||||
|
android:id="@+id/button_skip_op"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="bottom|end"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:layout_marginBottom="70dp"
|
||||||
|
android:gravity="center"
|
||||||
|
android:text="@string/skip_opening"
|
||||||
|
android:textAllCaps="false"
|
||||||
|
android:textColor="@android:color/primary_text_light"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:visibility="gone"
|
||||||
|
app:backgroundTint="@color/exo_white"
|
||||||
|
app:iconGravity="textStart" />
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
@ -69,6 +69,7 @@
|
|||||||
<string name="play_pause">Abspielen/Pause</string>
|
<string name="play_pause">Abspielen/Pause</string>
|
||||||
<string name="forward_10">10 Sekunden vorwärts</string>
|
<string name="forward_10">10 Sekunden vorwärts</string>
|
||||||
<string name="next_episode">Nächste Folge</string>
|
<string name="next_episode">Nächste Folge</string>
|
||||||
|
<string name="skip_opening">Intro überspringen</string>
|
||||||
<string name="language">Sprache</string>
|
<string name="language">Sprache</string>
|
||||||
<string name="episodes">Folgen</string>
|
<string name="episodes">Folgen</string>
|
||||||
<string name="episode">Folge</string>
|
<string name="episode">Folge</string>
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<attr format="color" name="themeSecondary"/>
|
<attr format="color" name="themeSecondary"/>
|
||||||
<attr format="color" name="textPrimary"/>
|
<attr format="color" name="textPrimary"/>
|
||||||
<attr format="color" name="textSecondary"/>
|
<attr format="color" name="textSecondary"/>
|
||||||
<attr format="color" name="textBackground"/>
|
|
||||||
<attr format="color" name="iconColor"/>
|
<attr format="color" name="iconColor"/>
|
||||||
<attr format="color" name="buttonBackground"/>
|
<attr format="color" name="buttonBackground"/>
|
||||||
|
<attr format="color" name="shapeTextBackground"/>
|
||||||
</resources>
|
</resources>
|
@ -88,6 +88,7 @@
|
|||||||
<string name="rwd_10_s" translatable="false">- 10 s</string>
|
<string name="rwd_10_s" translatable="false">- 10 s</string>
|
||||||
<string name="fwd_10_s" translatable="false">+ 10 s</string>
|
<string name="fwd_10_s" translatable="false">+ 10 s</string>
|
||||||
<string name="next_episode">Next Episode</string>
|
<string name="next_episode">Next Episode</string>
|
||||||
|
<string name="skip_opening">Skip Opening</string>
|
||||||
<string name="time_min_sec" translatable="false">%1$02d:%2$02d</string>
|
<string name="time_min_sec" translatable="false">%1$02d:%2$02d</string>
|
||||||
<string name="time_hour_min_sec" translatable="false">%1$d:%2$02d:%3$02d</string>
|
<string name="time_hour_min_sec" translatable="false">%1$d:%2$02d:%3$02d</string>
|
||||||
<string name="language">Language</string>
|
<string name="language">Language</string>
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
<item name="android:textColor">@color/textPrimaryLight</item>
|
<item name="android:textColor">@color/textPrimaryLight</item>
|
||||||
<item name="android:textColorPrimary">@color/textPrimaryLight</item>
|
<item name="android:textColorPrimary">@color/textPrimaryLight</item>
|
||||||
<item name="android:textColorHint">@color/textSecondaryLight</item>
|
<item name="android:textColorHint">@color/textSecondaryLight</item>
|
||||||
<item name="textBackground">@color/textBackgroundLight</item>
|
<item name="shapeTextBackground">@color/textBackgroundLight</item>
|
||||||
<item name="iconColor">@color/iconColorLight</item>
|
<item name="iconColor">@color/iconColorLight</item>
|
||||||
<item name="buttonBackground">@color/buttonBackgroundLight</item>
|
<item name="buttonBackground">@color/buttonBackgroundLight</item>
|
||||||
<item name="md_background_color">@color/themeSecondaryLight</item>
|
<item name="md_background_color">@color/themeSecondaryLight</item>
|
||||||
@ -32,7 +32,7 @@
|
|||||||
<item name="android:textColor">@color/textPrimaryDark</item>
|
<item name="android:textColor">@color/textPrimaryDark</item>
|
||||||
<item name="android:textColorPrimary">@color/textPrimaryDark</item>
|
<item name="android:textColorPrimary">@color/textPrimaryDark</item>
|
||||||
<item name="android:textColorHint">@color/textSecondaryDark</item>
|
<item name="android:textColorHint">@color/textSecondaryDark</item>
|
||||||
<item name="textBackground">@color/textBackgroundDark</item>
|
<item name="shapeTextBackground">@color/textBackgroundDark</item>
|
||||||
<item name="iconColor">@color/iconColorDark</item>
|
<item name="iconColor">@color/iconColorDark</item>
|
||||||
<item name="buttonBackground">@color/buttonBackgroundDark</item>
|
<item name="buttonBackground">@color/buttonBackgroundDark</item>
|
||||||
<item name="md_background_color">@color/themeSecondaryDark</item>
|
<item name="md_background_color">@color/themeSecondaryDark</item>
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = "1.5.21"
|
ext.kotlin_version = "1.5.30"
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.0.0'
|
classpath 'com.android.tools.build:gradle:7.0.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,5 +1,5 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-bin.zip
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
|
Loading…
Reference in New Issue
Block a user