Skip to content

Commit

Permalink
add tccf site; improve global free recognization for nexusphp sites
Browse files Browse the repository at this point in the history
  • Loading branch information
sagan committed Feb 10, 2024
1 parent 8e4b7fe commit bf1eea3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
21 changes: 17 additions & 4 deletions site/nexusphp/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,20 @@ func parseTorrents(doc *goquery.Document, option *TorrentsParserOption,
option.selectorTorrentPaid = SELECTOR_TORRENT_PAID
}

globalFree := false
maybeGlobalFree := false
globalDiscountEndTime := int64(0)
globalDiscountLabels := doc.Find("p,span,b,i,a").FilterFunction(func(i int, s *goquery.Selection) bool {
globalDiscountLabels := doc.Find("p,h1,h2,span,b,i,a").FilterFunction(func(i int, s *goquery.Selection) bool {
txt := util.DomRemovedSpecialCharsTextPreservingTime(s)
re := regexp.MustCompile(`(全站|全局)\s*(\dX Free|Free|优惠)\s*生效`)
return re.MatchString(txt)
re := regexp.MustCompile(`(全站|全局)\s*(?P<free>\dX Free|Free|免费|优惠)\s*生效`)
if matches := re.FindStringSubmatch(txt); matches != nil {
discountText := strings.ToLower(matches[re.SubexpIndex("free")])
if strings.Contains(discountText, "free") || strings.Contains(discountText, "免费") {
maybeGlobalFree = true
}
return true
}
return false
})
if globalDiscountLabels.Length() > 0 {
var globalDiscountLabel *goquery.Selection
Expand All @@ -91,7 +100,7 @@ func parseTorrents(doc *goquery.Document, option *TorrentsParserOption,
return true
})
globalDiscountEl := globalDiscountLabel.Parent()
for i := 0; globalDiscountEl.Prev().Length() == 0 && i < 3; i++ {
for i := 0; globalDiscountLabel.Parent().Length() > 0 && globalDiscountEl.Prev().Length() == 0 && i < 3; i++ {
globalDiscountEl = globalDiscountEl.Parent()
}
txt := util.DomRemovedSpecialCharsTextPreservingTime(globalDiscountEl)
Expand All @@ -103,6 +112,7 @@ func parseTorrents(doc *goquery.Document, option *TorrentsParserOption,
if time1 > 0 && time2 > 0 && doctime >= time1 && doctime < time2 {
log.Tracef("Found global discount timespan: %s ~ %s", util.FormatTime(time1), util.FormatTime(time2))
globalDiscountEndTime = time2
globalFree = maybeGlobalFree
}
}

Expand Down Expand Up @@ -437,6 +447,9 @@ func parseTorrents(doc *goquery.Document, option *TorrentsParserOption,
if discountEndTime <= 0 && globalDiscountEndTime > 0 {
discountEndTime = globalDiscountEndTime
}
if downloadMultiplier == 1 && globalFree {
downloadMultiplier = 0
}
if name != "" && (downloadUrl != "" || id != "") {
if id != "" && siteName != "" {
id = siteName + "." + id
Expand Down
13 changes: 10 additions & 3 deletions site/tpl/tpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,17 @@ var (
Comment: "龍之家",
},
"eastgame": {
Type: "nexusphp",
Aliases: []string{"tlfbits", "tlf"},
Url: "https://pt.eastgame.org/",
TorrentsExtraUrls: []string{"trls.php"},
Comment: "吐鲁番",
},
"et8": {
Type: "nexusphp",
Aliases: []string{"tlfbits", "tlf"},
Url: "https://pt.eastgame.org/",
Comment: "吐鲁番",
Aliases: []string{"tccf", "torrentccf"},
Url: "https://et8.org/",
Comment: "精品论坛,他吹吹风",
},
// need heavy work to support it
// "filelist": {
Expand Down

0 comments on commit bf1eea3

Please sign in to comment.