Skip to content

Commit

Permalink
feat(milkie): new site
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyangsh authored and fzlins committed Sep 2, 2024
1 parent 570efd1 commit ad8b6ca
Show file tree
Hide file tree
Showing 2 changed files with 184 additions and 0 deletions.
101 changes: 101 additions & 0 deletions resource/sites/milkie.cc/config.json
Original file line number Diff line number Diff line change
@@ -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()"
]
}
}
}
}
}
83 changes: 83 additions & 0 deletions resource/sites/milkie.cc/getSearchResult.js
Original file line number Diff line number Diff line change
@@ -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);

0 comments on commit ad8b6ca

Please sign in to comment.