Compare commits
No commits in common. "main" and "download-transcoding" have entirely different histories.
main
...
download-t
46 changed files with 1355 additions and 1992 deletions
5
.github/workflows/build.yaml
vendored
5
.github/workflows/build.yaml
vendored
|
@ -25,7 +25,6 @@ jobs:
|
|||
assemble:
|
||||
name: Assemble
|
||||
runs-on: ubuntu-22.04
|
||||
if: startsWith(github.event.head_commit.message, 'build:')
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
@ -41,11 +40,11 @@ jobs:
|
|||
- name: Build with Gradle
|
||||
run: ./gradlew assemble
|
||||
# Upload all build artifacts in separate steps. This can be shortened once https://github.com/actions/upload-artifact/pull/354 is merged.
|
||||
- name: Upload artifact ananas-v0.10.3-0.14.2-libre-arm64-v8a.apk
|
||||
- name: Upload artifact ananas-v0.14.2-libre-arm64-v8a.apk
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: phone-libre-arm64-v8a.apk
|
||||
path: ./app/phone/build/outputs/apk/libre/release/ananas-v0.10.3-0.14.2-libre-arm64-v8a.apk
|
||||
path: ./app/phone/build/outputs/apk/libre/release/ananas-v0.14.2-libre-arm64-v8a.apk
|
||||
# - name: Upload artifact phone-libre-armeabi-v7a-debug.apk
|
||||
# uses: actions/upload-artifact@v4
|
||||
# with:
|
||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -41,4 +41,3 @@ fastlane/report.xml
|
|||
fastlane/Preview.html
|
||||
fastlane/screenshots
|
||||
fastlane/test_output
|
||||
push.sh
|
||||
|
|
|
@ -10,8 +10,7 @@ Personal fork
|
|||
- Completely native interface
|
||||
- Supported media items: movies, series, seasons, episodes
|
||||
- Direct play and Transcoding
|
||||
- Offline playback / downloads
|
||||
- Transcoding Downloads (Original - 720p - 480p - 360p)
|
||||
- Offline playback / downloads
|
||||
- ExoPlayer
|
||||
- Video codecs: H.263, H.264, H.265, VP8, VP9, AV1
|
||||
- Support depends on Android device
|
||||
|
|
|
@ -1,87 +0,0 @@
|
|||
{
|
||||
"version": 3,
|
||||
"artifactType": {
|
||||
"type": "APK",
|
||||
"kind": "Directory"
|
||||
},
|
||||
"applicationId": "com.nomadics9.ananas",
|
||||
"variantName": "AnanasRelease",
|
||||
"elements": [
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
"filters": [
|
||||
{
|
||||
"filterType": "ABI",
|
||||
"value": "armeabi-v7a"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 16,
|
||||
"versionName": "0.10.6-0.14.2",
|
||||
"outputFile": "ananas-v0.10.6-0.14.2-Ananas-armeabi-v7a.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
"filters": [
|
||||
{
|
||||
"filterType": "ABI",
|
||||
"value": "arm64-v8a"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 16,
|
||||
"versionName": "0.10.6-0.14.2",
|
||||
"outputFile": "ananas-v0.10.6-0.14.2-Ananas-arm64-v8a.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
"filters": [
|
||||
{
|
||||
"filterType": "ABI",
|
||||
"value": "x86_64"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 16,
|
||||
"versionName": "0.10.6-0.14.2",
|
||||
"outputFile": "ananas-v0.10.6-0.14.2-Ananas-x86_64.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
"filters": [
|
||||
{
|
||||
"filterType": "ABI",
|
||||
"value": "x86"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 16,
|
||||
"versionName": "0.10.6-0.14.2",
|
||||
"outputFile": "ananas-v0.10.6-0.14.2-Ananas-x86.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
"baselineProfiles": [
|
||||
{
|
||||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/ananas-v0.10.6-0.14.2-Ananas-armeabi-v7a.dm",
|
||||
"baselineProfiles/1/ananas-v0.10.6-0.14.2-Ananas-arm64-v8a.dm",
|
||||
"baselineProfiles/1/ananas-v0.10.6-0.14.2-Ananas-x86_64.dm",
|
||||
"baselineProfiles/1/ananas-v0.10.6-0.14.2-Ananas-x86.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/0/ananas-v0.10.6-0.14.2-Ananas-armeabi-v7a.dm",
|
||||
"baselineProfiles/0/ananas-v0.10.6-0.14.2-Ananas-arm64-v8a.dm",
|
||||
"baselineProfiles/0/ananas-v0.10.6-0.14.2-Ananas-x86_64.dm",
|
||||
"baselineProfiles/0/ananas-v0.10.6-0.14.2-Ananas-x86.dm"
|
||||
]
|
||||
}
|
||||
],
|
||||
"minSdkVersionForDexing": 28
|
||||
}
|
|
@ -23,10 +23,6 @@ android {
|
|||
versionName = Versions.appName
|
||||
|
||||
testInstrumentationRunner = "com.nomadics9.ananas.HiltTestRunner"
|
||||
buildConfigField( "String", "DEFAULT_SERVER_ADDRESS", "\" \"")
|
||||
buildConfigField( "String", "REQUEST_SERVER_ADDRESS", "\" \"")
|
||||
buildConfigField("String", "FORGET_PASSWORD_ADDRESS", "\" \"")
|
||||
buildConfigField("String", "UPDATE_ADDRESS", "\" \"")
|
||||
}
|
||||
|
||||
applicationVariants.all {
|
||||
|
@ -61,18 +57,10 @@ android {
|
|||
|
||||
flavorDimensions += "variant"
|
||||
productFlavors {
|
||||
create("libre") {
|
||||
register("libre") {
|
||||
dimension = "variant"
|
||||
isDefault = true
|
||||
}
|
||||
create("Ananas") {
|
||||
dimension = "variant"
|
||||
isDefault = false
|
||||
buildConfigField( "String", "DEFAULT_SERVER_ADDRESS", "\"https://askar.tv\"")
|
||||
buildConfigField( "String", "REQUEST_SERVER_ADDRESS", "\"https://r.askar.tv\"")
|
||||
buildConfigField("String", "FORGET_PASSWORD_ADDRESS", "\"https://user.askar.tv/my/account\"")
|
||||
buildConfigField("String", "UPDATE_ADDRESS", "\"https://fs.nmd.mov/p/ananas.apk\"")
|
||||
}
|
||||
}
|
||||
|
||||
splits {
|
||||
|
@ -134,7 +122,6 @@ dependencies {
|
|||
implementation(libs.material)
|
||||
implementation(libs.media3.ffmpeg.decoder)
|
||||
implementation(libs.timber)
|
||||
implementation(libs.markwon)
|
||||
|
||||
coreLibraryDesugaring(libs.android.desugar.jdk)
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -16,9 +16,9 @@
|
|||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 11,
|
||||
"versionName": "0.10.1-0.14.2",
|
||||
"outputFile": "ananas-v0.10.1-0.14.2-libre-armeabi-v7a.apk"
|
||||
"versionCode": 9,
|
||||
"versionName": "0.14.2",
|
||||
"outputFile": "ananas-v0.14.2-libre-armeabi-v7a.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
|
@ -29,22 +29,9 @@
|
|||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 11,
|
||||
"versionName": "0.10.1-0.14.2",
|
||||
"outputFile": "ananas-v0.10.1-0.14.2-libre-x86_64.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
"filters": [
|
||||
{
|
||||
"filterType": "ABI",
|
||||
"value": "arm64-v8a"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 11,
|
||||
"versionName": "0.10.1-0.14.2",
|
||||
"outputFile": "ananas-v0.10.1-0.14.2-libre-arm64-v8a.apk"
|
||||
"versionCode": 9,
|
||||
"versionName": "0.14.2",
|
||||
"outputFile": "ananas-v0.14.2-libre-x86_64.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
|
@ -55,9 +42,22 @@
|
|||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 11,
|
||||
"versionName": "0.10.1-0.14.2",
|
||||
"outputFile": "ananas-v0.10.1-0.14.2-libre-x86.apk"
|
||||
"versionCode": 9,
|
||||
"versionName": "0.14.2",
|
||||
"outputFile": "ananas-v0.14.2-libre-x86.apk"
|
||||
},
|
||||
{
|
||||
"type": "ONE_OF_MANY",
|
||||
"filters": [
|
||||
{
|
||||
"filterType": "ABI",
|
||||
"value": "arm64-v8a"
|
||||
}
|
||||
],
|
||||
"attributes": [],
|
||||
"versionCode": 9,
|
||||
"versionName": "0.14.2",
|
||||
"outputFile": "ananas-v0.14.2-libre-arm64-v8a.apk"
|
||||
}
|
||||
],
|
||||
"elementType": "File",
|
||||
|
@ -66,20 +66,20 @@
|
|||
"minApi": 28,
|
||||
"maxApi": 30,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/1/ananas-v0.10.1-0.14.2-libre-armeabi-v7a.dm",
|
||||
"baselineProfiles/1/ananas-v0.10.1-0.14.2-libre-x86_64.dm",
|
||||
"baselineProfiles/1/ananas-v0.10.1-0.14.2-libre-arm64-v8a.dm",
|
||||
"baselineProfiles/1/ananas-v0.10.1-0.14.2-libre-x86.dm"
|
||||
"baselineProfiles/1/ananas-v0.14.2-libre-armeabi-v7a.dm",
|
||||
"baselineProfiles/1/ananas-v0.14.2-libre-x86_64.dm",
|
||||
"baselineProfiles/1/ananas-v0.14.2-libre-x86.dm",
|
||||
"baselineProfiles/1/ananas-v0.14.2-libre-arm64-v8a.dm"
|
||||
]
|
||||
},
|
||||
{
|
||||
"minApi": 31,
|
||||
"maxApi": 2147483647,
|
||||
"baselineProfiles": [
|
||||
"baselineProfiles/0/ananas-v0.10.1-0.14.2-libre-armeabi-v7a.dm",
|
||||
"baselineProfiles/0/ananas-v0.10.1-0.14.2-libre-x86_64.dm",
|
||||
"baselineProfiles/0/ananas-v0.10.1-0.14.2-libre-arm64-v8a.dm",
|
||||
"baselineProfiles/0/ananas-v0.10.1-0.14.2-libre-x86.dm"
|
||||
"baselineProfiles/0/ananas-v0.14.2-libre-armeabi-v7a.dm",
|
||||
"baselineProfiles/0/ananas-v0.14.2-libre-x86_64.dm",
|
||||
"baselineProfiles/0/ananas-v0.14.2-libre-x86.dm",
|
||||
"baselineProfiles/0/ananas-v0.14.2-libre-arm64-v8a.dm"
|
||||
]
|
||||
}
|
||||
],
|
||||
|
|
|
@ -24,16 +24,19 @@ import android.widget.ImageView
|
|||
import android.widget.Space
|
||||
import android.widget.TextView
|
||||
import androidx.activity.viewModels
|
||||
import androidx.appcompat.app.AlertDialog
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.media3.common.C
|
||||
import androidx.media3.common.Player
|
||||
import androidx.media3.ui.DefaultTimeBar
|
||||
import androidx.media3.ui.PlayerControlView
|
||||
import androidx.media3.ui.PlayerView
|
||||
import androidx.navigation.navArgs
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import com.nomadics9.ananas.databinding.ActivityPlayerBinding
|
||||
import com.nomadics9.ananas.dialogs.SpeedSelectionDialogFragment
|
||||
import com.nomadics9.ananas.dialogs.TrackSelectionDialogFragment
|
||||
|
@ -42,17 +45,16 @@ import com.nomadics9.ananas.utils.PlayerGestureHelper
|
|||
import com.nomadics9.ananas.utils.PreviewScrubListener
|
||||
import com.nomadics9.ananas.viewmodels.PlayerActivityViewModel
|
||||
import com.nomadics9.ananas.viewmodels.PlayerEvents
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import com.nomadics9.ananas.core.R as CoreR
|
||||
import com.nomadics9.ananas.models.VideoQuality
|
||||
|
||||
var isControlsLocked: Boolean = false
|
||||
|
||||
@AndroidEntryPoint
|
||||
class PlayerActivity : BasePlayerActivity() {
|
||||
|
||||
@Inject
|
||||
lateinit var appPreferences: AppPreferences
|
||||
|
||||
|
@ -87,10 +89,12 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
|
||||
binding = ActivityPlayerBinding.inflate(layoutInflater)
|
||||
setContentView(binding.root)
|
||||
|
||||
val changeQualityButton: ImageButton = findViewById(R.id.btnChangeQuality)
|
||||
changeQualityButton.setOnClickListener {
|
||||
showQualitySelectionDialog()
|
||||
}
|
||||
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
||||
binding.playerView.player = viewModel.player
|
||||
|
@ -111,13 +115,12 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
configureInsets(lockedControls)
|
||||
|
||||
if (appPreferences.playerGestures) {
|
||||
playerGestureHelper =
|
||||
PlayerGestureHelper(
|
||||
appPreferences,
|
||||
this,
|
||||
binding.playerView,
|
||||
getSystemService(AUDIO_SERVICE) as AudioManager,
|
||||
)
|
||||
playerGestureHelper = PlayerGestureHelper(
|
||||
appPreferences,
|
||||
this,
|
||||
binding.playerView,
|
||||
getSystemService(AUDIO_SERVICE) as AudioManager,
|
||||
)
|
||||
}
|
||||
|
||||
binding.playerView.findViewById<View>(R.id.back_button).setOnClickListener {
|
||||
|
@ -152,12 +155,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
skipButton.text =
|
||||
getString(CoreR.string.skip_intro_button)
|
||||
skipButton.isVisible =
|
||||
!isInPictureInPictureMode &&
|
||||
!buttonPressed &&
|
||||
(
|
||||
showSkip == true ||
|
||||
(binding.playerView.isControllerFullyVisible && currentSegment?.skip == true)
|
||||
)
|
||||
!isInPictureInPictureMode && !buttonPressed && (showSkip == true || (binding.playerView.isControllerFullyVisible && currentSegment?.skip == true))
|
||||
watchCreditsButton.isVisible = false
|
||||
}
|
||||
|
||||
|
@ -169,10 +167,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
getString(CoreR.string.skip_credit_button_last)
|
||||
}
|
||||
skipButton.isVisible =
|
||||
!isInPictureInPictureMode &&
|
||||
!buttonPressed &&
|
||||
currentSegment?.skip == true &&
|
||||
!binding.playerView.isControllerFullyVisible
|
||||
!isInPictureInPictureMode && !buttonPressed && currentSegment?.skip == true && !binding.playerView.isControllerFullyVisible
|
||||
watchCreditsButton.isVisible = skipButton.isVisible
|
||||
}
|
||||
|
||||
|
@ -186,15 +181,12 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
when (currentSegment?.type) {
|
||||
"intro" -> {
|
||||
skipButton.isVisible =
|
||||
!buttonPressed &&
|
||||
(showSkip == true || (visibility == View.VISIBLE && currentSegment?.skip == true))
|
||||
!buttonPressed && (showSkip == true || (visibility == View.VISIBLE && currentSegment?.skip == true))
|
||||
}
|
||||
|
||||
"credit" -> {
|
||||
skipButton.isVisible =
|
||||
!buttonPressed &&
|
||||
currentSegment?.skip == true &&
|
||||
visibility == View.GONE
|
||||
!buttonPressed && currentSegment?.skip == true && visibility == View.GONE
|
||||
watchCreditsButton.isVisible = skipButton.isVisible
|
||||
}
|
||||
}
|
||||
|
@ -276,8 +268,7 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
if (appPreferences.playerPipGesture) {
|
||||
try {
|
||||
setPictureInPictureParams(pipParams(event.isPlaying))
|
||||
} catch (_: IllegalArgumentException) {
|
||||
}
|
||||
} catch (_: IllegalArgumentException) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -390,38 +381,34 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
private fun pipParams(enableAutoEnter: Boolean = viewModel.player.isPlaying): PictureInPictureParams {
|
||||
val displayAspectRatio = Rational(binding.playerView.width, binding.playerView.height)
|
||||
|
||||
val aspectRatio =
|
||||
binding.playerView.player?.videoSize?.let {
|
||||
Rational(
|
||||
it.width.coerceAtMost((it.height * 2.39f).toInt()),
|
||||
it.height.coerceAtMost((it.width * 2.39f).toInt()),
|
||||
)
|
||||
}
|
||||
val aspectRatio = binding.playerView.player?.videoSize?.let {
|
||||
Rational(
|
||||
it.width.coerceAtMost((it.height * 2.39f).toInt()),
|
||||
it.height.coerceAtMost((it.width * 2.39f).toInt()),
|
||||
)
|
||||
}
|
||||
|
||||
val sourceRectHint =
|
||||
if (displayAspectRatio < aspectRatio!!) {
|
||||
val space = ((binding.playerView.height - (binding.playerView.width.toFloat() / aspectRatio.toFloat())) / 2).toInt()
|
||||
Rect(
|
||||
0,
|
||||
space,
|
||||
binding.playerView.width,
|
||||
(binding.playerView.width.toFloat() / aspectRatio.toFloat()).toInt() + space,
|
||||
)
|
||||
} else {
|
||||
val space = ((binding.playerView.width - (binding.playerView.height.toFloat() * aspectRatio.toFloat())) / 2).toInt()
|
||||
Rect(
|
||||
space,
|
||||
0,
|
||||
(binding.playerView.height.toFloat() * aspectRatio.toFloat()).toInt() + space,
|
||||
binding.playerView.height,
|
||||
)
|
||||
}
|
||||
val sourceRectHint = if (displayAspectRatio < aspectRatio!!) {
|
||||
val space = ((binding.playerView.height - (binding.playerView.width.toFloat() / aspectRatio.toFloat())) / 2).toInt()
|
||||
Rect(
|
||||
0,
|
||||
space,
|
||||
binding.playerView.width,
|
||||
(binding.playerView.width.toFloat() / aspectRatio.toFloat()).toInt() + space,
|
||||
)
|
||||
} else {
|
||||
val space = ((binding.playerView.width - (binding.playerView.height.toFloat() * aspectRatio.toFloat())) / 2).toInt()
|
||||
Rect(
|
||||
space,
|
||||
0,
|
||||
(binding.playerView.height.toFloat() * aspectRatio.toFloat()).toInt() + space,
|
||||
binding.playerView.height,
|
||||
)
|
||||
}
|
||||
|
||||
val builder =
|
||||
PictureInPictureParams
|
||||
.Builder()
|
||||
.setAspectRatio(aspectRatio)
|
||||
.setSourceRectHint(sourceRectHint)
|
||||
val builder = PictureInPictureParams.Builder()
|
||||
.setAspectRatio(aspectRatio)
|
||||
.setSourceRectHint(sourceRectHint)
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||
builder.setAutoEnterEnabled(enableAutoEnter)
|
||||
|
@ -440,31 +427,28 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
} catch (_: IllegalArgumentException) { }
|
||||
}
|
||||
|
||||
private var selectedIndex = 1 // Default to "Original" (index 1)
|
||||
private fun showQualitySelectionDialog() {
|
||||
val originalResolution = viewModel.getOriginalResolution() ?: 0
|
||||
val qualityEntries = resources.getStringArray(CoreR.array.quality_entries).toList()
|
||||
val qualityValues = resources.getStringArray(CoreR.array.quality_values).toList()
|
||||
val height = viewModel.getOriginalHeight()
|
||||
|
||||
val qualities = qualityEntries.toMutableList()
|
||||
val closestQuality = VideoQuality.entries
|
||||
.filter { it != VideoQuality.Auto && it != VideoQuality.Original }
|
||||
.minByOrNull { kotlin.math.abs(it.height*it.width - originalResolution) }
|
||||
|
||||
if (closestQuality != null) {
|
||||
qualities[1] = "${qualities[1]} (${closestQuality})"
|
||||
val qualities = when (height) {
|
||||
0 -> arrayOf("Auto", "Original - Max", "720p - 2Mbps", "480p - 1Mbps", "360p - 800kbps")
|
||||
in 1001..1999 -> arrayOf("Auto", "Original (1080p) - Max", "720p - 2Mbps", "480p - 1Mbps", "360p - 800kbps")
|
||||
in 2000..3000 -> arrayOf("Auto", "Original (4K) - Max", "720p - 2Mbps", "480p - 1Mbps", "360p - 800kbps")
|
||||
else -> arrayOf("Auto", "Original - Max", "720p - 2Mbps", "480p - 1Mbps", "360p - 800kbps")
|
||||
}
|
||||
MaterialAlertDialogBuilder(this)
|
||||
.setTitle(CoreR.string.select_quality)
|
||||
.setSingleChoiceItems(qualities.toTypedArray(), selectedIndex) { dialog, which ->
|
||||
selectedIndex = which
|
||||
val selectedQualityValue = qualityValues[which]
|
||||
viewModel.changeVideoQuality(selectedQualityValue)
|
||||
dialog.dismiss()
|
||||
.setTitle("Select Video Quality")
|
||||
.setItems(qualities) { _, which ->
|
||||
val selectedQuality = qualities[which]
|
||||
viewModel.changeVideoQuality(selectedQuality)
|
||||
}
|
||||
.show()
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
override fun onPictureInPictureModeChanged(
|
||||
isInPictureInPictureMode: Boolean,
|
||||
newConfig: Configuration,
|
||||
|
@ -479,29 +463,25 @@ class PlayerActivity : BasePlayerActivity() {
|
|||
playerGestureHelper?.updateZoomMode(false)
|
||||
|
||||
// Brightness mode Auto
|
||||
window.attributes =
|
||||
window.attributes.apply {
|
||||
screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||
}
|
||||
window.attributes = window.attributes.apply {
|
||||
screenBrightness = WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
|
||||
}
|
||||
}
|
||||
false -> {
|
||||
binding.playerView.useController = true
|
||||
playerGestureHelper?.updateZoomMode(wasZoom)
|
||||
|
||||
// Override auto brightness
|
||||
window.attributes =
|
||||
window.attributes.apply {
|
||||
screenBrightness =
|
||||
if (appPreferences.playerBrightnessRemember) {
|
||||
appPreferences.playerBrightness
|
||||
} else {
|
||||
Settings.System
|
||||
.getInt(
|
||||
contentResolver,
|
||||
Settings.System.SCREEN_BRIGHTNESS,
|
||||
).toFloat() / 255
|
||||
}
|
||||
window.attributes = window.attributes.apply {
|
||||
screenBrightness = if (appPreferences.playerBrightnessRemember) {
|
||||
appPreferences.playerBrightness
|
||||
} else {
|
||||
Settings.System.getInt(
|
||||
contentResolver,
|
||||
Settings.System.SCREEN_BRIGHTNESS,
|
||||
).toFloat() / 255
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,7 +14,6 @@ import androidx.lifecycle.Lifecycle
|
|||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.lifecycle.repeatOnLifecycle
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import com.nomadics9.ananas.BuildConfig
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import com.nomadics9.ananas.adapters.DiscoveredServerListAdapter
|
||||
import com.nomadics9.ananas.databinding.FragmentAddServerBinding
|
||||
|
@ -90,12 +89,7 @@ class AddServerFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (BuildConfig.FLAVOR == "Ananas") {
|
||||
fun connectToServerDirectly(serverAddress: String = BuildConfig.DEFAULT_SERVER_ADDRESS) {
|
||||
viewModel.checkServer(serverAddress.removeSuffix("/"))
|
||||
}
|
||||
connectToServerDirectly()
|
||||
}
|
||||
connectToServer(DEFAULT_SERVER_ADDRESS)
|
||||
return binding.root
|
||||
}
|
||||
|
||||
|
@ -135,21 +129,18 @@ class AddServerFragment : Fragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun connectToServer() {
|
||||
val serverAddress = (binding.editTextServerAddress as AppCompatEditText).text.toString()
|
||||
viewModel.checkServer(serverAddress.removeSuffix("/"))
|
||||
}
|
||||
|
||||
|
||||
// private fun connectToServer() {
|
||||
// val serverAddress = (binding.editTextServerAddress as AppCompatEditText).text.toString()
|
||||
// if (serverAddress.isNotBlank()) {
|
||||
// viewModel.checkServer(serverAddress.removeSuffix("/"))
|
||||
// } else {
|
||||
// viewModel.checkServer(BuildConfig.DEFAULT_SERVER_ADDRESS.removeSuffix("/"))
|
||||
// }
|
||||
// viewModel.checkServer(serverAddress.removeSuffix("/"))
|
||||
// }
|
||||
|
||||
companion object {
|
||||
private const val DEFAULT_SERVER_ADDRESS = "https://askar.tv"
|
||||
}
|
||||
private fun connectToServer(serverAddress: String = DEFAULT_SERVER_ADDRESS) {
|
||||
viewModel.checkServer(serverAddress.removeSuffix("/"))
|
||||
}
|
||||
|
||||
private fun navigateToLoginFragment() {
|
||||
findNavController().navigate(AddServerFragmentDirections.actionAddServerFragmentToLoginFragment())
|
||||
}
|
||||
|
|
|
@ -172,63 +172,59 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
}else if (!appPreferences.downloadQualityDefault) {
|
||||
createPickQualityDialog()
|
||||
} else {
|
||||
startDownload()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startDownload(){
|
||||
binding.itemActions.downloadButton.setIconResource(AndroidR.color.transparent)
|
||||
binding.itemActions.progressDownload.isIndeterminate = true
|
||||
binding.itemActions.progressDownload.isVisible = true
|
||||
if (requireContext().getExternalFilesDirs(null).filterNotNull().size > 1) {
|
||||
val storageDialog = getStorageSelectionDialog(
|
||||
requireContext(),
|
||||
onItemSelected = { storageIndex ->
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex, storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return@getStorageSelectionDialog
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(storageIndex = storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
storageDialog.show()
|
||||
return
|
||||
binding.itemActions.downloadButton.setIconResource(AndroidR.color.transparent)
|
||||
binding.itemActions.progressDownload.isIndeterminate = true
|
||||
binding.itemActions.progressDownload.isVisible = true
|
||||
if (requireContext().getExternalFilesDirs(null).filterNotNull().size > 1) {
|
||||
val storageDialog = getStorageSelectionDialog(
|
||||
requireContext(),
|
||||
onItemSelected = { storageIndex ->
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex, storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return@getStorageSelectionDialog
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(storageIndex = storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
storageDialog.show()
|
||||
return
|
||||
}
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download()
|
||||
}
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download()
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
|
@ -413,8 +409,8 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
}
|
||||
|
||||
private fun createPickQualityDialog() {
|
||||
val qualityEntries = resources.getStringArray(CoreR.array.download_quality_entries)
|
||||
val qualityValues = resources.getStringArray(CoreR.array.download_quality_values)
|
||||
val qualityEntries = resources.getStringArray(com.nomadics9.ananas.core.R.array.quality_entries)
|
||||
val qualityValues = resources.getStringArray(com.nomadics9.ananas.core.R.array.quality_values)
|
||||
val quality = appPreferences.downloadQuality
|
||||
val currentQualityIndex = qualityValues.indexOf(quality)
|
||||
var selectedQuality = quality
|
||||
|
@ -428,7 +424,7 @@ class EpisodeBottomSheetFragment : BottomSheetDialogFragment() {
|
|||
builder.setPositiveButton("Download") { dialog, _ ->
|
||||
appPreferences.downloadQuality = selectedQuality
|
||||
dialog.dismiss()
|
||||
startDownload()
|
||||
handleDownload()
|
||||
}
|
||||
builder.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package com.nomadics9.ananas.fragments
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.text.Html.fromHtml
|
||||
import android.view.LayoutInflater
|
||||
|
@ -19,13 +17,11 @@ import androidx.navigation.fragment.findNavController
|
|||
import androidx.navigation.fragment.navArgs
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import com.nomadics9.ananas.AppPreferences
|
||||
import com.nomadics9.ananas.BuildConfig
|
||||
import com.nomadics9.ananas.adapters.UserLoginListAdapter
|
||||
import com.nomadics9.ananas.database.ServerDatabaseDao
|
||||
import com.nomadics9.ananas.databinding.FragmentLoginBinding
|
||||
import com.nomadics9.ananas.viewmodels.LoginEvent
|
||||
import com.nomadics9.ananas.viewmodels.LoginViewModel
|
||||
import io.noties.markwon.Markwon
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
@ -82,17 +78,6 @@ class LoginFragment : Fragment() {
|
|||
(binding.editTextPassword as AppCompatEditText).requestFocus()
|
||||
}
|
||||
|
||||
|
||||
if (BuildConfig.FLAVOR == "Ananas") {
|
||||
binding.buttonForgetPassword.setOnClickListener {
|
||||
val browserIntent = Intent(Intent.ACTION_VIEW, Uri.parse(BuildConfig.FORGET_PASSWORD_ADDRESS))
|
||||
startActivity(browserIntent)
|
||||
}
|
||||
binding.buttonForgetPassword.isVisible = true
|
||||
} else {
|
||||
binding.buttonForgetPassword.isVisible = false
|
||||
}
|
||||
|
||||
viewLifecycleOwner.lifecycleScope.launch {
|
||||
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
|
||||
viewModel.uiState.collect { uiState ->
|
||||
|
@ -158,21 +143,7 @@ class LoginFragment : Fragment() {
|
|||
binding.editTextPasswordLayout.isEnabled = true
|
||||
|
||||
uiState.disclaimer?.let { disclaimer ->
|
||||
if (BuildConfig.FLAVOR == "Ananas") {
|
||||
val lines = disclaimer.lines()
|
||||
val lineToRemoveIndex = 3
|
||||
val filteredLines = lines.toMutableList().apply {
|
||||
if (size > lineToRemoveIndex) {
|
||||
removeAt(lineToRemoveIndex)
|
||||
}
|
||||
}
|
||||
val filteredDisclaimer = filteredLines.joinToString("\n")
|
||||
val markwon = Markwon.create(requireContext())
|
||||
markwon.setMarkdown(binding.loginDisclaimer, filteredDisclaimer)
|
||||
} else {
|
||||
val markwon = Markwon.create(requireContext())
|
||||
markwon.setMarkdown(binding.loginDisclaimer, disclaimer)
|
||||
}
|
||||
binding.loginDisclaimer.text = fromHtml(disclaimer, 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -209,65 +209,61 @@ class MovieFragment : Fragment() {
|
|||
} else if (!appPreferences.downloadQualityDefault) {
|
||||
createPickQualityDialog()
|
||||
} else {
|
||||
startDownload()
|
||||
binding.itemActions.downloadButton.setIconResource(android.R.color.transparent)
|
||||
binding.itemActions.progressDownload.isIndeterminate = true
|
||||
binding.itemActions.progressDownload.isVisible = true
|
||||
if (requireContext().getExternalFilesDirs(null).filterNotNull().size > 1) {
|
||||
val storageDialog = getStorageSelectionDialog(
|
||||
requireContext(),
|
||||
onItemSelected = { storageIndex ->
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex, storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return@getStorageSelectionDialog
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(storageIndex = storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
storageDialog.show()
|
||||
return
|
||||
}
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download()
|
||||
}
|
||||
}
|
||||
|
||||
private fun startDownload() {
|
||||
binding.itemActions.downloadButton.setIconResource(android.R.color.transparent)
|
||||
binding.itemActions.progressDownload.isIndeterminate = true
|
||||
binding.itemActions.progressDownload.isVisible = true
|
||||
if (requireContext().getExternalFilesDirs(null).filterNotNull().size > 1) {
|
||||
val storageDialog = getStorageSelectionDialog(
|
||||
requireContext(),
|
||||
onItemSelected = { storageIndex ->
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex, storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return@getStorageSelectionDialog
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(storageIndex = storageIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
storageDialog.show()
|
||||
return
|
||||
}
|
||||
if (viewModel.item.sources.size > 1) {
|
||||
val dialog = getVideoVersionDialog(
|
||||
requireContext(),
|
||||
viewModel.item,
|
||||
onItemSelected = { sourceIndex ->
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download(sourceIndex)
|
||||
},
|
||||
onCancel = {
|
||||
binding.itemActions.progressDownload.isVisible = false
|
||||
binding.itemActions.downloadButton.setIconResource(CoreR.drawable.ic_download)
|
||||
},
|
||||
)
|
||||
dialog.show()
|
||||
return
|
||||
}
|
||||
createDownloadPreparingDialog()
|
||||
viewModel.download()
|
||||
}
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
|
||||
|
@ -506,8 +502,8 @@ class MovieFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun createPickQualityDialog() {
|
||||
val qualityEntries = resources.getStringArray(CoreR.array.download_quality_entries)
|
||||
val qualityValues = resources.getStringArray(CoreR.array.download_quality_values)
|
||||
val qualityEntries = resources.getStringArray(com.nomadics9.ananas.core.R.array.quality_entries)
|
||||
val qualityValues = resources.getStringArray(com.nomadics9.ananas.core.R.array.quality_values)
|
||||
val quality = appPreferences.downloadQuality
|
||||
val currentQualityIndex = qualityValues.indexOf(quality)
|
||||
var selectedQuality = quality
|
||||
|
@ -520,8 +516,8 @@ class MovieFragment : Fragment() {
|
|||
}
|
||||
builder.setPositiveButton("Download") { dialog, _ ->
|
||||
appPreferences.downloadQuality = selectedQuality
|
||||
startDownload()
|
||||
dialog.dismiss()
|
||||
handleDownload()
|
||||
}
|
||||
builder.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.webkit.WebViewClient
|
|||
import android.widget.ProgressBar
|
||||
import androidx.activity.OnBackPressedCallback
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.nomadics9.ananas.BuildConfig
|
||||
import com.nomadics9.ananas.R
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
|
@ -54,7 +53,7 @@ class RequestsWebViewFragment : Fragment() {
|
|||
}
|
||||
|
||||
// Load your URL here
|
||||
webView.loadUrl(BuildConfig.REQUEST_SERVER_ADDRESS)
|
||||
webView.loadUrl("https://r.askar.tv")
|
||||
|
||||
requireActivity().onBackPressedDispatcher.addCallback(viewLifecycleOwner, object : OnBackPressedCallback(true) {
|
||||
override fun handleOnBackPressed() {
|
||||
|
|
|
@ -226,8 +226,8 @@ class SeasonFragment : Fragment() {
|
|||
}
|
||||
|
||||
private fun createPickQualityDialog(onQualitySelected: () -> Unit) {
|
||||
val qualityEntries = resources.getStringArray(com.nomadics9.ananas.core.R.array.download_quality_entries)
|
||||
val qualityValues = resources.getStringArray(com.nomadics9.ananas.core.R.array.download_quality_values)
|
||||
val qualityEntries = resources.getStringArray(com.nomadics9.ananas.core.R.array.quality_entries)
|
||||
val qualityValues = resources.getStringArray(com.nomadics9.ananas.core.R.array.quality_values)
|
||||
val quality = appPreferences.downloadQuality
|
||||
val currentQualityIndex = qualityValues.indexOf(quality)
|
||||
|
||||
|
@ -240,8 +240,8 @@ class SeasonFragment : Fragment() {
|
|||
}
|
||||
builder.setPositiveButton("Download") { dialog, _ ->
|
||||
appPreferences.downloadQuality = selectedQuality
|
||||
onQualitySelected()
|
||||
dialog.dismiss()
|
||||
onQualitySelected()
|
||||
}
|
||||
builder.setNegativeButton("Cancel") { dialog, _ ->
|
||||
dialog.dismiss()
|
||||
|
|
|
@ -3,23 +3,12 @@ package com.nomadics9.ananas.fragments
|
|||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.navigation.fragment.findNavController
|
||||
import androidx.preference.Preference
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.nomadics9.ananas.AppPreferences
|
||||
import com.nomadics9.ananas.BuildConfig
|
||||
import com.nomadics9.ananas.utils.restart
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import timber.log.Timber
|
||||
import java.net.HttpURLConnection
|
||||
import java.net.URL
|
||||
import java.text.SimpleDateFormat
|
||||
import java.util.*
|
||||
import com.nomadics9.ananas.AppPreferences
|
||||
import com.nomadics9.ananas.utils.restart
|
||||
import javax.inject.Inject
|
||||
import com.nomadics9.ananas.core.R as CoreR
|
||||
|
||||
|
@ -28,10 +17,6 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
@Inject
|
||||
lateinit var appPreferences: AppPreferences
|
||||
|
||||
private val updateUrl = BuildConfig.UPDATE_ADDRESS
|
||||
private var isUpdateAvailable: Boolean = false
|
||||
private var newLastModifiedDate: Date? = null
|
||||
|
||||
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||
setPreferencesFromResource(CoreR.xml.fragment_settings, rootKey)
|
||||
|
||||
|
@ -42,21 +27,13 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
|
||||
findPreference<Preference>("switchUser")?.setOnPreferenceClickListener {
|
||||
val serverId = appPreferences.currentServer!!
|
||||
findNavController().navigate(
|
||||
TwoPaneSettingsFragmentDirections.actionNavigationSettingsToUsersFragment(
|
||||
serverId
|
||||
)
|
||||
)
|
||||
findNavController().navigate(TwoPaneSettingsFragmentDirections.actionNavigationSettingsToUsersFragment(serverId))
|
||||
true
|
||||
}
|
||||
|
||||
findPreference<Preference>("switchAddress")?.setOnPreferenceClickListener {
|
||||
val serverId = appPreferences.currentServer!!
|
||||
findNavController().navigate(
|
||||
TwoPaneSettingsFragmentDirections.actionNavigationSettingsToServerAddressesFragment(
|
||||
serverId
|
||||
)
|
||||
)
|
||||
findNavController().navigate(TwoPaneSettingsFragmentDirections.actionNavigationSettingsToServerAddressesFragment(serverId))
|
||||
true
|
||||
}
|
||||
|
||||
|
@ -74,102 +51,14 @@ class SettingsFragment : PreferenceFragmentCompat() {
|
|||
true
|
||||
}
|
||||
|
||||
|
||||
findPreference<Preference>("appInfo")?.setOnPreferenceClickListener {
|
||||
if (isUpdateAvailable && newLastModifiedDate != null) {
|
||||
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(updateUrl))
|
||||
startActivity(intent)
|
||||
storeDate(newLastModifiedDate!!)
|
||||
true
|
||||
} else {
|
||||
findNavController().navigate(TwoPaneSettingsFragmentDirections.actionSettingsFragmentToAboutLibraries())
|
||||
false
|
||||
}
|
||||
findNavController().navigate(TwoPaneSettingsFragmentDirections.actionSettingsFragmentToAboutLibraries())
|
||||
true
|
||||
}
|
||||
|
||||
findPreference<Preference>("requests")?.setOnPreferenceClickListener {
|
||||
findNavController().navigate(TwoPaneSettingsFragmentDirections.actionNavigationSettingsToRequestsWebFragment())
|
||||
true
|
||||
}
|
||||
|
||||
// Check for updates when the settings screen is opened
|
||||
checkForUpdates()
|
||||
}
|
||||
|
||||
private fun checkForUpdates() {
|
||||
lifecycleScope.launch {
|
||||
val lastModifiedDate = fetchLastModifiedDate(updateUrl)
|
||||
if (lastModifiedDate != null) {
|
||||
Timber.d("Fetched Last-Modified date: $lastModifiedDate")
|
||||
val storedDate = getStoredDate()
|
||||
Timber.d("Stored date: $storedDate")
|
||||
if (storedDate == Date(0L) || lastModifiedDate.after(storedDate)) {
|
||||
Timber.d("Update available")
|
||||
isUpdateAvailable = true
|
||||
newLastModifiedDate = lastModifiedDate
|
||||
showUpdateAvailable()
|
||||
} else {
|
||||
Timber.d("No update available")
|
||||
isUpdateAvailable = false
|
||||
}
|
||||
} else {
|
||||
Timber.d("Failed to fetch Last-Modified date")
|
||||
isUpdateAvailable = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun fetchLastModifiedDate(urlString: String): Date? {
|
||||
return withContext(Dispatchers.IO) {
|
||||
var urlConnection: HttpURLConnection? = null
|
||||
try {
|
||||
val url = URL(urlString)
|
||||
urlConnection = url.openConnection() as HttpURLConnection
|
||||
urlConnection.requestMethod = "HEAD"
|
||||
val lastModified = urlConnection.getHeaderField("Last-Modified")
|
||||
if (lastModified != null) {
|
||||
val dateFormat = SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z", Locale.US)
|
||||
dateFormat.parse(lastModified)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Error fetching Last-Modified date")
|
||||
null
|
||||
} finally {
|
||||
urlConnection?.disconnect()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getStoredDate(): Date {
|
||||
val sharedPreferences = preferenceManager.sharedPreferences
|
||||
val storedDateString = sharedPreferences?.getString("stored_date", null)
|
||||
Timber.d("Retrieved stored date string: $storedDateString")
|
||||
return if (storedDateString != null) {
|
||||
try {
|
||||
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US).parse(storedDateString) ?: Date(0)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e, "Error parsing stored date string")
|
||||
Date(0)
|
||||
}
|
||||
} else {
|
||||
Date(0)
|
||||
}
|
||||
}
|
||||
|
||||
private fun storeDate(date: Date) {
|
||||
val dateString = SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US).format(date)
|
||||
preferenceManager.sharedPreferences?.edit()?.putString("stored_date", dateString)?.apply()
|
||||
Timber.d("Stored new date: $dateString")
|
||||
}
|
||||
|
||||
private fun showUpdateAvailable() {
|
||||
val appInfoPreference = findPreference<Preference>("appInfo")
|
||||
appInfoPreference?.let {
|
||||
it.summary = "Update available!"
|
||||
it.icon = ResourcesCompat.getDrawable(resources, CoreR.drawable.ic_download, null) // Ensure this drawable exists
|
||||
Timber.d("Update available UI shown")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -73,7 +73,6 @@
|
|||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<!--TODO: Content Desc to Strings-->
|
||||
<ImageButton
|
||||
android:id="@+id/btnChangeQuality"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -81,7 +80,7 @@
|
|||
android:background="@drawable/transparent_circle_background"
|
||||
android:contentDescription="Quality"
|
||||
android:padding="16dp"
|
||||
android:src="@drawable/ic_monitor_play"
|
||||
android:src="@drawable/ic_quality"
|
||||
android:layout_gravity="end"
|
||||
app:tint="@android:color/white"
|
||||
/>
|
||||
|
|
|
@ -141,24 +141,10 @@
|
|||
android:visibility="invisible" />
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginHorizontal="24dp">
|
||||
|
||||
<Button
|
||||
android:id="@+id/button_forget_password"
|
||||
style="@style/Widget.Material3.Button.OutlinedButton"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/forget_password" />
|
||||
</RelativeLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/login_disclaimer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:gravity="center"
|
||||
android:layout_marginHorizontal="24dp"
|
||||
android:layout_margin="24dp"
|
||||
android:textSize="16sp"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import org.gradle.api.JavaVersion
|
||||
|
||||
object Versions {
|
||||
const val appCode = 16
|
||||
const val appName = "0.10.6-0.14.2"
|
||||
const val appCode = 9
|
||||
const val appName = "0.14.2"
|
||||
|
||||
const val compileSdk = 34
|
||||
const val buildTools = "34.0.0"
|
||||
|
@ -12,4 +12,4 @@ object Versions {
|
|||
val java = JavaVersion.VERSION_17
|
||||
|
||||
const val ktlint = "0.50.0"
|
||||
}
|
||||
}
|
|
@ -30,7 +30,6 @@ android {
|
|||
flavorDimensions += "variant"
|
||||
productFlavors {
|
||||
register("libre")
|
||||
create("Ananas")
|
||||
}
|
||||
|
||||
compileOptions {
|
||||
|
|
|
@ -6,8 +6,10 @@ import android.net.Uri
|
|||
import android.os.Environment
|
||||
import android.os.StatFs
|
||||
import android.text.format.Formatter
|
||||
import androidx.core.net.toFile
|
||||
import androidx.core.net.toUri
|
||||
import com.nomadics9.ananas.AppPreferences
|
||||
import com.nomadics9.ananas.api.JellyfinApi
|
||||
import com.nomadics9.ananas.database.ServerDatabaseDao
|
||||
import com.nomadics9.ananas.models.FindroidEpisode
|
||||
import com.nomadics9.ananas.models.FindroidItem
|
||||
|
@ -17,7 +19,6 @@ import com.nomadics9.ananas.models.FindroidSource
|
|||
import com.nomadics9.ananas.models.FindroidSources
|
||||
import com.nomadics9.ananas.models.FindroidTrickplayInfo
|
||||
import com.nomadics9.ananas.models.UiText
|
||||
import com.nomadics9.ananas.models.VideoQuality
|
||||
import com.nomadics9.ananas.models.toFindroidEpisodeDto
|
||||
import com.nomadics9.ananas.models.toFindroidMediaStreamDto
|
||||
import com.nomadics9.ananas.models.toFindroidMovieDto
|
||||
|
@ -28,10 +29,34 @@ import com.nomadics9.ananas.models.toFindroidSourceDto
|
|||
import com.nomadics9.ananas.models.toFindroidTrickplayInfoDto
|
||||
import com.nomadics9.ananas.models.toFindroidUserDataDto
|
||||
import com.nomadics9.ananas.repository.JellyfinRepository
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jellyfin.sdk.api.client.extensions.dynamicHlsApi
|
||||
import org.jellyfin.sdk.api.client.extensions.videosApi
|
||||
import org.jellyfin.sdk.model.api.ClientCapabilitiesDto
|
||||
import org.jellyfin.sdk.model.api.DeviceProfile
|
||||
import org.jellyfin.sdk.model.api.DirectPlayProfile
|
||||
import org.jellyfin.sdk.model.api.DlnaProfileType
|
||||
import org.jellyfin.sdk.model.api.EncodingContext
|
||||
import org.jellyfin.sdk.model.api.MediaStreamType
|
||||
import org.jellyfin.sdk.model.api.MediaStreamProtocol
|
||||
import org.jellyfin.sdk.model.api.PlaybackInfoDto
|
||||
import org.jellyfin.sdk.model.api.ProfileCondition
|
||||
import org.jellyfin.sdk.model.api.ProfileConditionType
|
||||
import org.jellyfin.sdk.model.api.ProfileConditionValue
|
||||
import org.jellyfin.sdk.model.api.SubtitleDeliveryMethod
|
||||
import org.jellyfin.sdk.model.api.SubtitleProfile
|
||||
import org.jellyfin.sdk.model.api.TranscodeSeekInfo
|
||||
import org.jellyfin.sdk.model.api.TranscodingProfile
|
||||
import timber.log.Timber
|
||||
import java.io.File
|
||||
import java.io.FileOutputStream
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.io.OutputStream
|
||||
import java.net.URL
|
||||
import java.util.UUID
|
||||
import kotlin.Exception
|
||||
import kotlin.math.ceil
|
||||
|
@ -51,17 +76,17 @@ class DownloaderImpl(
|
|||
storageIndex: Int,
|
||||
): Pair<Long, UiText?> {
|
||||
try {
|
||||
|
||||
Timber.d("Downloading item: ${item.id} with sourceId: $sourceId")
|
||||
|
||||
val source =
|
||||
jellyfinRepository.getMediaSources(item.id, true).first { it.id == sourceId }
|
||||
val segments = jellyfinRepository.getSegmentsTimestamps(item.id)
|
||||
val trickplayInfo =
|
||||
if (item is FindroidSources) {
|
||||
item.trickplayInfo?.get(sourceId)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val trickplayInfo = if (item is FindroidSources) {
|
||||
item.trickplayInfo?.get(sourceId)
|
||||
} else {
|
||||
null
|
||||
}
|
||||
val storageLocation = context.getExternalFilesDirs(null)[storageIndex]
|
||||
if (storageLocation == null || Environment.getExternalStorageState(storageLocation) != Environment.MEDIA_MOUNTED) {
|
||||
return Pair(-1, UiText.StringResource(CoreR.string.storage_unavailable))
|
||||
|
@ -79,8 +104,15 @@ class DownloaderImpl(
|
|||
),
|
||||
)
|
||||
}
|
||||
handleDownload(item, source, storageIndex, trickplayInfo, segments, path)
|
||||
return Pair(-1, null)
|
||||
val qualityPreference = appPreferences.downloadQuality!!
|
||||
Timber.d("Quality preference: $qualityPreference")
|
||||
return if (qualityPreference != "Original") {
|
||||
Timber.d("Handling Transcoding download for item: ${item.id}")
|
||||
handleTranscodeDownload(item, source, storageIndex, trickplayInfo, segments, path, qualityPreference)
|
||||
} else {
|
||||
Timber.d("Handling original download for item: ${item.id}")
|
||||
downloadOriginalItem(item, source, storageIndex, trickplayInfo, segments, path)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
try {
|
||||
val source = jellyfinRepository.getMediaSources(item.id).first { it.id == sourceId }
|
||||
|
@ -90,18 +122,79 @@ class DownloaderImpl(
|
|||
|
||||
return Pair(
|
||||
-1,
|
||||
if (e.message != null) {
|
||||
UiText.DynamicString(e.message!!)
|
||||
} else {
|
||||
UiText.StringResource(
|
||||
CoreR.string.unknown_error,
|
||||
)
|
||||
},
|
||||
if (e.message != null) UiText.DynamicString(e.message!!) else UiText.StringResource(
|
||||
CoreR.string.unknown_error
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun handleDownload(
|
||||
private suspend fun handleTranscodeDownload(
|
||||
item: FindroidItem,
|
||||
source: FindroidSource,
|
||||
storageIndex: Int,
|
||||
trickplayInfo: FindroidTrickplayInfo?,
|
||||
segments: List<FindroidSegment>?,
|
||||
path: Uri,
|
||||
quality: String
|
||||
): Pair<Long, UiText?> {
|
||||
val transcodingUrl = getTranscodedUrl(item.id, quality)
|
||||
when (item) {
|
||||
is FindroidMovie -> {
|
||||
database.insertMovie(item.toFindroidMovieDto(appPreferences.currentServer!!))
|
||||
database.insertSource(source.toFindroidSourceDto(item.id, path.path.orEmpty()))
|
||||
database.insertUserData(item.toFindroidUserDataDto(jellyfinRepository.getUserId()))
|
||||
downloadExternalMediaStreams(item, source, storageIndex)
|
||||
if (trickplayInfo != null) {
|
||||
downloadTrickplayData(item.id, source.id, trickplayInfo)
|
||||
}
|
||||
if (segments != null) {
|
||||
database.insertSegments(segments.toFindroidSegmentsDto(item.id))
|
||||
}
|
||||
val request = DownloadManager.Request(transcodingUrl)
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
}
|
||||
|
||||
is FindroidEpisode -> {
|
||||
database.insertShow(
|
||||
jellyfinRepository.getShow(item.seriesId)
|
||||
.toFindroidShowDto(appPreferences.currentServer!!),
|
||||
)
|
||||
database.insertSeason(
|
||||
jellyfinRepository.getSeason(item.seasonId).toFindroidSeasonDto(),
|
||||
)
|
||||
database.insertEpisode(item.toFindroidEpisodeDto(appPreferences.currentServer!!))
|
||||
database.insertSource(source.toFindroidSourceDto(item.id, path.path.orEmpty()))
|
||||
database.insertUserData(item.toFindroidUserDataDto(jellyfinRepository.getUserId()))
|
||||
downloadExternalMediaStreams(item, source, storageIndex)
|
||||
if (trickplayInfo != null) {
|
||||
downloadTrickplayData(item.id, source.id, trickplayInfo)
|
||||
}
|
||||
if (segments != null) {
|
||||
database.insertSegments(segments.toFindroidSegmentsDto(item.id))
|
||||
}
|
||||
val request = DownloadManager.Request(transcodingUrl)
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
}
|
||||
}
|
||||
return Pair(-1, null)
|
||||
}
|
||||
|
||||
private suspend fun downloadOriginalItem(
|
||||
item: FindroidItem,
|
||||
source: FindroidSource,
|
||||
storageIndex: Int,
|
||||
|
@ -121,40 +214,20 @@ class DownloaderImpl(
|
|||
if (segments != null) {
|
||||
database.insertSegments(segments.toFindroidSegmentsDto(item.id))
|
||||
}
|
||||
if (appPreferences.downloadQuality != VideoQuality.Original.toString()) {
|
||||
downloadEmbeddedMediaStreams(item, source, storageIndex)
|
||||
val transcodingUrl =
|
||||
getTranscodedUrl(item.id, appPreferences.downloadQuality!!)
|
||||
val request =
|
||||
DownloadManager
|
||||
.Request(transcodingUrl)
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
} else {
|
||||
val request =
|
||||
DownloadManager
|
||||
.Request(source.path.toUri())
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
}
|
||||
val request = DownloadManager.Request(source.path.toUri())
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
}
|
||||
|
||||
is FindroidEpisode -> {
|
||||
database.insertShow(
|
||||
jellyfinRepository
|
||||
.getShow(item.seriesId)
|
||||
jellyfinRepository.getShow(item.seriesId)
|
||||
.toFindroidShowDto(appPreferences.currentServer!!),
|
||||
)
|
||||
database.insertSeason(
|
||||
|
@ -170,53 +243,29 @@ class DownloaderImpl(
|
|||
if (segments != null) {
|
||||
database.insertSegments(segments.toFindroidSegmentsDto(item.id))
|
||||
}
|
||||
if (appPreferences.downloadQuality != VideoQuality.Original.toString()) {
|
||||
downloadEmbeddedMediaStreams(item, source, storageIndex)
|
||||
val transcodingUrl =
|
||||
getTranscodedUrl(item.id, appPreferences.downloadQuality!!)
|
||||
val request =
|
||||
DownloadManager
|
||||
.Request(transcodingUrl)
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
} else {
|
||||
val request =
|
||||
DownloadManager
|
||||
.Request(source.path.toUri())
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
}
|
||||
val request = DownloadManager.Request(source.path.toUri())
|
||||
.setTitle(item.name)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED)
|
||||
.setDestinationUri(path)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setSourceDownloadId(source.id, downloadId)
|
||||
return Pair(downloadId, null)
|
||||
}
|
||||
}
|
||||
return Pair(-1, null)
|
||||
}
|
||||
|
||||
override suspend fun cancelDownload(
|
||||
item: FindroidItem,
|
||||
source: FindroidSource,
|
||||
) {
|
||||
|
||||
override suspend fun cancelDownload(item: FindroidItem, source: FindroidSource) {
|
||||
if (source.downloadId != null) {
|
||||
downloadManager.remove(source.downloadId!!)
|
||||
}
|
||||
deleteItem(item, source)
|
||||
}
|
||||
|
||||
override suspend fun deleteItem(
|
||||
item: FindroidItem,
|
||||
source: FindroidSource,
|
||||
) {
|
||||
override suspend fun deleteItem(item: FindroidItem, source: FindroidSource) {
|
||||
when (item) {
|
||||
is FindroidMovie -> {
|
||||
database.deleteMovie(item.id)
|
||||
|
@ -258,18 +307,15 @@ class DownloaderImpl(
|
|||
if (downloadId == null) {
|
||||
return Pair(downloadStatus, progress)
|
||||
}
|
||||
val query =
|
||||
DownloadManager
|
||||
.Query()
|
||||
.setFilterById(downloadId)
|
||||
val query = DownloadManager.Query()
|
||||
.setFilterById(downloadId)
|
||||
val cursor = downloadManager.query(query)
|
||||
if (cursor.moveToFirst()) {
|
||||
downloadStatus =
|
||||
cursor.getInt(
|
||||
cursor.getColumnIndexOrThrow(
|
||||
DownloadManager.COLUMN_STATUS,
|
||||
),
|
||||
)
|
||||
downloadStatus = cursor.getInt(
|
||||
cursor.getColumnIndexOrThrow(
|
||||
DownloadManager.COLUMN_STATUS,
|
||||
),
|
||||
)
|
||||
when (downloadStatus) {
|
||||
DownloadManager.STATUS_RUNNING -> {
|
||||
val totalBytes =
|
||||
|
@ -298,69 +344,25 @@ class DownloaderImpl(
|
|||
val storageLocation = context.getExternalFilesDirs(null)[storageIndex]
|
||||
for (mediaStream in source.mediaStreams.filter { it.isExternal }) {
|
||||
val id = UUID.randomUUID()
|
||||
val streamPath =
|
||||
Uri.fromFile(
|
||||
File(
|
||||
storageLocation,
|
||||
"downloads/${item.id}.${source.id}.$id.download",
|
||||
),
|
||||
val streamPath = Uri.fromFile(
|
||||
File(
|
||||
storageLocation,
|
||||
"downloads/${item.id}.${source.id}.$id.download"
|
||||
)
|
||||
)
|
||||
database.insertMediaStream(
|
||||
mediaStream.toFindroidMediaStreamDto(
|
||||
id,
|
||||
source.id,
|
||||
streamPath.path.orEmpty(),
|
||||
),
|
||||
)
|
||||
val request =
|
||||
DownloadManager
|
||||
.Request(Uri.parse(mediaStream.path))
|
||||
.setTitle(mediaStream.title)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
|
||||
.setDestinationUri(streamPath)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setMediaStreamDownloadId(id, downloadId)
|
||||
}
|
||||
}
|
||||
|
||||
private fun downloadEmbeddedMediaStreams(
|
||||
item: FindroidItem,
|
||||
source: FindroidSource,
|
||||
storageIndex: Int = 0,
|
||||
) {
|
||||
val storageLocation = context.getExternalFilesDirs(null)[storageIndex]
|
||||
val subtitleStreams = source.mediaStreams.filter { !it.isExternal && it.type == MediaStreamType.SUBTITLE && it.path != null }
|
||||
for (mediaStream in subtitleStreams) {
|
||||
var deliveryUrl = mediaStream.path!!
|
||||
if (mediaStream.codec == "webvtt") {
|
||||
deliveryUrl = deliveryUrl.replace("Stream.srt", "Stream.vtt")
|
||||
}
|
||||
val id = UUID.randomUUID()
|
||||
val streamPath =
|
||||
Uri.fromFile(
|
||||
File(
|
||||
storageLocation,
|
||||
"downloads/${item.id}.${source.id}.$id.download",
|
||||
),
|
||||
streamPath.path.orEmpty()
|
||||
)
|
||||
database.insertMediaStream(
|
||||
mediaStream.toFindroidMediaStreamDto(
|
||||
id,
|
||||
source.id,
|
||||
streamPath.path.orEmpty(),
|
||||
),
|
||||
)
|
||||
val request =
|
||||
DownloadManager
|
||||
.Request(Uri.parse(deliveryUrl))
|
||||
.setTitle(mediaStream.title)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
|
||||
.setDestinationUri(streamPath)
|
||||
|
||||
val request = DownloadManager.Request(Uri.parse(mediaStream.path))
|
||||
.setTitle(mediaStream.title)
|
||||
.setAllowedOverMetered(appPreferences.downloadOverMobileData)
|
||||
.setAllowedOverRoaming(appPreferences.downloadWhenRoaming)
|
||||
.setNotificationVisibility(DownloadManager.Request.VISIBILITY_HIDDEN)
|
||||
.setDestinationUri(streamPath)
|
||||
val downloadId = downloadManager.enqueue(request)
|
||||
database.setMediaStreamDownloadId(id, downloadId)
|
||||
}
|
||||
|
@ -371,22 +373,19 @@ class DownloaderImpl(
|
|||
sourceId: String,
|
||||
trickplayInfo: FindroidTrickplayInfo,
|
||||
) {
|
||||
val maxIndex =
|
||||
ceil(
|
||||
trickplayInfo.thumbnailCount
|
||||
.toDouble()
|
||||
.div(trickplayInfo.tileWidth * trickplayInfo.tileHeight),
|
||||
).toInt()
|
||||
val maxIndex = ceil(
|
||||
trickplayInfo.thumbnailCount.toDouble()
|
||||
.div(trickplayInfo.tileWidth * trickplayInfo.tileHeight)
|
||||
).toInt()
|
||||
val byteArrays = mutableListOf<ByteArray>()
|
||||
for (i in 0..maxIndex) {
|
||||
jellyfinRepository
|
||||
.getTrickplayData(
|
||||
itemId,
|
||||
trickplayInfo.width,
|
||||
i,
|
||||
)?.let { byteArray ->
|
||||
byteArrays.add(byteArray)
|
||||
}
|
||||
jellyfinRepository.getTrickplayData(
|
||||
itemId,
|
||||
trickplayInfo.width,
|
||||
i,
|
||||
)?.let { byteArray ->
|
||||
byteArrays.add(byteArray)
|
||||
}
|
||||
}
|
||||
saveTrickplayData(itemId, sourceId, trickplayInfo, byteArrays)
|
||||
}
|
||||
|
@ -406,46 +405,51 @@ class DownloaderImpl(
|
|||
}
|
||||
}
|
||||
|
||||
private suspend fun getTranscodedUrl(
|
||||
itemId: UUID,
|
||||
quality: String,
|
||||
): Uri? {
|
||||
val videoQuality = VideoQuality.fromString(quality)!!
|
||||
return try {
|
||||
val deviceProfile =
|
||||
jellyfinRepository.buildDeviceProfile(
|
||||
VideoQuality.getBitrate(videoQuality),
|
||||
"mkv",
|
||||
EncodingContext.STATIC,
|
||||
)
|
||||
val playbackInfo =
|
||||
jellyfinRepository.getPostedPlaybackInfo(
|
||||
itemId,
|
||||
false,
|
||||
deviceProfile,
|
||||
VideoQuality.getBitrate(videoQuality),
|
||||
)
|
||||
val mediaSourceId =
|
||||
playbackInfo.content.mediaSources
|
||||
.firstOrNull()
|
||||
?.id!!
|
||||
val playSessionId = playbackInfo.content.playSessionId!!
|
||||
val deviceId = jellyfinRepository.getDeviceId()
|
||||
val downloadUrl =
|
||||
jellyfinRepository.getVideoStreambyContainerUrl(
|
||||
itemId,
|
||||
deviceId,
|
||||
mediaSourceId,
|
||||
playSessionId,
|
||||
VideoQuality.getBitrate(videoQuality),
|
||||
"mkv",
|
||||
VideoQuality.getHeight(videoQuality),
|
||||
)
|
||||
private suspend fun getTranscodedUrl(itemId: UUID, quality: String): Uri? {
|
||||
val maxBitrate = when (quality) {
|
||||
"720p" -> 2000000 // 2 Mbps
|
||||
"480p" -> 1000000 // 1 Mbps
|
||||
"360p" -> 800000 // 800Kbps
|
||||
else -> 2000000 // Default to 2 Mbps if not specified
|
||||
}
|
||||
|
||||
return downloadUrl.toUri()
|
||||
return try {
|
||||
|
||||
val deviceProfile = jellyfinRepository.buildDeviceProfile(maxBitrate,"mkv", EncodingContext.STATIC)
|
||||
val playbackInfo = jellyfinRepository.getPostedPlaybackInfo(itemId,false,deviceProfile,maxBitrate)
|
||||
val mediaSourceId = playbackInfo.content.mediaSources.firstOrNull()?.id!!
|
||||
val playSessionId = playbackInfo.content.playSessionId!!
|
||||
val downloadUrl = jellyfinRepository.getVideoStreambyContainerUrl(itemId, mediaSourceId, playSessionId, maxBitrate, "ts")
|
||||
|
||||
val transcodeUri = buildTranscodeUri(downloadUrl, maxBitrate, quality)
|
||||
Timber.d("Constructed Transcode URL: $transcodeUri")
|
||||
transcodeUri
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
private fun buildTranscodeUri(
|
||||
transcodingUrl: String,
|
||||
maxBitrate: Int,
|
||||
quality: String
|
||||
): Uri {
|
||||
val resolution = when (quality) {
|
||||
"720p" -> "720"
|
||||
"480p" -> "480"
|
||||
"360p" -> "360"
|
||||
else -> "720"
|
||||
}
|
||||
return Uri.parse(transcodingUrl).buildUpon()
|
||||
.appendQueryParameter("MaxVideoHeight", resolution)
|
||||
.appendQueryParameter("MaxVideoBitRate", maxBitrate.toString())
|
||||
.appendQueryParameter("subtitleMethod", "External")
|
||||
//.appendQueryParameter("api_key", apiKey)
|
||||
.build()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24"
|
||||
android:tint="?attr/colorControlNormal">
|
||||
<path
|
||||
android:pathData="M10,7.75a0.75,0.75 0,0 1,1.142 -0.638l3.664,2.249a0.75,0.75 0,0 1,0 1.278l-3.664,2.25a0.75,0.75 0,0 1,-1.142 -0.64z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M12,17v4"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M8,21h8"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeLineCap="round"/>
|
||||
<path
|
||||
android:pathData="M4,3L20,3A2,2 0,0 1,22 5L22,15A2,2 0,0 1,20 17L4,17A2,2 0,0 1,2 15L2,5A2,2 0,0 1,4 3z"
|
||||
android:strokeLineJoin="round"
|
||||
android:strokeWidth="2"
|
||||
android:fillColor="#00000000"
|
||||
android:strokeColor="@android:color/white"
|
||||
android:strokeLineCap="round"/>
|
||||
</vector>
|
|
@ -1,20 +1,2 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="add_server_error_outdated">اصدار الخادم قديم: %1$s. الرجاء تحديث الخادم</string>
|
||||
<string name="add_server_error_not_jellyfin">ليس خادم جيلي فن:%1$s</string>
|
||||
<string name="add_server_error_version">اصدار الخادم غير مدعوم: %1$s. الرجاء تحديث الخادم</string>
|
||||
<string name="add_server_error_slow">رد الخادم بطيء: %1$s</string>
|
||||
<string name="login">تسجيل دخول</string>
|
||||
<string name="login_error_wrong_username_password">اسم المستخدم او الكلمه السريه غير صحيحه</string>
|
||||
<string name="select_server">اختر الخادم</string>
|
||||
<string name="edit_text_server_address_hint">عنوان الخادم</string>
|
||||
<string name="edit_text_username_hint">اسم المستخدم</string>
|
||||
<string name="edit_text_password_hint">الكلمه السريه</string>
|
||||
<string name="button_connect">اتصل</string>
|
||||
<string name="button_login">تسجيل دخول</string>
|
||||
<string name="remove_server">حذف الخادم</string>
|
||||
<string name="add_server">اضافه خادم</string>
|
||||
<string name="add_server_error_not_found">الخادم غير موجود</string>
|
||||
<string name="add_server_error_empty_address">عنوان الخادم فاضي</string>
|
||||
<string name="add_server_error_no_id">الخادم غير معرف بالid , يبدو انه هناك خلل في الخادم</string>
|
||||
</resources>
|
||||
<resources></resources>
|
|
@ -26,37 +26,15 @@
|
|||
<item>opensles</item>
|
||||
</string-array>
|
||||
<string-array name="quality_entries">
|
||||
<item>@string/quality_auto</item>
|
||||
<item>@string/quality_original</item>
|
||||
<item>@string/quality_1080p</item>
|
||||
<item>@string/quality_720p</item>
|
||||
<item>@string/quality_480p</item>
|
||||
<item>@string/quality_360p</item>
|
||||
<item>Original</item>
|
||||
<item>720p - 2Mbps</item>
|
||||
<item>480p - 1Mbps</item>
|
||||
<item>360p - 800Kbps</item>
|
||||
</string-array>
|
||||
<string-array name="quality_values">
|
||||
<item>Auto</item>
|
||||
<item>Original</item>
|
||||
<item>1080p</item>
|
||||
<item>720p</item>
|
||||
<item>480p</item>
|
||||
<item>360p</item>
|
||||
</string-array>
|
||||
<string-array name="download_quality_entries">
|
||||
<item>@string/quality_original</item>
|
||||
<item>@string/quality_1080p</item>
|
||||
<item>@string/quality_720p</item>
|
||||
<item>@string/quality_480p</item>
|
||||
<item>@string/quality_360p</item>
|
||||
</string-array>
|
||||
<string-array name="download_quality_values">
|
||||
<item>Original</item>
|
||||
<item>1080p</item>
|
||||
<item>720p</item>
|
||||
<item>480p</item>
|
||||
<item>360p</item>
|
||||
</string-array>
|
||||
<string-array name="codecs">
|
||||
<item>h264</item>
|
||||
<item>hevc</item>
|
||||
</string-array>
|
||||
</resources>
|
|
@ -11,7 +11,6 @@
|
|||
<string name="add_server_error_not_found">Server not found</string>
|
||||
<string name="add_server_error_no_id">Server has no id, something seems to be wrong with the server</string>
|
||||
<string name="login">Login</string>
|
||||
<string name="forget_password">Forget Password?</string>
|
||||
<string name="login_error_wrong_username_password">Wrong username or password</string>
|
||||
<string name="select_server">Select server</string>
|
||||
<string name="edit_text_server_address_hint">Server address</string>
|
||||
|
@ -140,7 +139,6 @@
|
|||
<string name="settings_request_timeout">Request timeout (ms)</string>
|
||||
<string name="settings_connect_timeout">Connect timeout (ms)</string>
|
||||
<string name="settings_socket_timeout">Socket timeout (ms)</string>
|
||||
<string name="settings_quality_codec">Transcoding codec</string>
|
||||
<string name="users">Users</string>
|
||||
<string name="add_user">Add user</string>
|
||||
<string name="pref_player_mpv_hwdec">Hardware decoding</string>
|
||||
|
@ -195,15 +193,6 @@
|
|||
<string name="unmark_as_played">Unmark as played</string>
|
||||
<string name="add_to_favorites">Add to favorites</string>
|
||||
<string name="remove_from_favorites">Remove from favorites</string>
|
||||
<string name="quality_default">Default to selected download quality</string>
|
||||
<string name="download_quality">Download Quality</string>
|
||||
<string name="select_quality">Select Video Quality</string>
|
||||
<string name="quality_auto">Auto</string>
|
||||
<string name="quality_original">Original</string>
|
||||
<string name="quality_1080p">1080p - 8Mbps</string>
|
||||
<string name="quality_720p">720p - 3Mbps</string>
|
||||
<string name="quality_480p">480p - 1.5Mbps</string>
|
||||
<string name="quality_360p">360p - 0.8Mbps</string>
|
||||
<string name="alaskarTV_requests">AlaskarTV Requests</string>
|
||||
<string name="pref_player_trickplay_gesture">Trick Play in seek gesture</string>
|
||||
<string name="pref_player_trickplay_gesture_summary">Requires \'Seek gesture\' and \'Trick Play\'</string>
|
||||
|
|
|
@ -75,8 +75,7 @@
|
|||
<Preference
|
||||
app:key="appInfo"
|
||||
app:icon="@drawable/ic_logo"
|
||||
app:title="@string/app_info"
|
||||
app:summary="" />
|
||||
app:title="@string/app_info" />
|
||||
|
||||
|
||||
</PreferenceCategory>
|
||||
|
|
|
@ -11,13 +11,15 @@
|
|||
app:title="@string/download_roaming" />
|
||||
<ListPreference
|
||||
android:key="pref_downloads_quality"
|
||||
android:title="@string/download_quality"
|
||||
android:defaultValue="@string/quality_original"
|
||||
android:entries="@array/download_quality_entries"
|
||||
android:entryValues="@array/download_quality_values"
|
||||
android:title="Download Quality"
|
||||
android:defaultValue="Original"
|
||||
android:entries="@array/quality_entries"
|
||||
android:entryValues="@array/quality_values"
|
||||
android:summary="%s" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:defaultValue="false"
|
||||
app:key="pref_downloads_quality_default"
|
||||
app:summary="@string/quality_default" />
|
||||
app:summary="Default to picked Download Quality" />
|
||||
|
||||
</PreferenceScreen>
|
|
@ -20,11 +20,4 @@
|
|||
android:defaultValue="true"
|
||||
app:key="pref_auto_offline"
|
||||
app:title="@string/turn_on_offline_mode_automatically" />
|
||||
<ListPreference
|
||||
app:defaultValue="hevc"
|
||||
app:key="pref_network_codec"
|
||||
app:title="@string/settings_quality_codec"
|
||||
app:useSimpleSummaryProvider="true"
|
||||
app:entries="@array/codecs"
|
||||
app:entryValues="@array/codecs" />
|
||||
</PreferenceScreen>
|
|
@ -1,31 +0,0 @@
|
|||
package com.nomadics9.ananas.models
|
||||
|
||||
enum class VideoQuality(
|
||||
val bitrate: Int,
|
||||
val height: Int,
|
||||
val width: Int,
|
||||
val isOriginalQuality: Boolean,
|
||||
) {
|
||||
Auto(10000000, 1080, 1920, false),
|
||||
Original(1000000000, 1080, 1920, true),
|
||||
P3840(12000000,3840, 2160, false), // Here for future proofing and to calculate original resolution only
|
||||
P1080(8000000, 1080, 1920, false),
|
||||
P720(3000000, 720, 1280, false),
|
||||
P480(1500000, 480, 854, false),
|
||||
P360(800000, 360, 640, false);
|
||||
|
||||
override fun toString(): String = when (this) {
|
||||
Auto -> "Auto"
|
||||
Original -> "Original"
|
||||
P3840 -> "4K"
|
||||
else -> "${height}p"
|
||||
}
|
||||
|
||||
companion object {
|
||||
fun fromString(quality: String): VideoQuality? = entries.find { it.toString() == quality }
|
||||
fun getBitrate(quality: VideoQuality): Int = quality.bitrate
|
||||
fun getHeight(quality: VideoQuality): Int = quality.height
|
||||
fun getWidth(quality: VideoQuality): Int = quality.width
|
||||
fun getIsOriginalQuality(quality: VideoQuality): Boolean = quality.isOriginalQuality
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ import kotlinx.coroutines.flow.Flow
|
|||
import org.jellyfin.sdk.api.client.Response
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
import org.jellyfin.sdk.model.api.BaseItemKind
|
||||
import org.jellyfin.sdk.model.api.DeviceInfoQueryResult
|
||||
import org.jellyfin.sdk.model.api.DeviceProfile
|
||||
import org.jellyfin.sdk.model.api.EncodingContext
|
||||
import org.jellyfin.sdk.model.api.ItemFields
|
||||
|
@ -29,9 +30,7 @@ interface JellyfinRepository {
|
|||
suspend fun getUserViews(): List<BaseItemDto>
|
||||
|
||||
suspend fun getItem(itemId: UUID): BaseItemDto
|
||||
|
||||
suspend fun getEpisode(itemId: UUID): FindroidEpisode
|
||||
|
||||
suspend fun getMovie(itemId: UUID): FindroidMovie
|
||||
|
||||
suspend fun getShow(itemId: UUID): FindroidShow
|
||||
|
@ -72,10 +71,7 @@ interface JellyfinRepository {
|
|||
|
||||
suspend fun getLatestMedia(parentId: UUID): List<FindroidItem>
|
||||
|
||||
suspend fun getSeasons(
|
||||
seriesId: UUID,
|
||||
offline: Boolean = false,
|
||||
): List<FindroidSeason>
|
||||
suspend fun getSeasons(seriesId: UUID, offline: Boolean = false): List<FindroidSeason>
|
||||
|
||||
suspend fun getNextUp(seriesId: UUID? = null): List<FindroidEpisode>
|
||||
|
||||
|
@ -90,7 +86,7 @@ interface JellyfinRepository {
|
|||
|
||||
suspend fun getMediaSources(itemId: UUID, includePath: Boolean = false): List<FindroidSource>
|
||||
|
||||
suspend fun getStreamUrl(itemId: UUID, mediaSourceId: String, playSessionId: String? = null): String
|
||||
suspend fun getStreamUrl(itemId: UUID, mediaSourceId: String): String
|
||||
|
||||
suspend fun getSegmentsTimestamps(itemId: UUID): List<FindroidSegment>?
|
||||
|
||||
|
@ -124,38 +120,13 @@ interface JellyfinRepository {
|
|||
|
||||
suspend fun getDeviceId(): String
|
||||
|
||||
suspend fun buildDeviceProfile(
|
||||
maxBitrate: Int,
|
||||
container: String,
|
||||
context: EncodingContext,
|
||||
): DeviceProfile
|
||||
suspend fun getVideoTranscodeBitRate(transcodeResolution: Int): Pair<Int, Int>
|
||||
|
||||
suspend fun getVideoStreambyContainerUrl(
|
||||
itemId: UUID,
|
||||
deviceId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String,
|
||||
videoBitrate: Int,
|
||||
container: String,
|
||||
maxHeight: Int,
|
||||
): String
|
||||
suspend fun buildDeviceProfile(maxBitrate: Int, container: String, context: EncodingContext): DeviceProfile
|
||||
|
||||
suspend fun getTranscodedVideoStream(
|
||||
itemId: UUID,
|
||||
deviceId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String,
|
||||
videoBitrate: Int,
|
||||
): String
|
||||
suspend fun getVideoStreambyContainerUrl(itemId: UUID, mediaSourceId: String, playSessionId: String, videoBitrate: Int, container: String): String
|
||||
|
||||
suspend fun getPostedPlaybackInfo(
|
||||
itemId: UUID,
|
||||
enableDirectStream: Boolean,
|
||||
deviceProfile: DeviceProfile,
|
||||
maxBitrate: Int,
|
||||
): Response<PlaybackInfoResponse>
|
||||
suspend fun getPostedPlaybackInfo(itemId: UUID, enableDirectStream: Boolean, deviceProfile: DeviceProfile ,maxBitrate: Int): Response<PlaybackInfoResponse>
|
||||
|
||||
suspend fun stopEncodingProcess(playSessionId: String)
|
||||
|
||||
suspend fun getAccessToken(): String?
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ import com.nomadics9.ananas.models.FindroidSegments
|
|||
import com.nomadics9.ananas.models.FindroidShow
|
||||
import com.nomadics9.ananas.models.FindroidSource
|
||||
import com.nomadics9.ananas.models.SortBy
|
||||
import com.nomadics9.ananas.models.VideoQuality
|
||||
import com.nomadics9.ananas.models.toFindroidCollection
|
||||
import com.nomadics9.ananas.models.toFindroidEpisode
|
||||
import com.nomadics9.ananas.models.toFindroidItem
|
||||
|
@ -31,12 +30,12 @@ import kotlinx.coroutines.Dispatchers
|
|||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.withContext
|
||||
import org.jellyfin.sdk.api.client.Response
|
||||
import org.jellyfin.sdk.api.client.extensions.dynamicHlsApi
|
||||
import org.jellyfin.sdk.api.client.extensions.get
|
||||
import org.jellyfin.sdk.api.client.extensions.hlsSegmentApi
|
||||
import org.jellyfin.sdk.model.api.BaseItemDto
|
||||
import org.jellyfin.sdk.model.api.BaseItemKind
|
||||
import org.jellyfin.sdk.model.api.ClientCapabilitiesDto
|
||||
import org.jellyfin.sdk.model.api.DeviceInfoQueryResult
|
||||
import org.jellyfin.sdk.model.api.DeviceOptionsDto
|
||||
import org.jellyfin.sdk.model.api.DeviceProfile
|
||||
import org.jellyfin.sdk.model.api.DirectPlayProfile
|
||||
|
@ -70,70 +69,55 @@ class JellyfinRepositoryImpl(
|
|||
private val database: ServerDatabaseDao,
|
||||
private val appPreferences: AppPreferences,
|
||||
) : JellyfinRepository {
|
||||
override suspend fun getPublicSystemInfo(): PublicSystemInfo =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.systemApi.getPublicSystemInfo().content
|
||||
}
|
||||
override suspend fun getPublicSystemInfo(): PublicSystemInfo = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.systemApi.getPublicSystemInfo().content
|
||||
}
|
||||
|
||||
override suspend fun getUserViews(): List<BaseItemDto> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.viewsApi
|
||||
.getUserViews(jellyfinApi.userId!!)
|
||||
.content.items
|
||||
.orEmpty()
|
||||
}
|
||||
override suspend fun getUserViews(): List<BaseItemDto> = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.viewsApi.getUserViews(jellyfinApi.userId!!).content.items.orEmpty()
|
||||
}
|
||||
|
||||
override suspend fun getItem(itemId: UUID): BaseItemDto =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi.getItem(itemId, jellyfinApi.userId!!).content
|
||||
}
|
||||
override suspend fun getItem(itemId: UUID): BaseItemDto = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi.getItem(itemId, jellyfinApi.userId!!).content
|
||||
}
|
||||
|
||||
override suspend fun getEpisode(itemId: UUID): FindroidEpisode =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi
|
||||
.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content
|
||||
.toFindroidEpisode(this@JellyfinRepositoryImpl, database)!!
|
||||
jellyfinApi.userLibraryApi.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content.toFindroidEpisode(this@JellyfinRepositoryImpl, database)!!
|
||||
}
|
||||
|
||||
override suspend fun getMovie(itemId: UUID): FindroidMovie =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi
|
||||
.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content
|
||||
.toFindroidMovie(this@JellyfinRepositoryImpl, database)
|
||||
jellyfinApi.userLibraryApi.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content.toFindroidMovie(this@JellyfinRepositoryImpl, database)
|
||||
}
|
||||
|
||||
override suspend fun getShow(itemId: UUID): FindroidShow =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi
|
||||
.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content
|
||||
.toFindroidShow(this@JellyfinRepositoryImpl)
|
||||
jellyfinApi.userLibraryApi.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content.toFindroidShow(this@JellyfinRepositoryImpl)
|
||||
}
|
||||
|
||||
override suspend fun getSeason(itemId: UUID): FindroidSeason =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi
|
||||
.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content
|
||||
.toFindroidSeason(this@JellyfinRepositoryImpl)
|
||||
jellyfinApi.userLibraryApi.getItem(
|
||||
itemId,
|
||||
jellyfinApi.userId!!,
|
||||
).content.toFindroidSeason(this@JellyfinRepositoryImpl)
|
||||
}
|
||||
|
||||
override suspend fun getLibraries(): List<FindroidCollection> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi
|
||||
.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
).content.items
|
||||
jellyfinApi.itemsApi.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull { it.toFindroidCollection(this@JellyfinRepositoryImpl) }
|
||||
}
|
||||
|
@ -148,17 +132,16 @@ class JellyfinRepositoryImpl(
|
|||
limit: Int?,
|
||||
): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi
|
||||
.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
parentId = parentId,
|
||||
includeItemTypes = includeTypes,
|
||||
recursive = recursive,
|
||||
sortBy = listOf(ItemSortBy.fromName(sortBy.sortString)),
|
||||
sortOrder = listOf(sortOrder),
|
||||
startIndex = startIndex,
|
||||
limit = limit,
|
||||
).content.items
|
||||
jellyfinApi.itemsApi.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
parentId = parentId,
|
||||
includeItemTypes = includeTypes,
|
||||
recursive = recursive,
|
||||
sortBy = listOf(ItemSortBy.fromName(sortBy.sortString)),
|
||||
sortOrder = listOf(sortOrder),
|
||||
startIndex = startIndex,
|
||||
limit = limit,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull { it.toFindroidItem(this@JellyfinRepositoryImpl, database) }
|
||||
}
|
||||
|
@ -169,14 +152,13 @@ class JellyfinRepositoryImpl(
|
|||
recursive: Boolean,
|
||||
sortBy: SortBy,
|
||||
sortOrder: SortOrder,
|
||||
): Flow<PagingData<FindroidItem>> =
|
||||
Pager(
|
||||
config =
|
||||
PagingConfig(
|
||||
pageSize = 10,
|
||||
maxSize = 100,
|
||||
enablePlaceholders = false,
|
||||
),
|
||||
): Flow<PagingData<FindroidItem>> {
|
||||
return Pager(
|
||||
config = PagingConfig(
|
||||
pageSize = 10,
|
||||
maxSize = 100,
|
||||
enablePlaceholders = false,
|
||||
),
|
||||
pagingSourceFactory = {
|
||||
ItemsPagingSource(
|
||||
this,
|
||||
|
@ -188,102 +170,87 @@ class JellyfinRepositoryImpl(
|
|||
)
|
||||
},
|
||||
).flow
|
||||
}
|
||||
|
||||
override suspend fun getPersonItems(
|
||||
personIds: List<UUID>,
|
||||
includeTypes: List<BaseItemKind>?,
|
||||
recursive: Boolean,
|
||||
): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi
|
||||
.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
personIds = personIds,
|
||||
includeItemTypes = includeTypes,
|
||||
recursive = recursive,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull {
|
||||
it.toFindroidItem(this@JellyfinRepositoryImpl, database)
|
||||
}
|
||||
}
|
||||
): List<FindroidItem> = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
personIds = personIds,
|
||||
includeItemTypes = includeTypes,
|
||||
recursive = recursive,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull {
|
||||
it.toFindroidItem(this@JellyfinRepositoryImpl, database)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getFavoriteItems(): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi
|
||||
.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
filters = listOf(ItemFilter.IS_FAVORITE),
|
||||
includeItemTypes =
|
||||
listOf(
|
||||
BaseItemKind.MOVIE,
|
||||
BaseItemKind.SERIES,
|
||||
BaseItemKind.EPISODE,
|
||||
),
|
||||
recursive = true,
|
||||
).content.items
|
||||
jellyfinApi.itemsApi.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
filters = listOf(ItemFilter.IS_FAVORITE),
|
||||
includeItemTypes = listOf(
|
||||
BaseItemKind.MOVIE,
|
||||
BaseItemKind.SERIES,
|
||||
BaseItemKind.EPISODE,
|
||||
),
|
||||
recursive = true,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull { it.toFindroidItem(this@JellyfinRepositoryImpl, database) }
|
||||
}
|
||||
|
||||
override suspend fun getSearchItems(searchQuery: String): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi
|
||||
.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
searchTerm = searchQuery,
|
||||
includeItemTypes =
|
||||
listOf(
|
||||
BaseItemKind.MOVIE,
|
||||
BaseItemKind.SERIES,
|
||||
BaseItemKind.EPISODE,
|
||||
),
|
||||
recursive = true,
|
||||
).content.items
|
||||
jellyfinApi.itemsApi.getItems(
|
||||
jellyfinApi.userId!!,
|
||||
searchTerm = searchQuery,
|
||||
includeItemTypes = listOf(
|
||||
BaseItemKind.MOVIE,
|
||||
BaseItemKind.SERIES,
|
||||
BaseItemKind.EPISODE,
|
||||
),
|
||||
recursive = true,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull { it.toFindroidItem(this@JellyfinRepositoryImpl, database) }
|
||||
}
|
||||
|
||||
override suspend fun getResumeItems(): List<FindroidItem> {
|
||||
val items =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi
|
||||
.getResumeItems(
|
||||
jellyfinApi.userId!!,
|
||||
limit = 12,
|
||||
includeItemTypes = listOf(BaseItemKind.MOVIE, BaseItemKind.EPISODE),
|
||||
).content.items
|
||||
.orEmpty()
|
||||
}
|
||||
val items = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.itemsApi.getResumeItems(
|
||||
jellyfinApi.userId!!,
|
||||
limit = 12,
|
||||
includeItemTypes = listOf(BaseItemKind.MOVIE, BaseItemKind.EPISODE),
|
||||
).content.items.orEmpty()
|
||||
}
|
||||
return items.mapNotNull {
|
||||
it.toFindroidItem(this, database)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getLatestMedia(parentId: UUID): List<FindroidItem> {
|
||||
val items =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi
|
||||
.getLatestMedia(
|
||||
jellyfinApi.userId!!,
|
||||
parentId = parentId,
|
||||
limit = 16,
|
||||
).content
|
||||
}
|
||||
val items = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userLibraryApi.getLatestMedia(
|
||||
jellyfinApi.userId!!,
|
||||
parentId = parentId,
|
||||
limit = 16,
|
||||
).content
|
||||
}
|
||||
return items.mapNotNull {
|
||||
it.toFindroidItem(this, database)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getSeasons(
|
||||
seriesId: UUID,
|
||||
offline: Boolean,
|
||||
): List<FindroidSeason> =
|
||||
override suspend fun getSeasons(seriesId: UUID, offline: Boolean): List<FindroidSeason> =
|
||||
withContext(Dispatchers.IO) {
|
||||
if (!offline) {
|
||||
jellyfinApi.showsApi
|
||||
.getSeasons(seriesId, jellyfinApi.userId!!)
|
||||
.content.items
|
||||
jellyfinApi.showsApi.getSeasons(seriesId, jellyfinApi.userId!!).content.items
|
||||
.orEmpty()
|
||||
.map { it.toFindroidSeason(this@JellyfinRepositoryImpl) }
|
||||
} else {
|
||||
|
@ -293,13 +260,12 @@ class JellyfinRepositoryImpl(
|
|||
|
||||
override suspend fun getNextUp(seriesId: UUID?): List<FindroidEpisode> =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.showsApi
|
||||
.getNextUp(
|
||||
jellyfinApi.userId!!,
|
||||
limit = 24,
|
||||
seriesId = seriesId,
|
||||
enableResumable = false,
|
||||
).content.items
|
||||
jellyfinApi.showsApi.getNextUp(
|
||||
jellyfinApi.userId!!,
|
||||
limit = 24,
|
||||
seriesId = seriesId,
|
||||
enableResumable = false,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull { it.toFindroidEpisode(this@JellyfinRepositoryImpl) }
|
||||
}
|
||||
|
@ -314,15 +280,14 @@ class JellyfinRepositoryImpl(
|
|||
): List<FindroidEpisode> =
|
||||
withContext(Dispatchers.IO) {
|
||||
if (!offline) {
|
||||
jellyfinApi.showsApi
|
||||
.getEpisodes(
|
||||
seriesId,
|
||||
jellyfinApi.userId!!,
|
||||
seasonId = seasonId,
|
||||
fields = fields,
|
||||
startItemId = startItemId,
|
||||
limit = limit,
|
||||
).content.items
|
||||
jellyfinApi.showsApi.getEpisodes(
|
||||
seriesId,
|
||||
jellyfinApi.userId!!,
|
||||
seasonId = seasonId,
|
||||
fields = fields,
|
||||
startItemId = startItemId,
|
||||
limit = limit,
|
||||
).content.items
|
||||
.orEmpty()
|
||||
.mapNotNull { it.toFindroidEpisode(this@JellyfinRepositoryImpl, database) }
|
||||
} else {
|
||||
|
@ -330,47 +295,39 @@ class JellyfinRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun getMediaSources(
|
||||
itemId: UUID,
|
||||
includePath: Boolean,
|
||||
): List<FindroidSource> =
|
||||
override suspend fun getMediaSources(itemId: UUID, includePath: Boolean): List<FindroidSource> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val sources = mutableListOf<FindroidSource>()
|
||||
sources.addAll(
|
||||
jellyfinApi.mediaInfoApi
|
||||
.getPostedPlaybackInfo(
|
||||
itemId,
|
||||
PlaybackInfoDto(
|
||||
userId = jellyfinApi.userId!!,
|
||||
deviceProfile =
|
||||
DeviceProfile(
|
||||
name = "Direct play all",
|
||||
maxStaticBitrate = 1_000_000_000,
|
||||
maxStreamingBitrate = 1_000_000_000,
|
||||
codecProfiles = emptyList(),
|
||||
containerProfiles = emptyList(),
|
||||
directPlayProfiles =
|
||||
listOf(
|
||||
DirectPlayProfile(type = DlnaProfileType.VIDEO),
|
||||
DirectPlayProfile(type = DlnaProfileType.AUDIO),
|
||||
),
|
||||
transcodingProfiles = emptyList(),
|
||||
subtitleProfiles =
|
||||
listOf(
|
||||
SubtitleProfile("srt", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("ass", SubtitleDeliveryMethod.EXTERNAL),
|
||||
),
|
||||
),
|
||||
jellyfinApi.mediaInfoApi.getPostedPlaybackInfo(
|
||||
itemId,
|
||||
PlaybackInfoDto(
|
||||
userId = jellyfinApi.userId!!,
|
||||
deviceProfile = DeviceProfile(
|
||||
name = "Direct play all",
|
||||
maxStaticBitrate = 1_000_000_000,
|
||||
maxStreamingBitrate = 1_000_000_000,
|
||||
codecProfiles = emptyList(),
|
||||
containerProfiles = emptyList(),
|
||||
directPlayProfiles = listOf(
|
||||
DirectPlayProfile(type = DlnaProfileType.VIDEO),
|
||||
DirectPlayProfile(type = DlnaProfileType.AUDIO),
|
||||
),
|
||||
transcodingProfiles = emptyList(),
|
||||
subtitleProfiles = listOf(
|
||||
SubtitleProfile("srt", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("ass", SubtitleDeliveryMethod.EXTERNAL),
|
||||
),
|
||||
),
|
||||
).content.mediaSources
|
||||
.map {
|
||||
it.toFindroidSource(
|
||||
this@JellyfinRepositoryImpl,
|
||||
itemId,
|
||||
includePath,
|
||||
)
|
||||
},
|
||||
maxStreamingBitrate = 1_000_000_000,
|
||||
),
|
||||
).content.mediaSources.map {
|
||||
it.toFindroidSource(
|
||||
this@JellyfinRepositoryImpl,
|
||||
itemId,
|
||||
includePath,
|
||||
)
|
||||
},
|
||||
)
|
||||
sources.addAll(
|
||||
database.getSources(itemId).map { it.toFindroidSource(database) },
|
||||
|
@ -378,33 +335,14 @@ class JellyfinRepositoryImpl(
|
|||
sources
|
||||
}
|
||||
|
||||
override suspend fun getStreamUrl(
|
||||
itemId: UUID,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String?,
|
||||
): String =
|
||||
override suspend fun getStreamUrl(itemId: UUID, mediaSourceId: String): String =
|
||||
withContext(Dispatchers.IO) {
|
||||
val deviceId = getDeviceId()
|
||||
try {
|
||||
val url =
|
||||
if (playSessionId != null) {
|
||||
jellyfinApi.videosApi.getVideoStreamUrl(
|
||||
itemId,
|
||||
static = true,
|
||||
mediaSourceId = mediaSourceId,
|
||||
playSessionId = playSessionId,
|
||||
deviceId = deviceId,
|
||||
context = EncodingContext.STREAMING,
|
||||
)
|
||||
} else {
|
||||
jellyfinApi.videosApi.getVideoStreamUrl(
|
||||
itemId,
|
||||
static = true,
|
||||
mediaSourceId = mediaSourceId,
|
||||
deviceId = deviceId,
|
||||
)
|
||||
}
|
||||
url
|
||||
jellyfinApi.videosApi.getVideoStreamUrl(
|
||||
itemId,
|
||||
static = true,
|
||||
mediaSourceId = mediaSourceId,
|
||||
)
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
""
|
||||
|
@ -424,36 +362,33 @@ class JellyfinRepositoryImpl(
|
|||
pathParameters["itemId"] = itemId
|
||||
|
||||
try {
|
||||
val segmentToConvert =
|
||||
jellyfinApi.api
|
||||
.get<FindroidSegments>(
|
||||
"/Episode/{itemId}/IntroSkipperSegments",
|
||||
pathParameters,
|
||||
).content
|
||||
val segmentToConvert = jellyfinApi.api.get<FindroidSegments>(
|
||||
"/Episode/{itemId}/IntroSkipperSegments",
|
||||
pathParameters,
|
||||
).content
|
||||
|
||||
val segmentConverted =
|
||||
mutableListOf(
|
||||
segmentToConvert.intro!!.let {
|
||||
FindroidSegment(
|
||||
type = "intro",
|
||||
skip = true,
|
||||
startTime = it.startTime,
|
||||
endTime = it.endTime,
|
||||
showAt = it.showAt,
|
||||
hideAt = it.hideAt,
|
||||
)
|
||||
},
|
||||
segmentToConvert.credit!!.let {
|
||||
FindroidSegment(
|
||||
type = "credit",
|
||||
skip = true,
|
||||
startTime = it.startTime,
|
||||
endTime = it.endTime,
|
||||
showAt = it.showAt,
|
||||
hideAt = it.hideAt,
|
||||
)
|
||||
},
|
||||
)
|
||||
val segmentConverted = mutableListOf(
|
||||
segmentToConvert.intro!!.let {
|
||||
FindroidSegment(
|
||||
type = "intro",
|
||||
skip = true,
|
||||
startTime = it.startTime,
|
||||
endTime = it.endTime,
|
||||
showAt = it.showAt,
|
||||
hideAt = it.hideAt,
|
||||
)
|
||||
},
|
||||
segmentToConvert.credit!!.let {
|
||||
FindroidSegment(
|
||||
type = "credit",
|
||||
skip = true,
|
||||
startTime = it.startTime,
|
||||
endTime = it.endTime,
|
||||
showAt = it.showAt,
|
||||
hideAt = it.hideAt,
|
||||
)
|
||||
},
|
||||
)
|
||||
Timber.tag("SegmentInfo").d("segmentToConvert: %s", segmentToConvert)
|
||||
Timber.tag("SegmentInfo").d("segmentConverted: %s", segmentConverted)
|
||||
|
||||
|
@ -463,11 +398,7 @@ class JellyfinRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun getTrickplayData(
|
||||
itemId: UUID,
|
||||
width: Int,
|
||||
index: Int,
|
||||
): ByteArray? =
|
||||
override suspend fun getTrickplayData(itemId: UUID, width: Int, index: Int): ByteArray? =
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
try {
|
||||
|
@ -475,13 +406,9 @@ class JellyfinRepositoryImpl(
|
|||
if (sources != null) {
|
||||
return@withContext File(sources.first(), index.toString()).readBytes()
|
||||
}
|
||||
} catch (_: Exception) {
|
||||
}
|
||||
} catch (_: Exception) { }
|
||||
|
||||
return@withContext jellyfinApi.trickplayApi
|
||||
.getTrickplayTileImage(itemId, width, index)
|
||||
.content
|
||||
.toByteArray()
|
||||
return@withContext jellyfinApi.trickplayApi.getTrickplayTileImage(itemId, width, index).content.toByteArray()
|
||||
} catch (e: Exception) {
|
||||
return@withContext null
|
||||
}
|
||||
|
@ -492,22 +419,21 @@ class JellyfinRepositoryImpl(
|
|||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.sessionApi.postCapabilities(
|
||||
playableMediaTypes = listOf(MediaType.VIDEO),
|
||||
supportedCommands =
|
||||
listOf(
|
||||
GeneralCommandType.VOLUME_UP,
|
||||
GeneralCommandType.VOLUME_DOWN,
|
||||
GeneralCommandType.TOGGLE_MUTE,
|
||||
GeneralCommandType.SET_AUDIO_STREAM_INDEX,
|
||||
GeneralCommandType.SET_SUBTITLE_STREAM_INDEX,
|
||||
GeneralCommandType.MUTE,
|
||||
GeneralCommandType.UNMUTE,
|
||||
GeneralCommandType.SET_VOLUME,
|
||||
GeneralCommandType.DISPLAY_MESSAGE,
|
||||
GeneralCommandType.PLAY,
|
||||
GeneralCommandType.PLAY_STATE,
|
||||
GeneralCommandType.PLAY_NEXT,
|
||||
GeneralCommandType.PLAY_MEDIA_SOURCE,
|
||||
),
|
||||
supportedCommands = listOf(
|
||||
GeneralCommandType.VOLUME_UP,
|
||||
GeneralCommandType.VOLUME_DOWN,
|
||||
GeneralCommandType.TOGGLE_MUTE,
|
||||
GeneralCommandType.SET_AUDIO_STREAM_INDEX,
|
||||
GeneralCommandType.SET_SUBTITLE_STREAM_INDEX,
|
||||
GeneralCommandType.MUTE,
|
||||
GeneralCommandType.UNMUTE,
|
||||
GeneralCommandType.SET_VOLUME,
|
||||
GeneralCommandType.DISPLAY_MESSAGE,
|
||||
GeneralCommandType.PLAY,
|
||||
GeneralCommandType.PLAY_STATE,
|
||||
GeneralCommandType.PLAY_NEXT,
|
||||
GeneralCommandType.PLAY_MEDIA_SOURCE,
|
||||
),
|
||||
supportsMediaControl = true,
|
||||
)
|
||||
}
|
||||
|
@ -629,218 +555,140 @@ class JellyfinRepositoryImpl(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun getUserConfiguration(): UserConfiguration =
|
||||
withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userApi
|
||||
.getCurrentUser()
|
||||
.content.configuration!!
|
||||
}
|
||||
override suspend fun getUserConfiguration(): UserConfiguration = withContext(Dispatchers.IO) {
|
||||
jellyfinApi.userApi.getCurrentUser().content.configuration!!
|
||||
}
|
||||
|
||||
override suspend fun getDownloads(): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val items = mutableListOf<FindroidItem>()
|
||||
items.addAll(
|
||||
database
|
||||
.getMoviesByServerId(appPreferences.currentServer!!)
|
||||
database.getMoviesByServerId(appPreferences.currentServer!!)
|
||||
.map { it.toFindroidMovie(database, jellyfinApi.userId!!) },
|
||||
)
|
||||
items.addAll(
|
||||
database
|
||||
.getShowsByServerId(appPreferences.currentServer!!)
|
||||
database.getShowsByServerId(appPreferences.currentServer!!)
|
||||
.map { it.toFindroidShow(database, jellyfinApi.userId!!) },
|
||||
)
|
||||
items
|
||||
}
|
||||
|
||||
override fun getUserId(): UUID = jellyfinApi.userId!!
|
||||
override fun getUserId(): UUID {
|
||||
return jellyfinApi.userId!!
|
||||
}
|
||||
|
||||
override suspend fun buildDeviceProfile(
|
||||
maxBitrate: Int,
|
||||
container: String,
|
||||
context: EncodingContext,
|
||||
): DeviceProfile {
|
||||
val deviceProfile =
|
||||
ClientCapabilitiesDto(
|
||||
supportedCommands = emptyList(),
|
||||
playableMediaTypes =
|
||||
listOf(
|
||||
MediaType.VIDEO,
|
||||
MediaType.AUDIO,
|
||||
MediaType.UNKNOWN,
|
||||
),
|
||||
supportsMediaControl = true,
|
||||
supportsPersistentIdentifier = true,
|
||||
deviceProfile =
|
||||
DeviceProfile(
|
||||
name = "AnanasUser",
|
||||
id = getUserId().toString(),
|
||||
maxStaticBitrate = maxBitrate,
|
||||
maxStreamingBitrate = maxBitrate,
|
||||
codecProfiles = emptyList(),
|
||||
containerProfiles = listOf(),
|
||||
directPlayProfiles =
|
||||
listOf(
|
||||
DirectPlayProfile(type = DlnaProfileType.VIDEO),
|
||||
DirectPlayProfile(type = DlnaProfileType.AUDIO),
|
||||
),
|
||||
transcodingProfiles =
|
||||
listOf(
|
||||
TranscodingProfile(
|
||||
container = container,
|
||||
context = context,
|
||||
protocol = MediaStreamProtocol.HLS,
|
||||
audioCodec = "aac,ac3,eac3",
|
||||
videoCodec = "hevc,h264",
|
||||
type = DlnaProfileType.VIDEO,
|
||||
conditions =
|
||||
listOf(
|
||||
ProfileCondition(
|
||||
condition = ProfileConditionType.LESS_THAN_EQUAL,
|
||||
property = ProfileConditionValue.VIDEO_BITRATE,
|
||||
value = "8000000",
|
||||
isRequired = true,
|
||||
),
|
||||
),
|
||||
copyTimestamps = true,
|
||||
enableSubtitlesInManifest = true,
|
||||
transcodeSeekInfo = TranscodeSeekInfo.AUTO,
|
||||
),
|
||||
),
|
||||
subtitleProfiles =
|
||||
listOf(
|
||||
SubtitleProfile("srt", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("ass", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("sub", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("vtt", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("ssa", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("pgs", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("dvb_teletext", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("dvd_subtitle", SubtitleDeliveryMethod.EXTERNAL),
|
||||
),
|
||||
|
||||
override suspend fun getVideoTranscodeBitRate(transcodeResolution: Int): Pair<Int, Int> {
|
||||
return when (transcodeResolution) {
|
||||
1080 -> 8000000 to 384000 // Adjusted for 1080p
|
||||
720 -> 2000000 to 384000 // Adjusted for 720p
|
||||
480 -> 1000000 to 384000 // Adjusted for 480p
|
||||
360 -> 800000 to 128000 // Adjusted for 360p
|
||||
else -> 8000000 to 384000
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun buildDeviceProfile(maxBitrate: Int, container: String, context: EncodingContext): DeviceProfile {
|
||||
val deviceProfile = ClientCapabilitiesDto(
|
||||
supportedCommands = emptyList(),
|
||||
playableMediaTypes = emptyList(),
|
||||
supportsMediaControl = true,
|
||||
supportsPersistentIdentifier = true,
|
||||
deviceProfile = DeviceProfile(
|
||||
name = "AnanasUser",
|
||||
id = getUserId().toString(),
|
||||
maxStaticBitrate = maxBitrate,
|
||||
maxStreamingBitrate = maxBitrate,
|
||||
codecProfiles = emptyList(),
|
||||
containerProfiles = listOf(),
|
||||
directPlayProfiles = listOf(
|
||||
DirectPlayProfile(type = DlnaProfileType.VIDEO),
|
||||
DirectPlayProfile(type = DlnaProfileType.AUDIO),
|
||||
),
|
||||
transcodingProfiles = listOf(
|
||||
TranscodingProfile(
|
||||
container = container,
|
||||
context = context,
|
||||
protocol = MediaStreamProtocol.HLS,
|
||||
audioCodec = "aac,ac3,eac3",
|
||||
videoCodec = "hevc,h264",
|
||||
type = DlnaProfileType.VIDEO,
|
||||
conditions = listOf(
|
||||
ProfileCondition(
|
||||
condition = ProfileConditionType.LESS_THAN_EQUAL,
|
||||
property = ProfileConditionValue.VIDEO_BITRATE,
|
||||
value = "8000000",
|
||||
isRequired = true,
|
||||
)
|
||||
),
|
||||
copyTimestamps = true,
|
||||
enableSubtitlesInManifest = true,
|
||||
transcodeSeekInfo = TranscodeSeekInfo.AUTO,
|
||||
),
|
||||
),
|
||||
subtitleProfiles = listOf(
|
||||
SubtitleProfile("srt", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("ass", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("sub", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("vtt", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("ssa", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("pgs", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("dvb_teletext", SubtitleDeliveryMethod.EXTERNAL),
|
||||
SubtitleProfile("dvd_subtitle", SubtitleDeliveryMethod.EXTERNAL)
|
||||
),
|
||||
)
|
||||
)
|
||||
return deviceProfile.deviceProfile!!
|
||||
}
|
||||
|
||||
override suspend fun getPostedPlaybackInfo(
|
||||
itemId: UUID,
|
||||
enableDirectStream: Boolean,
|
||||
deviceProfile: DeviceProfile,
|
||||
maxBitrate: Int,
|
||||
): Response<PlaybackInfoResponse> {
|
||||
val playbackInfo =
|
||||
jellyfinApi.mediaInfoApi.getPostedPlaybackInfo(
|
||||
itemId = itemId,
|
||||
PlaybackInfoDto(
|
||||
userId = jellyfinApi.userId!!,
|
||||
enableTranscoding = true,
|
||||
enableDirectPlay = false,
|
||||
enableDirectStream = enableDirectStream,
|
||||
autoOpenLiveStream = true,
|
||||
deviceProfile = buildDeviceProfile(maxBitrate, "ts", EncodingContext.STREAMING),
|
||||
allowAudioStreamCopy = true,
|
||||
allowVideoStreamCopy = true,
|
||||
maxStreamingBitrate = maxBitrate,
|
||||
),
|
||||
|
||||
override suspend fun getPostedPlaybackInfo(itemId: UUID ,enableDirectStream: Boolean ,deviceProfile: DeviceProfile ,maxBitrate: Int): Response<PlaybackInfoResponse> {
|
||||
val playbackInfo = jellyfinApi.mediaInfoApi.getPostedPlaybackInfo(
|
||||
itemId = itemId,
|
||||
PlaybackInfoDto(
|
||||
userId = jellyfinApi.userId!!,
|
||||
enableTranscoding = true,
|
||||
enableDirectPlay = false,
|
||||
enableDirectStream = enableDirectStream,
|
||||
autoOpenLiveStream = true,
|
||||
deviceProfile = deviceProfile,
|
||||
allowAudioStreamCopy = true,
|
||||
allowVideoStreamCopy = true,
|
||||
maxStreamingBitrate = maxBitrate,
|
||||
)
|
||||
)
|
||||
return playbackInfo
|
||||
}
|
||||
|
||||
override suspend fun getVideoStreambyContainerUrl(
|
||||
itemId: UUID,
|
||||
deviceId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String,
|
||||
videoBitrate: Int,
|
||||
container: String,
|
||||
maxHeight: Int,
|
||||
): String {
|
||||
val url =
|
||||
jellyfinApi.videosApi.getVideoStreamByContainerUrl(
|
||||
itemId,
|
||||
static = false,
|
||||
deviceId = deviceId,
|
||||
mediaSourceId = mediaSourceId,
|
||||
playSessionId = playSessionId,
|
||||
videoBitRate = videoBitrate,
|
||||
maxHeight = maxHeight,
|
||||
audioBitRate = 328000,
|
||||
videoCodec = appPreferences.transcodeCodec,
|
||||
audioCodec = "aac,ac3,eac3",
|
||||
container = container,
|
||||
startTimeTicks = 0,
|
||||
copyTimestamps = true,
|
||||
subtitleMethod = SubtitleDeliveryMethod.EXTERNAL,
|
||||
)
|
||||
override suspend fun getVideoStreambyContainerUrl(itemId: UUID, mediaSourceId: String, playSessionId: String, videoBitrate: Int, container: String): String {
|
||||
val url = jellyfinApi.videosApi.getVideoStreamByContainerUrl(
|
||||
itemId,
|
||||
static = false,
|
||||
mediaSourceId = mediaSourceId,
|
||||
playSessionId = playSessionId,
|
||||
videoBitRate = videoBitrate,
|
||||
audioBitRate = 384000,
|
||||
videoCodec = "hevc",
|
||||
audioCodec = "aac,ac3,eac3",
|
||||
container = container,
|
||||
startTimeTicks = 0,
|
||||
copyTimestamps = true,
|
||||
)
|
||||
return url
|
||||
}
|
||||
|
||||
override suspend fun getTranscodedVideoStream(
|
||||
itemId: UUID,
|
||||
deviceId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String,
|
||||
videoBitrate: Int,
|
||||
): String {
|
||||
val isAuto = videoBitrate == VideoQuality.getBitrate(VideoQuality.Auto)
|
||||
val url: String
|
||||
try {
|
||||
url =
|
||||
if (!isAuto) {
|
||||
jellyfinApi.api.dynamicHlsApi.getMasterHlsVideoPlaylistUrl(
|
||||
itemId,
|
||||
static = false,
|
||||
deviceId = deviceId,
|
||||
mediaSourceId = mediaSourceId,
|
||||
playSessionId = playSessionId,
|
||||
videoBitRate = videoBitrate,
|
||||
enableAdaptiveBitrateStreaming = false,
|
||||
audioBitRate = 328000,
|
||||
videoCodec = appPreferences.transcodeCodec,
|
||||
audioCodec = "aac,ac3,eac3",
|
||||
startTimeTicks = 0,
|
||||
copyTimestamps = true,
|
||||
subtitleMethod = SubtitleDeliveryMethod.EXTERNAL,
|
||||
context = EncodingContext.STREAMING,
|
||||
segmentContainer = "ts",
|
||||
transcodeReasons = "ContainerBitrateExceedsLimit",
|
||||
)
|
||||
} else {
|
||||
jellyfinApi.api.dynamicHlsApi.getMasterHlsVideoPlaylistUrl(
|
||||
itemId,
|
||||
static = false,
|
||||
deviceId = deviceId,
|
||||
mediaSourceId = mediaSourceId,
|
||||
playSessionId = playSessionId,
|
||||
enableAdaptiveBitrateStreaming = true,
|
||||
videoCodec = appPreferences.transcodeCodec,
|
||||
audioCodec = "aac,ac3,eac3",
|
||||
startTimeTicks = 0,
|
||||
copyTimestamps = true,
|
||||
subtitleMethod = SubtitleDeliveryMethod.EXTERNAL,
|
||||
context = EncodingContext.STREAMING,
|
||||
segmentContainer = "ts",
|
||||
transcodeReasons = "ContainerBitrateExceedsLimit",
|
||||
)
|
||||
}
|
||||
} catch (e: Exception) {
|
||||
Timber.e(e)
|
||||
throw e
|
||||
}
|
||||
return url
|
||||
override suspend fun getDeviceId(): String {
|
||||
val deviceId = jellyfinApi.devicesApi.getDevices(getUserId())
|
||||
return deviceId.toString()
|
||||
}
|
||||
|
||||
override suspend fun getDeviceId(): String = jellyfinApi.api.deviceInfo.id
|
||||
|
||||
override suspend fun stopEncodingProcess(playSessionId: String) {
|
||||
val deviceId = getDeviceId()
|
||||
jellyfinApi.api.hlsSegmentApi.stopEncodingProcess(
|
||||
deviceId = deviceId,
|
||||
playSessionId = playSessionId,
|
||||
deviceId = getDeviceId(),
|
||||
playSessionId = playSessionId
|
||||
)
|
||||
}
|
||||
|
||||
override suspend fun getAccessToken(): String? {
|
||||
return jellyfinApi.api.accessToken
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -42,9 +42,14 @@ class JellyfinRepositoryOfflineImpl(
|
|||
private val database: ServerDatabaseDao,
|
||||
private val appPreferences: AppPreferences,
|
||||
) : JellyfinRepository {
|
||||
override suspend fun getPublicSystemInfo(): PublicSystemInfo = throw Exception("System info not available in offline mode")
|
||||
|
||||
override suspend fun getUserViews(): List<BaseItemDto> = emptyList()
|
||||
override suspend fun getPublicSystemInfo(): PublicSystemInfo {
|
||||
throw Exception("System info not available in offline mode")
|
||||
}
|
||||
|
||||
override suspend fun getUserViews(): List<BaseItemDto> {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override suspend fun getItem(itemId: UUID): BaseItemDto {
|
||||
TODO("Not yet implemented")
|
||||
|
@ -108,61 +113,38 @@ class JellyfinRepositoryOfflineImpl(
|
|||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun getSearchItems(searchQuery: String): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val movies =
|
||||
database
|
||||
.searchMovies(
|
||||
appPreferences.currentServer!!,
|
||||
searchQuery,
|
||||
).map { it.toFindroidMovie(database, jellyfinApi.userId!!) }
|
||||
val shows =
|
||||
database
|
||||
.searchShows(
|
||||
appPreferences.currentServer!!,
|
||||
searchQuery,
|
||||
).map { it.toFindroidShow(database, jellyfinApi.userId!!) }
|
||||
val episodes =
|
||||
database.searchEpisodes(appPreferences.currentServer!!, searchQuery).map {
|
||||
it.toFindroidEpisode(database, jellyfinApi.userId!!)
|
||||
}
|
||||
override suspend fun getSearchItems(searchQuery: String): List<FindroidItem> {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val movies = database.searchMovies(appPreferences.currentServer!!, searchQuery).map { it.toFindroidMovie(database, jellyfinApi.userId!!) }
|
||||
val shows = database.searchShows(appPreferences.currentServer!!, searchQuery).map { it.toFindroidShow(database, jellyfinApi.userId!!) }
|
||||
val episodes = database.searchEpisodes(appPreferences.currentServer!!, searchQuery).map { it.toFindroidEpisode(database, jellyfinApi.userId!!) }
|
||||
movies + shows + episodes
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getResumeItems(): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val movies =
|
||||
database
|
||||
.getMoviesByServerId(appPreferences.currentServer!!)
|
||||
.map {
|
||||
it.toFindroidMovie(database, jellyfinApi.userId!!)
|
||||
}.filter { it.playbackPositionTicks > 0 }
|
||||
val episodes =
|
||||
database
|
||||
.getEpisodesByServerId(appPreferences.currentServer!!)
|
||||
.map {
|
||||
it.toFindroidEpisode(database, jellyfinApi.userId!!)
|
||||
}.filter { it.playbackPositionTicks > 0 }
|
||||
override suspend fun getResumeItems(): List<FindroidItem> {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val movies = database.getMoviesByServerId(appPreferences.currentServer!!).map { it.toFindroidMovie(database, jellyfinApi.userId!!) }.filter { it.playbackPositionTicks > 0 }
|
||||
val episodes = database.getEpisodesByServerId(appPreferences.currentServer!!).map { it.toFindroidEpisode(database, jellyfinApi.userId!!) }.filter { it.playbackPositionTicks > 0 }
|
||||
movies + episodes
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getLatestMedia(parentId: UUID): List<FindroidItem> = emptyList()
|
||||
override suspend fun getLatestMedia(parentId: UUID): List<FindroidItem> {
|
||||
return emptyList()
|
||||
}
|
||||
|
||||
override suspend fun getSeasons(
|
||||
seriesId: UUID,
|
||||
offline: Boolean,
|
||||
): List<FindroidSeason> =
|
||||
override suspend fun getSeasons(seriesId: UUID, offline: Boolean): List<FindroidSeason> =
|
||||
withContext(Dispatchers.IO) {
|
||||
database.getSeasonsByShowId(seriesId).map { it.toFindroidSeason(database, jellyfinApi.userId!!) }
|
||||
}
|
||||
|
||||
override suspend fun getNextUp(seriesId: UUID?): List<FindroidEpisode> =
|
||||
withContext(Dispatchers.IO) {
|
||||
override suspend fun getNextUp(seriesId: UUID?): List<FindroidEpisode> {
|
||||
return withContext(Dispatchers.IO) {
|
||||
val result = mutableListOf<FindroidEpisode>()
|
||||
val shows =
|
||||
database.getShowsByServerId(appPreferences.currentServer!!).filter {
|
||||
if (seriesId != null) it.id == seriesId else true
|
||||
}
|
||||
val shows = database.getShowsByServerId(appPreferences.currentServer!!).filter {
|
||||
if (seriesId != null) it.id == seriesId else true
|
||||
}
|
||||
for (show in shows) {
|
||||
val episodes = database.getEpisodesByShowId(show.id).map { it.toFindroidEpisode(database, jellyfinApi.userId!!) }
|
||||
val indexOfLastPlayed = episodes.indexOfLast { it.played }
|
||||
|
@ -174,6 +156,7 @@ class JellyfinRepositoryOfflineImpl(
|
|||
}
|
||||
result.filter { it.playbackPositionTicks == 0L }
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun getEpisodes(
|
||||
seriesId: UUID,
|
||||
|
@ -189,19 +172,12 @@ class JellyfinRepositoryOfflineImpl(
|
|||
items
|
||||
}
|
||||
|
||||
override suspend fun getMediaSources(
|
||||
itemId: UUID,
|
||||
includePath: Boolean,
|
||||
): List<FindroidSource> =
|
||||
override suspend fun getMediaSources(itemId: UUID, includePath: Boolean): List<FindroidSource> =
|
||||
withContext(Dispatchers.IO) {
|
||||
database.getSources(itemId).map { it.toFindroidSource(database) }
|
||||
}
|
||||
|
||||
override suspend fun getStreamUrl(
|
||||
itemId: UUID,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String?,
|
||||
): String {
|
||||
override suspend fun getStreamUrl(itemId: UUID, mediaSourceId: String): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
|
@ -210,11 +186,7 @@ class JellyfinRepositoryOfflineImpl(
|
|||
database.getSegments(itemId)?.toFindroidSegments()
|
||||
}
|
||||
|
||||
override suspend fun getTrickplayData(
|
||||
itemId: UUID,
|
||||
width: Int,
|
||||
index: Int,
|
||||
): ByteArray? =
|
||||
override suspend fun getTrickplayData(itemId: UUID, width: Int, index: Int): ByteArray? =
|
||||
withContext(Dispatchers.IO) {
|
||||
try {
|
||||
val sources = File(context.filesDir, "trickplay/$itemId").listFiles() ?: return@withContext null
|
||||
|
@ -228,11 +200,7 @@ class JellyfinRepositoryOfflineImpl(
|
|||
|
||||
override suspend fun postPlaybackStart(itemId: UUID) {}
|
||||
|
||||
override suspend fun postPlaybackStop(
|
||||
itemId: UUID,
|
||||
positionTicks: Long,
|
||||
playedPercentage: Int,
|
||||
) {
|
||||
override suspend fun postPlaybackStop(itemId: UUID, positionTicks: Long, playedPercentage: Int) {
|
||||
withContext(Dispatchers.IO) {
|
||||
when {
|
||||
playedPercentage < 10 -> {
|
||||
|
@ -292,31 +260,35 @@ class JellyfinRepositoryOfflineImpl(
|
|||
}
|
||||
}
|
||||
|
||||
override fun getBaseUrl(): String = ""
|
||||
override fun getBaseUrl(): String {
|
||||
return ""
|
||||
}
|
||||
|
||||
override suspend fun updateDeviceName(name: String) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun getUserConfiguration(): UserConfiguration? = null
|
||||
override suspend fun getUserConfiguration(): UserConfiguration? {
|
||||
return null
|
||||
}
|
||||
|
||||
override suspend fun getDownloads(): List<FindroidItem> =
|
||||
withContext(Dispatchers.IO) {
|
||||
val items = mutableListOf<FindroidItem>()
|
||||
items.addAll(
|
||||
database
|
||||
.getMoviesByServerId(appPreferences.currentServer!!)
|
||||
database.getMoviesByServerId(appPreferences.currentServer!!)
|
||||
.map { it.toFindroidMovie(database, jellyfinApi.userId!!) },
|
||||
)
|
||||
items.addAll(
|
||||
database
|
||||
.getShowsByServerId(appPreferences.currentServer!!)
|
||||
database.getShowsByServerId(appPreferences.currentServer!!)
|
||||
.map { it.toFindroidShow(database, jellyfinApi.userId!!) },
|
||||
)
|
||||
items
|
||||
}
|
||||
|
||||
override fun getUserId(): UUID = jellyfinApi.userId!!
|
||||
override fun getUserId(): UUID {
|
||||
return jellyfinApi.userId!!
|
||||
}
|
||||
|
||||
override suspend fun getDeviceId(): String {
|
||||
TODO("Not yet implemented")
|
||||
|
@ -325,29 +297,17 @@ class JellyfinRepositoryOfflineImpl(
|
|||
override suspend fun buildDeviceProfile(
|
||||
maxBitrate: Int,
|
||||
container: String,
|
||||
context: EncodingContext,
|
||||
context: EncodingContext
|
||||
): DeviceProfile {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun getVideoStreambyContainerUrl(
|
||||
itemId: UUID,
|
||||
deviceId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String,
|
||||
videoBitrate: Int,
|
||||
container: String,
|
||||
maxHeight: Int,
|
||||
): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun getTranscodedVideoStream(
|
||||
itemId: UUID,
|
||||
deviceId: String,
|
||||
mediaSourceId: String,
|
||||
playSessionId: String,
|
||||
videoBitrate: Int,
|
||||
container: String
|
||||
): String {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
@ -356,7 +316,7 @@ class JellyfinRepositoryOfflineImpl(
|
|||
itemId: UUID,
|
||||
enableDirectStream: Boolean,
|
||||
deviceProfile: DeviceProfile,
|
||||
maxBitrate: Int,
|
||||
maxBitrate: Int
|
||||
): Response<PlaybackInfoResponse> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
|
@ -365,7 +325,7 @@ class JellyfinRepositoryOfflineImpl(
|
|||
TODO("Not yet implemented")
|
||||
}
|
||||
|
||||
override suspend fun getAccessToken(): String? {
|
||||
override suspend fun getVideoTranscodeBitRate(transcodeResolution: Int): Pair<Int, Int> {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,6 @@ libmpv = "0.3.0"
|
|||
material = "1.12.0"
|
||||
media3-ffmpeg-decoder = "1.3.1+2"
|
||||
timber = "5.0.1"
|
||||
markwon = "4.6.2"
|
||||
|
||||
[libraries]
|
||||
aboutlibraries-core = { group = "com.mikepenz", name = "aboutlibraries-core", version.ref = "aboutlibraries" }
|
||||
|
@ -100,7 +99,6 @@ material = { group = "com.google.android.material", name = "material", version.r
|
|||
media3-ffmpeg-decoder = { group = "org.jellyfin.media3", name = "media3-ffmpeg-decoder", version.ref = "media3-ffmpeg-decoder" }
|
||||
timber = { group = "com.jakewharton.timber", name = "timber", version.ref = "timber" }
|
||||
kotlinx-serialization-json = { group = "org.jetbrains.kotlinx", name = "kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
|
||||
markwon = { group = "io.noties.markwon", name = "core", version.ref = "markwon" }
|
||||
|
||||
[plugins]
|
||||
aboutlibraries = { id = "com.mikepenz.aboutlibraries.plugin", version.ref = "aboutlibraries" }
|
||||
|
|
1
lint.xml
1
lint.xml
|
@ -1,5 +1,4 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lint>
|
||||
<issue id="MissingTranslation" severity="ignore" />
|
||||
|
||||
</lint>
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
package com.nomadics9.ananas
|
||||
|
||||
import androidx.media3.common.MimeTypes
|
||||
|
||||
public fun setSubtitlesMimeTypes(codec: String): String {
|
||||
return when (codec) {
|
||||
"subrip" -> MimeTypes.APPLICATION_SUBRIP
|
||||
"webvtt" -> MimeTypes.TEXT_VTT
|
||||
"ssa" -> MimeTypes.TEXT_SSA
|
||||
"pgs" -> MimeTypes.APPLICATION_PGS
|
||||
"ass" -> MimeTypes.TEXT_SSA
|
||||
"srt" -> MimeTypes.APPLICATION_SUBRIP
|
||||
"vtt" -> MimeTypes.TEXT_VTT
|
||||
"ttml" -> MimeTypes.APPLICATION_TTML
|
||||
"dfxp" -> MimeTypes.APPLICATION_TTML
|
||||
"stl" -> MimeTypes.APPLICATION_TTML
|
||||
"sbv" -> MimeTypes.APPLICATION_SUBRIP
|
||||
else -> MimeTypes.TEXT_UNKNOWN
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -18,7 +18,6 @@ import com.nomadics9.ananas.models.PlayerChapter
|
|||
import com.nomadics9.ananas.models.PlayerItem
|
||||
import com.nomadics9.ananas.models.TrickplayInfo
|
||||
import com.nomadics9.ananas.repository.JellyfinRepository
|
||||
import com.nomadics9.ananas.setSubtitlesMimeTypes
|
||||
import kotlinx.coroutines.channels.Channel
|
||||
import kotlinx.coroutines.flow.receiveAsFlow
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -137,22 +136,7 @@ class PlayerViewModel @Inject internal constructor(
|
|||
} else {
|
||||
mediaSources[mediaSourceIndex]
|
||||
}
|
||||
// Embedded Sub externally for offline playback
|
||||
val externalSubtitles = if (mediaSource.type.toString() == "LOCAL" ) {
|
||||
mediaSource.mediaStreams
|
||||
.filter { mediaStream ->
|
||||
mediaStream.type == MediaStreamType.SUBTITLE && !mediaStream.path.isNullOrBlank()
|
||||
}
|
||||
.map { mediaStream ->
|
||||
ExternalSubtitle(
|
||||
mediaStream.title,
|
||||
mediaStream.language,
|
||||
Uri.parse(mediaStream.path!!),
|
||||
setSubtitlesMimeTypes(mediaStream.codec),
|
||||
)
|
||||
}
|
||||
}else {
|
||||
mediaSource.mediaStreams
|
||||
val externalSubtitles = mediaSource.mediaStreams
|
||||
.filter { mediaStream ->
|
||||
mediaStream.isExternal && mediaStream.type == MediaStreamType.SUBTITLE && !mediaStream.path.isNullOrBlank()
|
||||
}
|
||||
|
@ -161,10 +145,14 @@ class PlayerViewModel @Inject internal constructor(
|
|||
mediaStream.title,
|
||||
mediaStream.language,
|
||||
Uri.parse(mediaStream.path!!),
|
||||
setSubtitlesMimeTypes(mediaStream.codec)
|
||||
when (mediaStream.codec) {
|
||||
"subrip" -> MimeTypes.APPLICATION_SUBRIP
|
||||
"webvtt" -> MimeTypes.APPLICATION_SUBRIP
|
||||
"ass" -> MimeTypes.TEXT_SSA
|
||||
else -> MimeTypes.TEXT_UNKNOWN
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
val trickplayInfo = when (this) {
|
||||
is FindroidSources -> {
|
||||
this.trickplayInfo?.get(mediaSource.id)?.let {
|
||||
|
|
|
@ -121,11 +121,6 @@ constructor(
|
|||
Constants.NETWORK_DEFAULT_SOCKET_TIMEOUT.toString(),
|
||||
)!!.toLongOrNull() ?: Constants.NETWORK_DEFAULT_SOCKET_TIMEOUT
|
||||
|
||||
val transcodeCodec get() = sharedPreferences.getString(
|
||||
Constants.PREF_NETWORK_CODEC,
|
||||
Constants.NETWORK_DEFAULT_CODEC,
|
||||
)
|
||||
|
||||
// Cache
|
||||
val imageCache get() = sharedPreferences.getBoolean(
|
||||
Constants.PREF_IMAGE_CACHE,
|
||||
|
@ -155,9 +150,8 @@ constructor(
|
|||
|
||||
val downloadQualityDefault get() = sharedPreferences.getBoolean(
|
||||
Constants.PREF_DOWNLOADS_QUALITY_DEFAULT,
|
||||
false,
|
||||
)
|
||||
|
||||
false
|
||||
)
|
||||
|
||||
// Sorting
|
||||
var sortBy: String
|
||||
|
|
|
@ -43,7 +43,6 @@ object Constants {
|
|||
const val PREF_NETWORK_REQUEST_TIMEOUT = "pref_network_request_timeout"
|
||||
const val PREF_NETWORK_CONNECT_TIMEOUT = "pref_network_connect_timeout"
|
||||
const val PREF_NETWORK_SOCKET_TIMEOUT = "pref_network_socket_timeout"
|
||||
const val PREF_NETWORK_CODEC = "pref_network_codec"
|
||||
const val PREF_DOWNLOADS_MOBILE_DATA = "pref_downloads_mobile_data"
|
||||
const val PREF_DOWNLOADS_ROAMING = "pref_downloads_roaming"
|
||||
const val PREF_DOWNLOADS_QUALITY = "pref_downloads_quality"
|
||||
|
@ -64,7 +63,6 @@ object Constants {
|
|||
const val NETWORK_DEFAULT_REQUEST_TIMEOUT = 30_000L
|
||||
const val NETWORK_DEFAULT_CONNECT_TIMEOUT = 6_000L
|
||||
const val NETWORK_DEFAULT_SOCKET_TIMEOUT = 10_000L
|
||||
const val NETWORK_DEFAULT_CODEC = "h264"
|
||||
|
||||
// sorting
|
||||
// This values must correspond to a SortString from [SortBy]
|
||||
|
|
1
version
1
version
|
@ -1 +0,0 @@
|
|||
0.10.6
|
Loading…
Reference in a new issue