diff --git a/resource/sites/login.superbits.org/config.json b/resource/sites/login.superbits.org/config.json index 168d2cc19..83984f3b8 100644 --- a/resource/sites/login.superbits.org/config.json +++ b/resource/sites/login.superbits.org/config.json @@ -121,5 +121,18 @@ } } } - } -} \ No newline at end of file + }, + "searchEntryConfig": { + "page": "/api/v1/torrents?searchText=$key$", + "resultType": "json", + "requestMethod": "GET", + "parseScriptFile": "getSearchResult.js", + "keepOriginKey": true + }, + "searchEntry": [ + { + "name": "全部", + "enabled": true + } + ] +} diff --git a/resource/sites/login.superbits.org/getSearchResult.js b/resource/sites/login.superbits.org/getSearchResult.js new file mode 100644 index 000000000..e420e3c76 --- /dev/null +++ b/resource/sites/login.superbits.org/getSearchResult.js @@ -0,0 +1,73 @@ +(function(options) { + class Parser { + constructor() { + this.haveData = false; + if (!options.page) { + options.status = ESearchResultParseStatus.needLogin; + return; + } + options.isLogged = true; + this.haveData = true; + } + + /** + * 获取搜索结果 + */ + + getResult() { + if (!this.haveData) { + return []; + } + let site = options.site; + let groups = options.page; + if (groups.length == 0) { + options.status = ESearchResultParseStatus.noTorrents; + return []; + } + let results = []; + try { + groups.forEach(group => { + let data = { + title: group.name, + link: `${site.url}/torrent/${group.id}/${group.name}`, + url: `${site.url}/api/v1/torrents/download/${group.id}`, + size: group.size, + time: Date(group.added), + seeders: group.seeders, + leechers: group.leechers, + completed: '--', + site: options.site, + tags: this.isFree(group.frileech), + entryName: options.entry.name, + category: null, + comments: group.comments, + }; + results.push(data); + }); + if (results.length == 0) { + options.status = ESearchResultParseStatus.noTorrents; + } + } catch (error) { + console.log(error); + options.status = ESearchResultParseStatus.parseError; + options.errorMsg = error.stack; + } + return results; + } + + isFree(frileech) { + let tags = []; + if (frileech == 1) { + tags.push({ + name: "Free", + color: "blue" + }); + } + + return tags; + } + } + + let parser = new Parser(options); + options.results = parser.getResult(); +})(options);