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

Method getEp

Extension/Script/libraryscript.cpp:198–231  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

196}
197
198ScriptState LibraryScript::getEp(Anime *anime, QVector<EpInfo> &results)
199{
200 MutexLocker locker(scriptLock);
201 if(!locker.tryLock()) return ScriptState(ScriptState::S_BUSY);
202 QString errInfo;
203 QVariantList rets = call(epFunc, {anime->toMap()}, 1, errInfo);
204 if(!errInfo.isEmpty()) return ScriptState(ScriptState::S_ERROR, errInfo);
205 if(rets[0].type()!=QVariant::List) return ScriptState(ScriptState::S_ERROR, "Wrong Return Value Type");
206 auto eps = rets[0].toList();
207 QMap<EpType, QPair<double, QSet<double>>> reOrderMap;
208 for(auto e: eps)
209 {
210 auto epobj = e.toMap();
211 double index = epobj.value("index", 0).toDouble();
212 QString epName = epobj.value("name").toString();
213 if(index<0) continue;
214 EpInfo ep;
215 ep.name = epName; ep.index = index;
216 ep.type = EpType(qBound(1, epobj.value("type", 1).toInt(), int(EpType::Other)));
217 if(!reOrderMap.contains(ep.type))
218 {
219 reOrderMap.insert(ep.type, {1, QSet<double>()});
220 }
221 if(reOrderMap[ep.type].second.contains(ep.index))
222 {
223 ep.index = reOrderMap[ep.type].first + 1;
224 }
225 reOrderMap[ep.type].first = qMax(reOrderMap[ep.type].first, ep.index);
226 reOrderMap[ep.type].second.insert(ep.index);
227 results.append(ep);
228 }
229 std::sort(results.begin(), results.end());
230 return ScriptState(ScriptState::S_NORM);
231}
232
233ScriptState LibraryScript::getTags(Anime *anime, QStringList &results)
234{

Callers

nothing calls this directly

Calls 14

ScriptStateClass · 0.85
sortFunction · 0.85
valueMethod · 0.80
EpTypeEnum · 0.50
tryLockMethod · 0.45
toMapMethod · 0.45
isEmptyMethod · 0.45
typeMethod · 0.45
toStringMethod · 0.45
containsMethod · 0.45
insertMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected