switched to lua scripts

This commit is contained in:
Schnitzel5 2025-08-01 02:57:05 +02:00
parent f25233182a
commit 0fea3ab84e
21 changed files with 144 additions and 140 deletions

Binary file not shown.

View file

@ -481,16 +481,16 @@
"mpv_redownload_info": "Replaces old config files with new one!",
"mpv_download": "MPV config files are required!\nDownload now?",
"custom_buttons": "Custom buttons",
"custom_buttons_info": "Execute Javascript code with custom buttons",
"custom_buttons_info": "Execute lua code with custom buttons",
"custom_buttons_edit": "Edit custom buttons",
"custom_buttons_add": "Add custom button",
"custom_buttons_delete": "Delete custom button",
"custom_buttons_text": "Button text",
"custom_buttons_text_req": "Button text required",
"custom_buttons_js_code": "Javascript code",
"custom_buttons_js_code_req": "Javascript code required",
"custom_buttons_js_code_long": "Javascript code (on long press)",
"custom_buttons_startup": "Javascript code (on startup)",
"custom_buttons_js_code": "lua code",
"custom_buttons_js_code_req": "lua code required",
"custom_buttons_js_code_long": "lua code (on long press)",
"custom_buttons_startup": "lua code (on startup)",
"n_days": "{n} days",
"decoder": "Decoder",
"decoder_info": "Hardware decoding, pixel format, debanding",

View file

@ -2964,7 +2964,7 @@ abstract class AppLocalizations {
/// No description provided for @custom_buttons_info.
///
/// In en, this message translates to:
/// **'Execute Javascript code with custom buttons'**
/// **'Execute lua code with custom buttons'**
String get custom_buttons_info;
/// No description provided for @custom_buttons_edit.
@ -3000,25 +3000,25 @@ abstract class AppLocalizations {
/// No description provided for @custom_buttons_js_code.
///
/// In en, this message translates to:
/// **'Javascript code'**
/// **'lua code'**
String get custom_buttons_js_code;
/// No description provided for @custom_buttons_js_code_req.
///
/// In en, this message translates to:
/// **'Javascript code required'**
/// **'lua code required'**
String get custom_buttons_js_code_req;
/// No description provided for @custom_buttons_js_code_long.
///
/// In en, this message translates to:
/// **'Javascript code (on long press)'**
/// **'lua code (on long press)'**
String get custom_buttons_js_code_long;
/// No description provided for @custom_buttons_startup.
///
/// In en, this message translates to:
/// **'Javascript code (on startup)'**
/// **'lua code (on startup)'**
String get custom_buttons_startup;
/// No description provided for @n_days.

View file

@ -1524,8 +1524,7 @@ class AppLocalizationsAr extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1543,16 +1542,16 @@ class AppLocalizationsAr extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1526,8 +1526,7 @@ class AppLocalizationsAs extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1545,16 +1544,16 @@ class AppLocalizationsAs extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1537,8 +1537,7 @@ class AppLocalizationsDe extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1556,16 +1555,16 @@ class AppLocalizationsDe extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1525,8 +1525,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1544,16 +1543,16 @@ class AppLocalizationsEn extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1542,8 +1542,7 @@ class AppLocalizationsEs extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1561,16 +1560,16 @@ class AppLocalizationsEs extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1543,8 +1543,7 @@ class AppLocalizationsFr extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1562,16 +1561,16 @@ class AppLocalizationsFr extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1527,8 +1527,7 @@ class AppLocalizationsHi extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1546,16 +1545,16 @@ class AppLocalizationsHi extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1531,8 +1531,7 @@ class AppLocalizationsId extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1550,16 +1549,16 @@ class AppLocalizationsId extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1540,8 +1540,7 @@ class AppLocalizationsIt extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1559,16 +1558,16 @@ class AppLocalizationsIt extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1539,8 +1539,7 @@ class AppLocalizationsPt extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1558,16 +1557,16 @@ class AppLocalizationsPt extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1541,8 +1541,7 @@ class AppLocalizationsRu extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1560,16 +1559,16 @@ class AppLocalizationsRu extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1525,8 +1525,7 @@ class AppLocalizationsTh extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1544,16 +1543,16 @@ class AppLocalizationsTh extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1531,8 +1531,7 @@ class AppLocalizationsTr extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1550,16 +1549,16 @@ class AppLocalizationsTr extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -1496,8 +1496,7 @@ class AppLocalizationsZh extends AppLocalizations {
String get custom_buttons => 'Custom buttons';
@override
String get custom_buttons_info =>
'Execute Javascript code with custom buttons';
String get custom_buttons_info => 'Execute lua code with custom buttons';
@override
String get custom_buttons_edit => 'Edit custom buttons';
@ -1515,16 +1514,16 @@ class AppLocalizationsZh extends AppLocalizations {
String get custom_buttons_text_req => 'Button text required';
@override
String get custom_buttons_js_code => 'Javascript code';
String get custom_buttons_js_code => 'lua code';
@override
String get custom_buttons_js_code_req => 'Javascript code required';
String get custom_buttons_js_code_req => 'lua code required';
@override
String get custom_buttons_js_code_long => 'Javascript code (on long press)';
String get custom_buttons_js_code_long => 'lua code (on long press)';
@override
String get custom_buttons_startup => 'Javascript code (on startup)';
String get custom_buttons_startup => 'lua code (on startup)';
@override
String n_days(Object n) {

View file

@ -639,9 +639,9 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
.map(
(e) => (
e["title"] as String,
e["time"] is double
? (e["time"] as double).toInt() * 1000
: (e["time"] as int) * 1000,
e["timestamp"] is double
? (e["timestamp"] as double).toInt() * 1000
: (e["timestamp"] as int) * 1000,
),
)
.toList();
@ -677,20 +677,24 @@ class _AnimeStreamPageState extends riv.ConsumerState<AnimeStreamPage>
}
final dir = await provider.getMpvDirectory();
String scriptsDir = path.join(dir!.path, 'scripts');
final mpvFile = File('$scriptsDir/init_custom_buttons.js');
final mpvFile = File('$scriptsDir/init_custom_buttons.lua');
final content = StringBuffer();
content.write("var aniyomi = require('./init_aniyomi_functions');");
content.writeln("""local lua_modules = mp.find_config_file('scripts')
if lua_modules then
package.path = package.path .. ';' .. lua_modules .. '/?.lua;' .. lua_modules .. '/?/init.lua;' .. '\${scriptsDir()!!.filePath}' .. '/?.lua'
end
local aniyomi = require 'init_aniyomi_functions'""");
for (final button in customButtons) {
content.write(
content.writeln(
"""
${button.getButtonStartup(primaryButton.id!).trim()}
function button${button.id}() {
function button${button.id}()
${button.getButtonPress(primaryButton.id!).trim()}
}
end
mp.register_script_message('call_button_${button.id}', button${button.id})
function button${button.id}long() {
function button${button.id}long()
${button.getButtonLongPress(primaryButton.id!).trim()}
}
end
mp.register_script_message('call_button_${button.id}_long', button${button.id}long)""",
);
}

View file

@ -211,20 +211,25 @@ class StorageProvider {
CustomButton(
title: "+85 s",
codePress:
"""var intro_length = mp.get_property_number("user-data/current-anime/intro-length")
"""local intro_length = mp.get_property_number("user-data/current-anime/intro-length")
aniyomi.right_seek_by(intro_length)""",
codeLongPress:
"""aniyomi.int_picker("Change intro length", "%ds", 0, 255, 1, "user-data/current-anime/intro-length")""",
codeStartup: """function update_button(_, length) {
if (length && length == 0) {
aniyomi.hide_button()
} else {
aniyomi.show_button()
}
aniyomi.set_button_title("+" + length + " s")
if (\$isPrimary) {
mp.observe_property("user-data/current-anime/intro-length", "number", update_button)
}""",
codeStartup: """function update_button(_, length)
if length ~= nil then
if length == 0 then
aniyomi.hide_button()
return
else
aniyomi.show_button()
end
aniyomi.set_button_title("+" .. length .. " s")
end
end
if \$isPrimary then
mp.observe_property("user-data/current-anime/intro-length", "number", update_button)
end""",
isFavourite: true,
pos: 0,
updatedAt: DateTime.now().millisecondsSinceEpoch,

View file

@ -1171,50 +1171,56 @@ packages:
media_kit_libs_android_video:
dependency: transitive
description:
name: media_kit_libs_android_video
sha256: adff9b571b8ead0867f9f91070f8df39562078c0eb3371d88b9029a2d547d7b7
url: "https://pub.dev"
source: hosted
path: "libs/android/media_kit_libs_android_video"
ref: HEAD
resolved-ref: a02ac2f7e6118cdab855ecacd194fa9ee6961a18
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.3.7"
media_kit_libs_ios_video:
dependency: transitive
description:
name: media_kit_libs_ios_video
sha256: b5382994eb37a4564c368386c154ad70ba0cc78dacdd3fb0cd9f30db6d837991
url: "https://pub.dev"
source: hosted
path: "libs/ios/media_kit_libs_ios_video"
ref: HEAD
resolved-ref: a02ac2f7e6118cdab855ecacd194fa9ee6961a18
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.1.4"
media_kit_libs_linux:
dependency: transitive
description:
name: media_kit_libs_linux
sha256: "2b473399a49ec94452c4d4ae51cfc0f6585074398d74216092bf3d54aac37ecf"
url: "https://pub.dev"
source: hosted
path: "libs/linux/media_kit_libs_linux"
ref: HEAD
resolved-ref: a02ac2f7e6118cdab855ecacd194fa9ee6961a18
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.2.1"
media_kit_libs_macos_video:
dependency: transitive
description:
name: media_kit_libs_macos_video
sha256: f26aa1452b665df288e360393758f84b911f70ffb3878032e1aabba23aa1032d
url: "https://pub.dev"
source: hosted
path: "libs/macos/media_kit_libs_macos_video"
ref: HEAD
resolved-ref: a02ac2f7e6118cdab855ecacd194fa9ee6961a18
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.1.4"
media_kit_libs_video:
dependency: "direct main"
description:
name: media_kit_libs_video
sha256: "958cc55e7065d9d01f52a2842dab2a0812a92add18489f1006d864fb5e42a3ef"
url: "https://pub.dev"
source: hosted
path: "libs/universal/media_kit_libs_video"
ref: HEAD
resolved-ref: a02ac2f7e6118cdab855ecacd194fa9ee6961a18
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.0.6"
media_kit_libs_windows_video:
dependency: transitive
description:
name: media_kit_libs_windows_video
sha256: dff76da2778729ab650229e6b4ec6ec111eb5151431002cbd7ea304ff1f112ab
url: "https://pub.dev"
source: hosted
path: "libs/windows/media_kit_libs_windows_video"
ref: HEAD
resolved-ref: a02ac2f7e6118cdab855ecacd194fa9ee6961a18
url: "https://github.com/Schnitzel5/media-kit.git"
source: git
version: "1.0.11"
media_kit_video:
dependency: "direct main"

View file

@ -49,7 +49,10 @@ dependencies:
git:
url: https://github.com/Schnitzel5/media-kit.git
path: media_kit_video
media_kit_libs_video: ^1.0.6
media_kit_libs_video:
git:
url: https://github.com/Schnitzel5/media-kit.git
path: libs/universal/media_kit_libs_video
crypto: ^3.0.6
cupertino_icons: ^1.0.8
window_manager: ^0.4.3