MCPcopy Create free account
hub / github.com/KikoPlayProject/KikoPlay / loadScript

Method loadScript

Extension/Script/libraryscript.cpp:11–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9}
10
11ScriptState LibraryScript::loadScript(const QString &scriptPath)
12{
13 MutexLocker locker(scriptLock);
14 if(!locker.tryLock()) return ScriptState(ScriptState::S_BUSY);
15 QString errInfo = ScriptBase::loadScript(scriptPath);
16 if(!errInfo.isEmpty()) return ScriptState(ScriptState::S_ERROR, errInfo);
17 matchSupported = checkType(matchFunc, LUA_TFUNCTION);
18 bool hasSearchFunc = checkType(searchFunc, LUA_TFUNCTION);
19 bool hasEpFunc = checkType(epFunc, LUA_TFUNCTION);
20 hasTagFunc = checkType(tagFunc, LUA_TFUNCTION);
21 if(!matchSupported && !(hasSearchFunc && hasEpFunc)) return ScriptState(ScriptState::S_ERROR, "search+getep/match function is not found");
22 QVariant menus = get(menusTable); //[{title=xx, id=xx}...]
23 if(menus.type() == QVariant::List)
24 {
25 auto mlist = menus.toList();
26 for(auto &m : mlist)
27 {
28 if(m.type() == QVariant::Map)
29 {
30 auto mObj = m.toMap();
31 QString title = mObj.value("title").toString(), id =mObj.value("id").toString();
32 if(title.isEmpty() || id.isEmpty()) continue;
33 menuItems.append({title, id});
34 }
35 }
36 }
37 return ScriptState(ScriptState::S_NORM);
38}
39
40ScriptState LibraryScript::search(const QString &keyword, QList<AnimeLite> &results)
41{

Callers

nothing calls this directly

Calls 8

ScriptStateClass · 0.85
valueMethod · 0.80
tryLockMethod · 0.45
isEmptyMethod · 0.45
typeMethod · 0.45
toMapMethod · 0.45
toStringMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected