Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
ronggang committed May 20, 2020
2 parents 039913c + 0e54a53 commit 6f2a233
Show file tree
Hide file tree
Showing 59 changed files with 2,228 additions and 444 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pt-plugin-plus",
"version": "1.4.8",
"version": "1.4.9",
"author": {
"name": "ronggang",
"url": "https://github.com/ronggang"
Expand Down
2 changes: 1 addition & 1 deletion public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_manifest_appName__",
"short_name": "__MSG_manifest_shortName__",
"version": "1.4.8",
"version": "1.4.9",
"description": "__MSG_manifest_appDescription__",
"manifest_version": 2,
"default_locale": "zh_CN",
Expand Down
2 changes: 1 addition & 1 deletion resource/publicSites/imdb.com/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"ver": "0.0.1",
"plugins": [{
"name": "电影详情页",
"pages": ["\/title\/tt\\d+\/"],
"pages": ["^\/title\/tt\\d+\/?$"],
"scripts": ["subject.js"]
}, {
"name": "Top",
Expand Down
15 changes: 8 additions & 7 deletions resource/schemas/Common/torrents.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
// "获取下载链接失败,未能正确定位到链接";
return this.t("getDownloadURLsFailed");
}

let urls = $.map(links, item => {
let url = $(item).attr("href");
return this.getFullURL(url);
});

return urls;
if (typeof(links[0])!="string"){
let urls = $.map(links, item => {
let url = $(item).attr("href");
return this.getFullURL(url);
});
return urls;
}
return links
}

/**
Expand Down
35 changes: 35 additions & 0 deletions resource/schemas/NexusPHP/getSearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,44 @@
.html(cell.html().replace("<br>", " "))
.text();
}
if (options.site.host === "pt.sjtu.edu.cn") {
if (time.match(/\d+[分时天月年]/g)) {
time = Date.now() - this._parseTime(time)
time = new Date(time).toLocaleString("zh-CN", {hour12: false}).replace(/\//g,'-')
}
}
return time || "";
}

_parseTime (timeString) {
const timeMatch = timeString.match(/\d+[分时天月年]/g)
let length = 0
timeMatch.forEach(time => {
const timeMatch = time.match(/(\d+)([分时天月年])/)
const number = parseInt(timeMatch[1])
const unit = timeMatch[2]
switch (true) {
case unit === '分':
length += number
break
case unit === '时':
length += number * 60
break
case unit === '天':
length += number * 60 * 24
break
case unit === '月':
length += number * 60 * 24 * 30
break
case unit === '年':
length += number * 60 * 24 * 365
break
default:
}
})
return length * 60 * 1000
}

/**
* 获取标题
*/
Expand Down
36 changes: 26 additions & 10 deletions resource/schemas/UNIT3D/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": ["/schemas/NexusPHP/common.js", "torrents.js"]
}],
"searchEntryConfig": {
"page": "/filterTorrents",
"page": "/torrents/filter",
"queryString": "search=$key$",
"area": [{
"name": "IMDB",
Expand All @@ -21,6 +21,24 @@
"tt", ""
]
}],
"fieldSelector": {
"progress": {
"selector": ["button.btn.btn-success.btn-circle", "button.btn.btn-warning.btn-circle, button.btn.btn-info.btn-circle", ""],
"switchFilters": [
["100"],
["0"],
["null"]
]
},
"status": {
"selector": ["button.btn.btn-success.btn-circle", "button.btn.btn-warning.btn-circle", "button.btn.btn-info.btn-circle"],
"switchFilters": [
["2"],
["1"],
["3"]
]
}
},
"resultType": "html",
"parseScriptFile": "/schemas/UNIT3D/getSearchResult.js",
"resultSelector": "div.table-responsive > table:first"
Expand All @@ -40,15 +58,13 @@
"userBaseInfo": {
"page": "/",
"fields": {
"id": {
"selector": ["a[href*='mail/inbox']:first"],
"attribute": "href",
"filters": ["query ? query.getQueryString('id'):''"]
},
"name": {
"selector": ["a[href*='mail/inbox']:first"],
"selector": ["a[href*='settings']:first"],
"attribute": "href",
"filters": ["query ? query.getQueryString('username'):''"]
"switchFilters": [
["query.match(/users\\/(.+)\\/settings/)", "(query && query.length>=2)?(query[1]):''"],
["query ? query.getQueryString('id'):''"]
]
},
"uploaded": {
"selector": ["div.ratio-bar i.fa-arrow-up"],
Expand All @@ -69,7 +85,7 @@
}
},
"userExtendInfo": {
"page": "/$user.name$.$user.id$",
"page": "/users/$user.name$",
"fields": {
"seedingSize": {
"selector": ["table.table-condensed.table-striped.table-bordered:first td:contains('Seeding Size') + td", "table.table-condensed.table-striped.table-bordered:first td:contains('做种体积') + td", "table.table-condensed.table-striped.table-bordered:first td:contains('做種體積') + td"],
Expand All @@ -79,7 +95,7 @@
"selector": "div.content span.badge-user"
},
"messageCount": {
"selector": ["ul.left-navbar a[href*='/mail/inbox'] .point"],
"selector": [".point"],
"filters": ["query.length?'11':'0'"]
},
"joinTime": {
Expand Down
3 changes: 2 additions & 1 deletion resource/schemas/UNIT3D/getSearchResult.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
return [];
}
let site = options.site;
site.searchEntryConfig = options.entry
let selector =
options.resultSelector || "div.table-responsive > table:first";
let table = options.page.find(selector);
Expand Down Expand Up @@ -194,7 +195,7 @@
.eq(fieldIndex.time)
.find("span[title]")
.attr("title") ||
cells.eq(fieldIndex.time).text() ||
cells.eq(fieldIndex.time).text().replace('秒前', ' seconds ago').replace('秒前', ' seconds ago').replace('分钟前', ' minutes ago').replace('分鐘前', ' minutes ago').replace('天前', ' day ago').replace('小時前', ' hours ago').replace('小时前', ' hours ago')||
"",
author:
fieldIndex.author == -1
Expand Down
1 change: 1 addition & 0 deletions resource/sites/aidoru-online.me/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"name": "Aidoru!Online",
"timezoneOffset": "+0000",
"description": "AO",
"icon": "https://aidoru-online.me/themes/default/images/favicon.ico",
"url": "https://aidoru-online.me/",
"tags": ["偶像"],
"schema": "Common",
Expand Down
34 changes: 34 additions & 0 deletions resource/sites/anthelion.me/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "Anthelion",
"timezoneOffset": "+0000",
"description": "Movies",
"url": "https://anthelion.me//",
"icon": "https://anthelion.me/favicon.ico",
"tags": ["电影"],
"schema": "GazelleJSONAPI",
"host": "anthelion.me",
"collaborator": "enigamz",
"searchEntryConfig": {
"skipIMDbId": true,
"parseScriptFile": "getSearchResult.js"
},
"searchEntry": [{
"name": "all",
"enabled": true
}],
"selectors": {
"userSeedingTorrents": {
"page": "/torrents.php?type=seeding&userid=$user.id$",
"fields": {
"seedingSize": {
"selector": ["tr.torrent_row > td.nobr"],
"filters": ["jQuery.map(query, (item)=>{return $(item).text();})", "_self.getTotalSize(query)"]
},
"bonus": {
"selector": ["a[href*='store.php']"],
"filters": ["query.text().replace(/,/g,'').match(/.+?([\\d.]+)/)", "(query && query.length>=2)?query[1]:0"]
}
}
}
}
}
159 changes: 159 additions & 0 deletions resource/sites/anthelion.me/getSearchResult.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
(function(options) {
class Parser {
constructor() {
this.haveData = false;
this.categories = {};
if (/auth_form/.test(options.responseText)) {
options.status = ESearchResultParseStatus.needLogin;
return;
}
options.isLogged = true;
this.haveData = true;
this.authkey = "";
this.passkey = "";
}

start() {
this.getAuthKey()
.then(() => {
options.resolve(this.getResult());
})
.catch(() => {
options.reject({
success: false,
msg: options.searcher.getErrorMessage(
options.site,
ESearchResultParseStatus.parseError,
options.errorMsg
),
data: {
site: options.site,
isLogged: options.isLogged
}
});
});
}

/**
* 获取搜索结果
*/

getResult() {
if (!this.haveData) {
return [];
}
let site = options.site;
let groups = options.page.response.results;
if (groups.length == 0) {
options.status = ESearchResultParseStatus.noTorrents;
return [];
}
let results = [];
let authkey = this.authkey;
let passkey = this.passkey;
console.log("groups.length", groups.length);
try {
groups.forEach(group => {
if (group.hasOwnProperty("torrents")) {
let torrents = group.torrents;
torrents.forEach(torrent => {
let data = {
title:
group.groupName +
" [" +
group.groupYear +
"]",
subTitle:
torrent.codec +
" / " +
torrent.container +
" / " +
torrent.media +
" / " +
torrent.resolution +
" / " +
torrent.audio +
(torrent.hasLog ? ` / Log(${torrent.logScore})` : "") +
(torrent.hasCue ? " / Cue" : "") +
(torrent.remastered ? ` / ${torrent.remasterYear}` : "") +
(torrent.scene ? " / Scene" : "") +
(torrent.isFreeleech ||
torrent.isNeutralLeech ||
torrent.isPersonalFreeleech
? " / Freeleech"
: ""),
link: `${site.url}torrents.php?id=${group.groupId}&torrentid=${torrent.torrentId}`,
url: `${site.url}torrents.php?action=download&id=${torrent.torrentId}&authkey=${authkey}&torrent_pass=${passkey}`,
size: parseFloat(torrent.size),
time: torrent.time,
seeders: torrent.seeders,
leechers: torrent.leechers,
completed: torrent.snatches,
site: site,
entryName: options.entry.name,
category: group.releaseType
};
results.push(data);
});
} else {
let data = {
title: group.groupName,
link: `${site.url}torrents.php?id=${group.groupId}&torrentid=${group.torrentId}`,
url: `${site.url}torrents.php?action=download&id=${group.torrentId}&authkey=${authkey}&torrent_pass=${passkey}`,
size: parseFloat(group.size),
time: group.groupTime,
author: "",
seeders: group.seeders,
leechers: group.leechers,
completed: group.snatches,
comments: 0,
site: site,
tags: group.tags,
entryName: options.entry.name,
category: group.category
};
results.push(data);
}
});
console.log("results.length", results.length);
if (results.length == 0) {
options.status = ESearchResultParseStatus.noTorrents;
}
} catch (error) {
console.log(error);
options.status = ESearchResultParseStatus.parseError;
options.errorMsg = error.stack;
}
return results;
}

/**
* 获取 AuthKey ,用于组合完整的下载链接
*/
getAuthKey() {
const url = (options.site.activeURL + "/ajax.php?action=index")
.replace("://", "****")
.replace(/\/\//g, "/")
.replace("****", "://");

return new Promise((resolve, reject) => {
$.get(url)
.done(result => {
if (result && result.status === "success" && result.response) {
this.authkey = result.response.authkey;
this.passkey = result.response.passkey;
resolve();
} else {
reject();
}
})
.fail(() => {
reject();
});
});
}
}

let parser = new Parser(options);
parser.start();
})(options);
Loading

0 comments on commit 6f2a233

Please sign in to comment.