mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2026-05-16 21:12:39 +02:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3f22c7f717 | |||
| f36e9588cb | |||
| 8f99f399ee | |||
| 56166a7948 | |||
| 4edd8ee1ea | |||
| a830c918ab | |||
| 53f74c4b6e |
@@ -58,3 +58,9 @@
|
||||
[submodule "dep/futopay"]
|
||||
path = dep/futopay
|
||||
url = ../futopayclientlibraries.git
|
||||
[submodule "app/src/unstable/assets/sources/bilibili"]
|
||||
path = app/src/unstable/assets/sources/bilibili
|
||||
url = ../plugins/bilibili.git
|
||||
[submodule "app/src/stable/assets/sources/bilibili"]
|
||||
path = app/src/stable/assets/sources/bilibili
|
||||
url = ../plugins/bilibili.git
|
||||
|
||||
@@ -549,6 +549,8 @@ class Settings : FragmentedStorageFileJson() {
|
||||
@DropdownFieldOptionsId(R.array.log_levels)
|
||||
var logLevel: Int = 0;
|
||||
|
||||
fun isVerbose() = logLevel >= 4;
|
||||
|
||||
@FormField(R.string.submit_logs, FieldForm.BUTTON, R.string.submit_logs_to_help_us_narrow_down_issues, 1)
|
||||
fun submitLogs() {
|
||||
StateApp.instance.scopeOrNull?.launch(Dispatchers.IO) {
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.futo.platformplayer.stores.FragmentedStorage
|
||||
import com.futo.platformplayer.stores.SubscriptionStorage
|
||||
import com.futo.platformplayer.stores.v2.ManagedStore
|
||||
import com.futo.platformplayer.views.ToastView
|
||||
import com.futo.polycentric.core.ApiMethods
|
||||
import com.google.gson.JsonParser
|
||||
import com.google.zxing.integration.android.IntentIntegrator
|
||||
import kotlinx.coroutines.*
|
||||
@@ -154,6 +155,8 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
}
|
||||
|
||||
constructor() : super() {
|
||||
ApiMethods.UserAgent = "Grayjay Android (${BuildConfig.VERSION_CODE})";
|
||||
|
||||
Thread.setDefaultUncaughtExceptionHandler { _, throwable ->
|
||||
val writer = StringWriter();
|
||||
|
||||
@@ -192,6 +195,7 @@ class MainActivity : AppCompatActivity, IWithResultLauncher {
|
||||
}
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Logger.i(TAG, "MainActivity Starting");
|
||||
StateApp.instance.setGlobalContext(this, lifecycleScope);
|
||||
StateApp.instance.mainAppStarting(this);
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.futo.platformplayer.api.media.models
|
||||
import com.caoccao.javet.values.reference.V8ValueArray
|
||||
import com.caoccao.javet.values.reference.V8ValueObject
|
||||
import com.futo.platformplayer.engine.IV8PluginConfig
|
||||
import com.futo.platformplayer.engine.V8PluginConfig
|
||||
import com.futo.platformplayer.getOrDefault
|
||||
import com.futo.platformplayer.getOrThrow
|
||||
|
||||
@kotlinx.serialization.Serializable
|
||||
@@ -31,7 +33,7 @@ class Thumbnails {
|
||||
fun fromV8(config: IV8PluginConfig, value: V8ValueObject): Thumbnails {
|
||||
return Thumbnails((value.getOrThrow<V8ValueArray>(config, "sources", "Thumbnails"))
|
||||
.toArray()
|
||||
.map { Thumbnail.fromV8(it as V8ValueObject) }
|
||||
.map { Thumbnail.fromV8(config, it as V8ValueObject) }
|
||||
.toTypedArray());
|
||||
}
|
||||
}
|
||||
@@ -40,10 +42,10 @@ class Thumbnails {
|
||||
data class Thumbnail(val url : String?, val quality : Int = 0) {
|
||||
|
||||
companion object {
|
||||
fun fromV8(value: V8ValueObject): Thumbnail {
|
||||
fun fromV8(config: IV8PluginConfig, value: V8ValueObject): Thumbnail {
|
||||
return Thumbnail(
|
||||
value.getString("url"),
|
||||
value.getInteger("quality"));
|
||||
value.getOrDefault<String>(config,"url", "Thumbnail", null),
|
||||
value.getOrDefault(config, "quality", "Thumbnail", 0) ?: 0);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -7,6 +7,7 @@ import androidx.documentfile.provider.DocumentFile
|
||||
import com.arthenica.ffmpegkit.*
|
||||
import com.futo.platformplayer.api.media.models.streams.sources.*
|
||||
import com.futo.platformplayer.constructs.Event1
|
||||
import com.futo.platformplayer.helpers.FileHelper.Companion.sanitizeFileName
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import com.futo.platformplayer.states.StateApp
|
||||
import com.futo.platformplayer.toHumanBitrate
|
||||
@@ -63,7 +64,7 @@ class VideoExport {
|
||||
val outputFile: DocumentFile?;
|
||||
val downloadRoot = StateApp.instance.getExternalDownloadDirectory(context) ?: throw Exception("External download directory is not set");
|
||||
if (sourceCount > 1) {
|
||||
val outputFileName = toSafeFileName(videoLocal.name) + ".mp4"// + VideoDownload.videoContainerToExtension(v.container);
|
||||
val outputFileName = videoLocal.name.sanitizeFileName(true) + ".mp4"// + VideoDownload.videoContainerToExtension(v.container);
|
||||
val f = downloadRoot.createFile("video/mp4", outputFileName)
|
||||
?: throw Exception("Failed to create file in external directory.");
|
||||
|
||||
@@ -79,7 +80,7 @@ class VideoExport {
|
||||
}
|
||||
outputFile = f;
|
||||
} else if (v != null) {
|
||||
val outputFileName = toSafeFileName(videoLocal.name) + "." + VideoDownload.videoContainerToExtension(v.container);
|
||||
val outputFileName = videoLocal.name.sanitizeFileName(true) + "." + VideoDownload.videoContainerToExtension(v.container);
|
||||
val f = downloadRoot.createFile(v.container, outputFileName)
|
||||
?: throw Exception("Failed to create file in external directory.");
|
||||
|
||||
@@ -91,7 +92,7 @@ class VideoExport {
|
||||
|
||||
outputFile = f;
|
||||
} else if (a != null) {
|
||||
val outputFileName = toSafeFileName(videoLocal.name) + "." + VideoDownload.audioContainerToExtension(a.container);
|
||||
val outputFileName = videoLocal.name.sanitizeFileName(true) + "." + VideoDownload.audioContainerToExtension(a.container);
|
||||
val f = downloadRoot.createFile(a.container, outputFileName)
|
||||
?: throw Exception("Failed to create file in external directory.");
|
||||
|
||||
@@ -110,11 +111,6 @@ class VideoExport {
|
||||
return@coroutineScope outputFile;
|
||||
}
|
||||
|
||||
private fun toSafeFileName(input: String): String {
|
||||
val safeCharacters = ('a'..'z') + ('A'..'Z') + ('0'..'9') + listOf('-', '_')
|
||||
return input.map { if (it in safeCharacters) it else '_' }.joinToString(separator = "")
|
||||
}
|
||||
|
||||
private suspend fun combine(inputPathAudio: String?, inputPathVideo: String?, inputPathSubtitles: String?, outputPath: String, duration: Double, onProgress: ((Double) -> Unit)? = null) = withContext(Dispatchers.IO) {
|
||||
suspendCancellableCoroutine { continuation ->
|
||||
//ffmpeg -i a.mp4 -i b.m4a -scodec mov_text -i c.vtt -map 0:v -map 1:a -map 2 -c:v copy -c:a copy -c:s mov_text output.mp4
|
||||
|
||||
+2
-2
@@ -2231,11 +2231,11 @@ class VideoDetailView : ConstraintLayout {
|
||||
videoSourceHeight = 9;
|
||||
}
|
||||
val aspectRatio = videoSourceWidth.toDouble() / videoSourceHeight;
|
||||
if(aspectRatio > 3) {
|
||||
if(aspectRatio > 2.38) {
|
||||
videoSourceWidth = 16;
|
||||
videoSourceHeight = 9;
|
||||
}
|
||||
else if(aspectRatio < 0.3) {
|
||||
else if(aspectRatio < 0.43) {
|
||||
videoSourceHeight = 16;
|
||||
videoSourceWidth = 9;
|
||||
}
|
||||
|
||||
@@ -2,11 +2,17 @@ package com.futo.platformplayer.helpers
|
||||
|
||||
class FileHelper {
|
||||
companion object {
|
||||
val allowedCharacters = HashSet("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz-.".toCharArray().toList());
|
||||
|
||||
|
||||
fun String.sanitizeFileName(): String {
|
||||
return this.filter { allowedCharacters.contains(it) };
|
||||
fun String.sanitizeFileName(allowSpace: Boolean = false): String {
|
||||
return this.filter {
|
||||
(it in '0' .. '9') ||
|
||||
(it in 'a'..'z') ||
|
||||
(it in 'A'..'Z') ||
|
||||
(it == '-' || it == '.' || it == '_' || (it == ' ' && allowSpace)) ||
|
||||
(it in '丁'..'龤') || //Chinese/Kanji
|
||||
(it in '\u3040'..'\u309f') || //Hiragana
|
||||
(it in '\u30A0'..'\u30ff') || //Katakana
|
||||
(it in '\u0600'..'\u06FF') //Arabic
|
||||
}; //Chinese
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -43,7 +43,8 @@ class FileLogConsumer : ILogConsumer, Closeable {
|
||||
}
|
||||
|
||||
while (_linesToWrite.isNotEmpty()) {
|
||||
_writer?.appendLine(_linesToWrite.remove());
|
||||
val todo = _linesToWrite.remove()
|
||||
_writer?.appendLine(todo);
|
||||
}
|
||||
|
||||
_writer?.flush();
|
||||
@@ -85,7 +86,7 @@ class FileLogConsumer : ILogConsumer, Closeable {
|
||||
_running = false;
|
||||
_writer?.close();
|
||||
_writer = null;
|
||||
_logThread?.join();
|
||||
//_logThread?.join();
|
||||
_logThread = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ class StateApp {
|
||||
suspend fun backgroundStarting(context: Context, scope: CoroutineScope, withFiles: Boolean, withPlugins: Boolean) {
|
||||
if(contextOrNull == null) {
|
||||
Logger.i(TAG, "BACKGROUND STATE: Starting");
|
||||
if(!Logger.hasConsumers && BuildConfig.DEBUG) {
|
||||
if(!Logger.hasConsumers && (BuildConfig.DEBUG)) {
|
||||
Logger.i(TAG, "BACKGROUND STATE: Initialize logger");
|
||||
Logger.setLogConsumers(listOf(AndroidLogConsumer()));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.futo.platformplayer.api.media.models.video.IPlatformVideo
|
||||
import com.futo.platformplayer.api.media.models.video.IPlatformVideoDetails
|
||||
import com.futo.platformplayer.constructs.Event0
|
||||
import com.futo.platformplayer.constructs.Event1
|
||||
import com.futo.platformplayer.logging.Logger
|
||||
import com.futo.platformplayer.models.Playlist
|
||||
import com.futo.platformplayer.services.MediaPlaybackService
|
||||
import com.futo.platformplayer.video.PlayerManager
|
||||
@@ -633,6 +634,7 @@ class StatePlayer {
|
||||
val instance = _instance;
|
||||
_instance = null;
|
||||
instance?.dispose();
|
||||
Logger.i(TAG, "Disposed StatePlayer");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -134,8 +134,11 @@ class StatePlugins {
|
||||
val embeddedConfig = getEmbeddedPluginConfig(context, embedded.value);
|
||||
if(embeddedConfig != null) {
|
||||
val existing = getPlugin(embedded.key);
|
||||
if(existing != null && (existing.config.version < embeddedConfig.version || (force || FORCE_REINSTALL_EMBEDDED))) {
|
||||
Logger.i(TAG, "Outdated Embedded plugin [${existing.config.id}] ${existing.config.name} (${existing.config.version} < ${embeddedConfig.version}), reinstalling");
|
||||
if(existing == null || (existing.config.version < embeddedConfig.version || (force || FORCE_REINSTALL_EMBEDDED))) {
|
||||
if (existing != null)
|
||||
Logger.i(TAG, "Outdated Embedded plugin [${existing.config.id}] ${existing.config.name} (${existing.config.version} < ${embeddedConfig.version}), reinstalling");
|
||||
else
|
||||
Logger.i(TAG, "Embedded plugin nog installed [${embeddedConfig.id}] ${embeddedConfig.name} (${embeddedConfig.version}), installing");
|
||||
installEmbeddedPlugin(context, embedded.value)
|
||||
}
|
||||
else if(existing != null && _isFirstEmbedUpdate) {
|
||||
|
||||
Submodule
+1
Submodule app/src/stable/assets/sources/bilibili added at 3cc6d553cf
@@ -8,12 +8,12 @@
|
||||
"c0f315f9-0992-4508-a061-f2738724c331": "sources/twitch/TwitchConfig.json",
|
||||
"4a78c2ff-c20f-43ac-8f75-34515df1d320": "sources/kick/KickConfig.json",
|
||||
"aac9e9f0-24b5-11ee-be56-0242ac120002": "sources/patreon/PatreonConfig.json",
|
||||
"9d703ff5-c556-4962-a990-4f000829cb87": "sources/nebula/NebulaConfig.json"
|
||||
"9d703ff5-c556-4962-a990-4f000829cb87": "sources/nebula/NebulaConfig.json",
|
||||
"cf8ea74d-ad9b-489e-a083-539b6aa8648c": "sources/bilibili/build/BiliBiliConfig.json"
|
||||
},
|
||||
"SOURCES_EMBEDDED_DEFAULT": [
|
||||
"35ae969a-a7db-11ed-afa1-0242ac120002"
|
||||
],
|
||||
"SOURCES_UNDER_CONSTRUCTION": {
|
||||
"Subscribestar": "logo_subscribestar"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.futo.platformplayer
|
||||
|
||||
import com.futo.platformplayer.helpers.FileHelper.Companion.sanitizeFileName
|
||||
import org.junit.Assert
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import java.time.OffsetDateTime
|
||||
import java.time.ZoneOffset
|
||||
|
||||
class ExtensionsFileTests {
|
||||
@Test
|
||||
fun test_sanitizeFileName1() {
|
||||
assertEquals("Helloworld", "Hello world".sanitizeFileName());
|
||||
assertEquals("Hello world", "Hello world".sanitizeFileName(true));
|
||||
assertEquals("漫漫听-点唱-公主冠", "漫漫听-点唱- 公主冠".sanitizeFileName());
|
||||
assertEquals("食べる", "食べ る".sanitizeFileName()); //Hiragana
|
||||
assertEquals("テレビ", "テレ ビ".sanitizeFileName()); //Katakana
|
||||
assertEquals("يخبر", "ي خبر".sanitizeFileName()); //Arabic
|
||||
assertEquals("..testing", "../testing".sanitizeFileName()); //Escaping
|
||||
}
|
||||
}
|
||||
Submodule
+1
Submodule app/src/unstable/assets/sources/bilibili added at 3cc6d553cf
@@ -8,12 +8,13 @@
|
||||
"c0f315f9-0992-4508-a061-f2738724c331": "sources/twitch/TwitchConfig.json",
|
||||
"4a78c2ff-c20f-43ac-8f75-34515df1d320": "sources/kick/KickConfig.json",
|
||||
"aac9e9f0-24b5-11ee-be56-0242ac120002": "sources/patreon/PatreonConfig.json",
|
||||
"9d703ff5-c556-4962-a990-4f000829cb87": "sources/nebula/NebulaConfig.json"
|
||||
"9d703ff5-c556-4962-a990-4f000829cb87": "sources/nebula/NebulaConfig.json",
|
||||
"cf8ea74d-ad9b-489e-a083-539b6aa8648c": "sources/bilibili/build/BiliBiliConfig.json"
|
||||
},
|
||||
"SOURCES_EMBEDDED_DEFAULT": [
|
||||
"35ae969a-a7db-11ed-afa1-0242ac120002"
|
||||
],
|
||||
"SOURCES_UNDER_CONSTRUCTION": {
|
||||
"Subscribestar": "logo_subscribestar"
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
Submodule dep/polycentricandroid updated: 00927bb700...cedbb52d33
Reference in New Issue
Block a user