Skip to content

Commit

Permalink
feat(PTP): add freeleech tag
Browse files Browse the repository at this point in the history
  • Loading branch information
tomyangsh authored and fzlins committed Sep 1, 2024
1 parent 2a4e9af commit 74687fa
Showing 1 changed file with 117 additions and 105 deletions.
222 changes: 117 additions & 105 deletions resource/sites/passthepopcorn.me/getSearchResult.js
Original file line number Diff line number Diff line change
@@ -1,105 +1,117 @@
if (!"".getQueryString) {
String.prototype.getQueryString = function(name, split) {
if (split == undefined) split = "&";
var reg = new RegExp(
"(^|" + split + "|\\?)" + name + "=([^" + split + "]*)(" + split + "|$)"
),
r;
if ((r = this.match(reg))) return decodeURI(r[2]);
return null;
};
}

(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;
}

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

getResult() {
if (!this.haveData) {
return [];
}
let site = options.site;
// 获取种子列表行
let Movies = options.page.Movies;
if (Movies.length == 0) {
options.status = ESearchResultParseStatus.noTorrents;
return [];
}
let results = [];
let authkey = options.page.AuthKey;
let passkey = options.page.PassKey;
console.log("Movies.length", Movies.length);
//console.log("Movies", Movies.text());
try {
// 遍历数据行
for (let index = 0; index < Movies.length; index++) {
let row = Movies[index];
let torrent = row.Torrents[0];
let data = {
id: `${torrent.Id}`,
title:
row.Title +
"[" +
row.Year +
"]" +
"-" +
torrent.Codec +
"/" +
torrent.Container +
"/" +
torrent.Source +
"/" +
torrent.Resolution,
subTitle: torrent.ReleaseName,
link: `${site.url}torrents.php?id=${row.GroupId}&torrentid=${
torrent.Id
}`,
url: `${site.url}torrents.php?action=download&id=${
torrent.Id
}&authkey=${authkey}&torrent_pass=${passkey}`,
size: parseFloat(torrent.Size),
time: torrent.UploadTime,
author: "",
seeders: torrent.Seeders,
leechers: torrent.Leechers,
completed: torrent.Snatched,
comments: 0,
site: site,
tags: null,
entryName: options.entry.name,
category: "Movie"
};
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;
}
}

let parser = new Parser(options);
options.results = parser.getResult();
console.log(options.results);
})(options);
if (!"".getQueryString) {
String.prototype.getQueryString = function(name, split) {
if (split == undefined) split = "&";
var reg = new RegExp(
"(^|" + split + "|\\?)" + name + "=([^" + split + "]*)(" + split + "|$)"
),
r;
if ((r = this.match(reg))) return decodeURI(r[2]);
return null;
};
}

(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;
}

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

getResult() {
if (!this.haveData) {
return [];
}
let site = options.site;
// 获取种子列表行
let Movies = options.page.Movies;
if (Movies.length == 0) {
options.status = ESearchResultParseStatus.noTorrents;
return [];
}
let results = [];
let authkey = options.page.AuthKey;
let passkey = options.page.PassKey;
console.log("Movies.length", Movies.length);
//console.log("Movies", Movies.text());
try {
// 遍历数据行
for (let index = 0; index < Movies.length; index++) {
let row = Movies[index];
let torrent = row.Torrents[0];
let data = {
id: `${torrent.Id}`,
title:
row.Title +
"[" +
row.Year +
"]" +
"-" +
torrent.Codec +
"/" +
torrent.Container +
"/" +
torrent.Source +
"/" +
torrent.Resolution,
subTitle: torrent.ReleaseName,
link: `${site.url}torrents.php?id=${row.GroupId}&torrentid=${
torrent.Id
}`,
url: `${site.url}torrents.php?action=download&id=${
torrent.Id
}&authkey=${authkey}&torrent_pass=${passkey}`,
size: parseFloat(torrent.Size),
time: torrent.UploadTime,
author: "",
seeders: torrent.Seeders,
leechers: torrent.Leechers,
completed: torrent.Snatched,
comments: 0,
site: site,
tags: this.getTags(torrent),
entryName: options.entry.name,
category: "Movie"
};
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;
}

getTags(torrent) {
let tags = [];
if (torrent.FreeleechType == "Freeleech") {
tags.push({
name: "Free",
color: "blue"
});
}

return tags;
}
}

let parser = new Parser(options);
options.results = parser.getResult();
console.log(options.results);
})(options);

0 comments on commit 74687fa

Please sign in to comment.