Skip to content

Commit

Permalink
improve paid torrent parsing in nexusphp sites
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Aug 21, 2023
1 parent fe2933d commit 7f5d04b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
7 changes: 7 additions & 0 deletions site/nexusphp/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ const (
SELECTOR_DOWNLOAD_LINK = `a[href^="download.php?"],a[href^="download?"]`
SELECTOR_DETAILS_LINK = `a[href^="details.php?"],a[href^="details_"]`
SELECTOR_TORRENTS_LIST_DEFAULT = `table.torrents > tbody`
// xiaomlove/nexusphp paid torrent feature.
// see https://github.com/xiaomlove/nexusphp/blob/php8/app/Repositories/TorrentRepository.php .
// function getPaidIcon.
SELECTOR_TORRENT_PAID = `span[title="收费种子"],span[title="收費種子"],span[title="Paid torrent"]`
)

type TorrentsParserOption struct {
Expand Down Expand Up @@ -55,6 +59,9 @@ func parseTorrents(doc *goquery.Document, option *TorrentsParserOption,
if option.selectorTorrentDetailsLink == "" {
option.selectorTorrentDetailsLink = SELECTOR_DETAILS_LINK
}
if option.selectorTorrentPaid == "" {
option.selectorTorrentPaid = SELECTOR_TORRENT_PAID
}

globalDiscountEndTime := int64(0)
globalDiscountLabels := doc.Find("p,span,b,i,a").FilterFunction(func(i int, s *goquery.Selection) bool {
Expand Down
21 changes: 13 additions & 8 deletions site/tpl/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ var (
"hdcity": {
Type: "nexusphp",
Url: "https://hdcity.city/",
SearchUrl: "https://hdcity.city/pt?iwannaseethis=%s",
SearchUrl: "pt?iwannaseethis=%s",
Domains: []string{"leniter.org"},
SelectorTorrentDetailsLink: `a[href^="t-"]`,
SelectorTorrentTime: `.trtop > div:nth-last-child(2)@text`,
Expand Down Expand Up @@ -304,13 +304,12 @@ var (
Comment: "库非",
},
"leaves": {
Type: "nexusphp",
Aliases: []string{"redleaves"},
Url: "https://leaves.red/",
TorrentsExtraUrls: []string{"special.php", "games.php"},
SearchUrl: `https://leaves.red/search.php?search=%s&search_area=0`,
SelectorTorrentPaid: `span[title="收费种子"]`,
Comment: "红叶",
Type: "nexusphp",
Aliases: []string{"redleaves"},
Url: "https://leaves.red/",
TorrentsExtraUrls: []string{"special.php", "games.php"},
SearchUrl: `search.php?search=%s&search_area=0`,
Comment: "红叶",
},
"lemonhd": {
Type: "nexusphp",
Expand Down Expand Up @@ -369,8 +368,14 @@ var (
Type: "nexusphp",
Url: "https://piggo.me/",
TorrentsExtraUrls: []string{"special.php"},
SearchUrl: `search.php?search=%s&search_area=0`,
Comment: "猪猪",
},
"ptcafe": {
Type: "nexusphp",
Url: "https://ptcafe.club/",
Comment: "咖啡",
},
"ptchina": {
Type: "nexusphp",
Url: "https://ptchina.org/",
Expand Down

0 comments on commit 7f5d04b

Please sign in to comment.