diff --git a/app/(auth)/player/direct-player.tsx b/app/(auth)/player/direct-player.tsx index a4bbfc92..67cebe57 100644 --- a/app/(auth)/player/direct-player.tsx +++ b/app/(auth)/player/direct-player.tsx @@ -128,15 +128,21 @@ export default function page() { if (!data?.mediaSource) return null; let m3u8Url = ""; - const path = `${FileSystem.documentDirectory}/downloads/${item?.Id}/Data`; - const files = await FileSystem.readDirectoryAsync(path); + if (Platform.OS === "ios") { + const path = `${FileSystem.documentDirectory}/downloads/${item?.Id}/Data`; + const files = await FileSystem.readDirectoryAsync(path); - for (const file of files) { - if (file.endsWith(".m3u8")) { - console.log(file); - m3u8Url = `${path}/${file}`; - break; + for (const file of files) { + if (file.endsWith(".m3u8")) { + console.log(file); + m3u8Url = `${path}/${file}`; + break; + } } + } else if (Platform.OS === "android") { + m3u8Url = `${FileSystem.documentDirectory}/downloads/${item?.Id}/playlist.m3u8`; + const fileContents = await FileSystem.readAsStringAsync(m3u8Url); + console.log(fileContents); } if (!m3u8Url) throw new Error("No m3u8 file found"); diff --git a/modules/hls-downloader/android/build.gradle b/modules/hls-downloader/android/build.gradle index cef9c7e2..a9a6650c 100644 --- a/modules/hls-downloader/android/build.gradle +++ b/modules/hls-downloader/android/build.gradle @@ -46,6 +46,7 @@ dependencies { def media3_version = "1.2.1" implementation "androidx.media3:media3-exoplayer:$media3_version" implementation "androidx.media3:media3-exoplayer-hls:$media3_version" + implementation "androidx.media3:media3-exoplayer-dash:$media3_version" implementation "androidx.media3:media3-database:$media3_version" implementation "androidx.media3:media3-datasource:$media3_version" } @@ -76,12 +77,11 @@ android { } kotlin { - jvmToolchain(17) + jvmToolchain(17) } tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).configureEach { kotlinOptions { - freeCompilerArgs += ["-Xshow-kotlin-compiler-errors"] jvmTarget = "17" } } \ No newline at end of file diff --git a/modules/hls-downloader/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar b/modules/hls-downloader/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar index 4ec7b15d..dddf760b 100644 Binary files a/modules/hls-downloader/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar and b/modules/hls-downloader/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar differ diff --git a/modules/hls-downloader/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties b/modules/hls-downloader/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties index 711618c5..e547cb78 100644 --- a/modules/hls-downloader/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +++ b/modules/hls-downloader/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties @@ -1 +1 @@ -#Mon Feb 17 21:32:35 CET 2025 +#Sat Feb 22 14:00:04 CET 2025 diff --git a/modules/hls-downloader/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar b/modules/hls-downloader/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar index 35535437..a8dfee24 100644 Binary files a/modules/hls-downloader/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar and b/modules/hls-downloader/android/build/intermediates/runtime_library_classes_jar/debug/bundleLibRuntimeToJarDebug/classes.jar differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab index 605fed36..09096053 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at index 6d7dcd9e..20a30a55 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/inputs/source-to-output.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab index e6bc45dc..2d413c18 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at index 9e593fa7..850852da 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-attributes.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab index 078492c1..2fab24e0 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at index ad38cfe6..c272a17d 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/class-fq-name-to-source.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab index b1ed9270..ea3cc30d 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream index fd242941..8b47fb19 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len index 5318c25b..f948122a 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.keystream.len differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len index 14f7c061..6f677df7 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.len differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at index be019b5d..1108e424 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i index 5a5c51d6..8490c4cb 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/internal-name-to-source.tab_i differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab index 289bf7c8..d15562c8 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at index 38464473..3bfe996f 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab index 390fd25c..133cb90f 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at index 0e088a3c..ffaf651d 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/source-to-classes.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab index 44636a11..fc937879 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at index 7341f98e..b16c7162 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/subtypes.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab index d19d17b9..9b705a47 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at index 4ed69115..11f4b13b 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/supertypes.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab index 4a12deaa..0737472a 100644 --- a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab +++ b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/counters.tab @@ -1,2 +1,2 @@ -5 +10 0 \ No newline at end of file diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab index d4be18c5..c188e64a 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at index f6a4f172..263bcd3c 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/file-to-id.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab index 60965b02..96acd5c8 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream index 1dd772ce..8ad02ff9 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len index 62f3e6ff..c15663dd 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.keystream.len differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len index ec8f944c..fd5292d4 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.len differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at index 2b490fb9..2d47b43d 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i index e6ff6ac7..5f2acb46 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/id-to-file.tab_i differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab index e1511c1d..4382b741 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream index ffc373c6..5f905e64 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len index 396abe0c..9c1e85c7 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len index e862f594..e66d94da 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at index ef46d859..ec8142cb 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i index 993e28e4..6fcc6739 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin index 7e07d8bc..9d5f4b2e 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin differ diff --git a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin index 8abafdc7..142660aa 100644 Binary files a/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin and b/modules/hls-downloader/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin differ diff --git a/modules/hls-downloader/android/build/kotlin/kaptGenerateStubsDebugKotlin/cacheable/last-build.bin b/modules/hls-downloader/android/build/kotlin/kaptGenerateStubsDebugKotlin/cacheable/last-build.bin index 3b549641..5231507f 100644 Binary files a/modules/hls-downloader/android/build/kotlin/kaptGenerateStubsDebugKotlin/cacheable/last-build.bin and b/modules/hls-downloader/android/build/kotlin/kaptGenerateStubsDebugKotlin/cacheable/last-build.bin differ diff --git a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$1$1$1.class b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$1$1$1.class index d6d58955..b208bde3 100644 Binary files a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$1$1$1.class and b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$1$1$1.class differ diff --git a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$4.class b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$4.class index 3dc73222..81825866 100644 Binary files a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$4.class and b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$4.class differ diff --git a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$6.class b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$6.class index acb271f9..53ab50a1 100644 Binary files a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$6.class and b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$Function$6.class differ diff --git a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$FunctionWithoutArgs$1.class b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$FunctionWithoutArgs$1.class index f8f97d21..6c1625ad 100644 Binary files a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$FunctionWithoutArgs$1.class and b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$FunctionWithoutArgs$1.class differ diff --git a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$OnCreate$1.class b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$OnCreate$1.class index df32bc8e..67f4407c 100644 Binary files a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$OnCreate$1.class and b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule$definition$lambda$6$$inlined$OnCreate$1.class differ diff --git a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule.class b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule.class index e68288e6..2014e658 100644 Binary files a/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule.class and b/modules/hls-downloader/android/build/tmp/kotlin-classes/debug/expo/modules/hlsdownloader/HlsDownloaderModule.class differ diff --git a/modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.alt.kt b/modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.alt.kt.bak similarity index 100% rename from modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.alt.kt rename to modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.alt.kt.bak diff --git a/modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.kt b/modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.kt index 4db5537d..3a3cd55a 100644 --- a/modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.kt +++ b/modules/hls-downloader/android/src/main/java/expo/modules/hls-downloader/HlsDownloaderModule.kt @@ -41,15 +41,28 @@ class HlsDownloaderModule : Module() { OnCreate { android.util.Log.d(TAG, "Creating HLS Downloader module") val context = appContext.reactContext as Context - - val cacheDir = File(context.filesDir, "downloads") - if (!cacheDir.exists()) { - cacheDir.mkdirs() - android.util.Log.d(TAG, "Created base downloads directory: ${cacheDir.absolutePath}") + + // Create the base downloads directory + val baseDownloadsDir = File(context.filesDir, "downloads") + if (!baseDownloadsDir.exists()) { + baseDownloadsDir.mkdirs() + android.util.Log.d(TAG, "Created base downloads directory: ${baseDownloadsDir.absolutePath}") } val databaseProvider = StandaloneDatabaseProvider(context) - downloadCache = SimpleCache(cacheDir, NoOpCacheEvictor(), databaseProvider) + + // Initialize the cache with a temporary directory + val tempCacheDir = File(baseDownloadsDir, "temp") + if (!tempCacheDir.exists()) { + tempCacheDir.mkdirs() + android.util.Log.d(TAG, "Created temp cache directory: ${tempCacheDir.absolutePath}") + } + + downloadCache = SimpleCache( + tempCacheDir, + NoOpCacheEvictor(), + databaseProvider + ) val dataSourceFactory = DefaultHttpDataSource.Factory() .setUserAgent("Streamyfin/1.0") @@ -76,6 +89,24 @@ class HlsDownloaderModule : Module() { when (download.state) { Download.STATE_COMPLETED -> { android.util.Log.d(TAG, "Download completed for ${metadata.providedId}") + + // Move files from temp directory to providerId directory + val tempDir = File(baseDownloadsDir, "temp") + val providerDir = File(baseDownloadsDir, metadata.providedId) + if (tempDir.exists() && tempDir.isDirectory) { + tempDir.listFiles()?.forEach { file -> + val destination = File(providerDir, file.name) + if (file.renameTo(destination)) { + android.util.Log.d(TAG, "Moved ${file.name} to ${destination.absolutePath}") + } else { + android.util.Log.e(TAG, "Failed to move ${file.name} to ${destination.absolutePath}") + } + } + } + + // Generate the .m3u8 playlist + createM3U8Playlist(context, metadata.providedId) + sendEvent( "onComplete", mapOf( @@ -163,11 +194,11 @@ class HlsDownloaderModule : Module() { } Function("downloadHLSAsset") { providedId: String, url: String, metadata: Map? -> - android.util.Log.d(TAG, "Starting download for $providedId from $url") + android.util.Log.d(TAG, "Starting download for $providedId from $url") val startTime = System.currentTimeMillis() val context = appContext.reactContext as Context - // Create the directory for this download + // Create the specific download directory val downloadDir = File(context.filesDir, "downloads/$providedId") if (!downloadDir.exists()) { downloadDir.mkdirs() @@ -175,12 +206,15 @@ class HlsDownloaderModule : Module() { } try { - val downloadRequest = DownloadRequest.Builder( - providedId, - Uri.parse(url) - ) - .setStreamKeys(emptyList()) - .build() + // Create MediaItem with proper URI + val mediaItem = MediaItem.Builder() + .setUri(Uri.parse(url)) + .setCustomCacheKey(providedId) // This is optional and depends on the media type + .build() + + val downloadRequest = DownloadRequest.Builder(providedId, Uri.parse(url)) + .setData(providedId.toByteArray()) + .build() downloadManager.addDownload(downloadRequest) android.util.Log.d(TAG, "Download request added for $providedId") @@ -244,15 +278,14 @@ class HlsDownloaderModule : Module() { private fun saveMetadataFile(metadata: DownloadMetadata) { try { val context = appContext.reactContext as Context - // Create metadata file in internal storage + // Save the metadata file directly in the /downloads folder val metadataFile = File( context.filesDir, - "downloads/${metadata.providedId}/${metadata.providedId}.json" + "downloads/${metadata.providedId}.json" // Save outside the providerId folder ) - - // Ensure the parent directory exists + metadataFile.parentFile?.mkdirs() - + android.util.Log.d(TAG, "Saving metadata to: ${metadataFile.absolutePath}") metadataFile.writeText(JSONObject(metadata.metadata).toString()) } catch (e: Exception) { @@ -260,5 +293,68 @@ class HlsDownloaderModule : Module() { e.printStackTrace() } } -} + private fun createM3U8Playlist(context: Context, providerId: String) { + val providerDir = File(context.filesDir, "downloads/$providerId") + + // Check if the provider directory exists + if (!providerDir.exists() || !providerDir.isDirectory) { + android.util.Log.e("M3U8", "Provider directory does not exist: ${providerDir.absolutePath}") + return + } + + // List all subfolders (0/, 1/, 2/, etc.) + val subFolders = providerDir.listFiles { file -> + file.isDirectory && file.name.matches(Regex("\\d+")) // Match folders with numeric names + } + + if (subFolders.isNullOrEmpty()) { + android.util.Log.e("M3U8", "No subfolders found in ${providerDir.absolutePath}") + return + } + + // Collect all .v3.exo files from subfolders + val segmentFiles = mutableListOf() + subFolders.forEach { folder -> + val filesInFolder = folder.listFiles { file -> + file.isFile && file.name.endsWith(".v3.exo") + } + if (!filesInFolder.isNullOrEmpty()) { + segmentFiles.addAll(filesInFolder) + } + } + + if (segmentFiles.isEmpty()) { + android.util.Log.e("M3U8", "No .v3.exo files found in any subfolder") + return + } + + // Sort files by their numeric names (e.g., 102.124532.v3.exo) + val sortedFiles = segmentFiles.sortedBy { file -> + file.nameWithoutExtension.toDoubleOrNull() ?: 0.0 + } + + // Create the .m3u8 file + val m3u8File = File(providerDir, "playlist.m3u8") + m3u8File.bufferedWriter().use { writer -> + // Write the M3U8 header + writer.write("#EXTM3U\n") + writer.write("#EXT-X-VERSION:3\n") + writer.write("#EXT-X-TARGETDURATION:10\n") // Adjust target duration as needed + writer.write("#EXT-X-MEDIA-SEQUENCE:0\n") // Start sequence from 0 + + // Write each segment with absolute path + sortedFiles.forEach { file -> + val segmentDuration = 10.0 // Adjust segment duration as needed + val absolutePath = "file://${file.absolutePath}" // Add file:// prefix and use absolute path + writer.write("#EXTINF:$segmentDuration,\n") + writer.write("$absolutePath\n") // Use absolute path instead of relative + } + + // Write the end tag + writer.write("#EXT-X-ENDLIST\n") + } + + android.util.Log.d("M3U8", "Playlist created at: ${m3u8File.absolutePath}") +} +} \ No newline at end of file