| 196 | } |
| 197 | |
| 198 | ScriptState 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 | |
| 233 | ScriptState LibraryScript::getTags(Anime *anime, QStringList &results) |
| 234 | { |
nothing calls this directly
no test coverage detected