diff --git a/resource/sites/milkie.cc/config.json b/resource/sites/milkie.cc/config.json new file mode 100644 index 000000000..abb4dd2c1 --- /dev/null +++ b/resource/sites/milkie.cc/config.json @@ -0,0 +1,101 @@ +{ + "name": "Milkie", + "description": "Milkie", + "url": "https://milkie.cc/", + "icon": "https://milkie.cc/favicon.png", + "tags": [ + "综合", + "成人" + ], + "schema": "common", + "host": "milkie.cc", + "tokenRequired": true, + "collaborator": [ + "tomyangsh" + ], + "plugins": [ + { + "name": "种子列表", + "pages": [ + "/browse" + ], + "scripts": [ + "/schemas/NexusPHP/common.js", + "/schemas/Common/torrents.js" + ] + } + ], + "searchEntryConfig": { + "skipIMDbId": true, + "page": "/api/v1/torrents?query=$key$&ps=10", + "resultType": "json", + "requestMethod": "GET", + "parseScriptFile": "getSearchResult.js", + "keepOriginKey": true, + "headers": { + "Authorization": "Bearer $site.authToken$" + } + }, + "searchEntry": [ + { + "name": "全部", + "enabled": true + } + ], + "selectors": { + "userBaseInfo": { + "page": "/api/v1/auth", + "dataType": "json", + "requestMethod": "GET", + "headers": { + "Authorization": "Bearer $site.authToken$" + }, + "fields": { + "name": { + "selector": [ + "user.displayName" + ] + }, + "uploaded": { + "selector": [ + "user.uploaded" + ] + }, + "downloaded": { + "selector": [ + "user.downloaded" + ] + }, + "joinTime": { + "selector": [ + "user.createdAt" + ], + "filters": [ + "dateTime(query).isValid()?dateTime(query).valueOf():query" + ] + } + } + }, + "common": { + "page": "/browse", + "fields": { + "downloadURL": { + "selector": [ + "a[href*='/api/v1/torrents']" + ], + "filters": [ + "query.attr('href')" + ] + }, + "downloadURLs": { + "selector": [ + "a[href*='/api/v1/torrents']" + ], + "filters": [ + "query.toArray()" + ] + } + } + } + } +} diff --git a/resource/sites/milkie.cc/getSearchResult.js b/resource/sites/milkie.cc/getSearchResult.js new file mode 100644 index 000000000..0a41cf1a4 --- /dev/null +++ b/resource/sites/milkie.cc/getSearchResult.js @@ -0,0 +1,83 @@ +(function(options) { + class Parser { + constructor() { + this.haveData = false; + if (!options.page.hits) { + options.status = ESearchResultParseStatus.needLogin; + return; + } + options.isLogged = true; + this.haveData = true; + } + + /** + * 获取搜索结果 + */ + + getResult() { + if (!this.haveData) { + return []; + } + let site = options.site; + let groups = options.page.torrents; + if (groups.length == 0) { + options.status = ESearchResultParseStatus.noTorrents; + return []; + } + let results = []; + try { + groups.forEach(group => { + let data = { + title: group.releaseName, + link: `${site.url}/browse/${group.id}`, + url: `${site.url}/api/v1/torrents/${group.id}/torrent?key=${encodeURIComponent(site.passkey)}`, + size: group.size, + time: Date(group.createdAt), + seeders: group.seeders, + leechers: group.leechers, + completed: group.downloaded, + site: options.site, + tags: null, + entryName: options.entry.name, + category: this.getCategory(group.category), + 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; + } + + getCategory(category) { + switch (category) + { + case 1: + return "电影"; + case 2: + return "电视剧"; + case 3: + return "音乐"; + case 4: + return "游戏"; + case 5: + return "电子书"; + case 6: + return "软件"; + case 7: + return "成人"; + default: + return category; + } + } + } + + let parser = new Parser(options); + options.results = parser.getResult(); +})(options);