| 9 | } |
| 10 | |
| 11 | ScriptState 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 | |
| 40 | ScriptState LibraryScript::search(const QString &keyword, QList<AnimeLite> &results) |
| 41 | { |