mik1ll / luarenamer Goto Github PK
View Code? Open in Web Editor NEWLua file renaming and moving plugin for Shoko. Uses Lua 5.4.
License: GNU Lesser General Public License v3.0
Lua file renaming and moving plugin for Shoko. Uses Lua 5.4.
License: GNU Lesser General Public License v3.0
Exhibit 1: Method not found: 'System.String Shoko.Plugin.Abstractions.DataModels.AniDBMediaData.get_VideoCodec()'
Check out the Abstractions changes https://github.com/ShokoAnime/ShokoServer/compare/e1d5bb..master?diff=unified
Two users, Eclipse and kero_chan reported this error when renaming files.
17:50:20| SVR_VideoLocal_Place --- System.InvalidCastException: Unable to cast object of type 'NLua.LuaUserData' to type 'KeraLua.LuaFunction'.
at NLua.Lua.GetFunction(String fullPath)
at NLua.Lua.RegisterFunction(String path, Object target, MethodBase function)
at LuaRenamer.LuaRenamer.CreateLuaEnv()
at LuaRenamer.LuaRenamer.RunSandboxed(String code)
at LuaRenamer.LuaRenamer.GetInfo()
at LuaRenamer.LuaRenamer.GetFilename(RenameEventArgs args)
at Shoko.Server.RenameFileHelper.GetFilename(SVR_VideoLocal_Place place, String scriptName) in /usr/src/app/source/Shoko.Server/Renamer/RenameFileHelper.cs:line 69
08:39:38| --- Trying to load /home/shoko/.shoko/Shoko.CLI/plugins/LuaRenamer/KeraLua.dll
Process terminated. A callback was made on a garbage collected delegate of type 'KeraLua!KeraLua.LuaFunction::Invoke'.
at KeraLua.NativeMethods.lua_settable(IntPtr, Int32)
08:40:56| --- Trying to load /home/shoko/.shoko/Shoko.CLI/plugins/LuaRenamer/KeraLua.dll
*Error: Unable to cast object of type 'NLua.LuaUserData' to type 'KeraLua.LuaFunction'.
*Error: Unable to cast object of type 'NLua.LuaUserData' to type 'KeraLua.LuaFunction'.
*Error: Unable to cast object of type 'NLua.LuaTable' to type 'KeraLua.LuaFunction'.
*Error: Unable to cast object of type 'NLua.LuaUserData' to type 'KeraLua.LuaFunction'.
08:58:45| --- Trying to load /home/shoko/.shoko/Shoko.CLI/plugins/LuaRenamer/KeraLua.dll
Make all folders available to the renamer through reflection or something.
LuaRenamer/LuaRenamer/LuaRenamer.cs
Line 341 in 4ab331d
Fix native linux assembly loading in shoko server first.
Probably remove additional arguments
Anidb rewrite added new title types, don't know if they are actually used anywhere though.
User Eclipse#8350 reported getting null reference exceptions on a few files.
Source of exception is somewhere inside CreateLuaEnv, but probably obfuscated because of object initializers.
Examples: https://anidb.net/file/2492883 https://anidb.net/file/2492898
Remove short circuit operators where possible. Allow nil assignments.
I have my ShokoServer on Docker (Manjaro Linux) and I use the Shoko Desktop app via Wine. I extracted the archive (linux version) to ~/.shoko/Shoko.CLI/plugin
(inside ~/.shoko/Shoko.CLI/plugin/LuaRenamer
is only lua
subdirectory and files - no nested LuaRenamer
directory). After restarting the server I opened Shoko Desktop, went to Utilities > File Renaming tab but there is no new renamer:
I managed to follow the install instructions for Linux and added the file to the .shoko/Shoko.CLI/plugins
folder. But since I am on Linux, I could not follow the usage instructions entirely. Instead, I modified sample script.lua
manually and saved it as my script.lua
in the same folder. At this point I'm not sure anymore what my next step should be. Is sample script.lua
the one that the renamer actually uses and should I not have created a new file? Or do I need to use a different name for it? Or add it to a configuration somewhere? I assume that Shoko Desktop does this for you, but I don't use that and it is not available on Linux. I'd appreciate some help with this.
In case you're curious about how I modified the sample script without Shoko Desktop. I basically removed all the logic and only kept the variables for the different parts that go into the filename. This allowed me to run it in an online runtime (JDoodle) so I could verify what the filename would be. This is the code that I used, maybe it'd be useful to add to the documentation somewhere (it could probably use better, more representative values for these variables).
local group = "[Fansub Group]"
local animename = "Isekai Anime"
animename = string.gsub(string.sub(animename, 0, 35), "%s+$", "") .. (#animename > 35 and "..." or "")
local episodename = "My First Day in Another World"
episodename = string.gsub(string.sub(episodename, 0, 35), "%s+$", "") .. (#episodename > 35 and "..." or "")
local episodenumber = "01"
local res = "1080p"
local codec = "AVC"
local bitdepth = "8bit"
local source = "HDD"
local fileinfo = "(" .. res .. " " .. codec .. " " .. bitdepth .. " " .. source .. ")"
local audiotag = "[AUDIOTAG]"
local subtag = "[SUBBED]"
local centag = "[UNCEN]"
local hashtag = "[deadbeef]"
local audios = "2.0"
local nametable = {group, animename, episodenumber, episodename, fileinfo, audiotag, subtag, centag, audios, hashtag}
filename = string.sub(table.concat(nametable, " "), 0, 120)
print(filename)
Currently, the renamer only runs on import and thats it. Due to that episodes with a title "Episode X" are not renamed to their actual name when/if it is eventually updated. It would be a nice addition to add an option to run the renamer whenever episode info is updated.
Find out how to remove redundant Fn constants
Source of error is from anime/episode getname lua function. (TitleFunction in LuaContext.cs)
Investigate possible changes in abstraction TitleType enum that causes this.
Error log from kero_chan#9048
13:22:26| SVR_VideoLocal_Place --- Error: The renamer returned an error on file: "/srv/Downloads/anime/[SubsPlease] Girls und Panzer das Finale - 03 (1080p) [EAD6892E].mkv"
*Error: ...hoko/.shoko/Shoko.CLI/plugins/LuaRenamer/lua/lualinq.lua:434: attempt to compare number with nil
13:22:26| SVR_VideoLocal_Place --- Attempting to MOVE file: "/srv/Downloads/anime/[SubsPlease] Girls und Panzer das Finale - 03 (1080p) [EAD6892E].mkv"
13:22:27| SVR_VideoLocal_Place --- Could not find a valid destination: "/srv/Downloads/anime/[SubsPlease] Girls und Panzer das Finale - 03 (1080p) [EAD6892E].mkv"
From first looks it's impossible to set an empty subfolder (immediate descendant of import folder).
Also check if there if there is a bug/vulnerability that allows user to set a subfolder that starts at root "/" or use relative paths "../"
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.