Skip to content

Commit

Permalink
added proper TL support
Browse files Browse the repository at this point in the history
  • Loading branch information
FrenchGithubUser committed Feb 16, 2025
1 parent ddb09b7 commit 60e5e9b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
18 changes: 9 additions & 9 deletions backend/config_sample/config_sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -451,16 +451,16 @@
"base_url": "https://www.torrentleech.org/",
"scraping": {
"xpaths": {
"uploaded_amount": "body > div:nth-of-type(6) > div > div > div > div:nth-of-type(3) > div > div > div > table > tbody > tr:nth-of-type(1) > td:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(1) > span",
"downloaded_amount": "body > div:nth-of-type(6) > div > div > div > div:nth-of-type(3) > div > div > div > table > tbody > tr:nth-of-type(1) > td:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(2) > span",
"bonus_points": "body > div:nth-of-type(3) > div:nth-of-type(2) > div > div:nth-of-type(1) > span:nth-of-type(2) > span:nth-of-type(2) > div:nth-of-type(1) > span > span",
"buffer": "body > div:nth-of-type(3) > div:nth-of-type(2) > div > div:nth-of-type(1) > span:nth-of-type(2) > span:nth-of-type(1) > div:nth-of-type(3)",
"seeding": "body > div:nth-of-type(3) > div:nth-of-type(2) > div > div:nth-of-type(1) > span:nth-of-type(2) > span:nth-of-type(1) > div:nth-of-type(1)",
"leeching": "body > div:nth-of-type(3) > div:nth-of-type(2) > div > div:nth-of-type(1) > span:nth-of-type(2) > span:nth-of-type(1) > div:nth-of-type(2)",
"ratio": "body > div:nth-of-type(6) > div > div > div > div:nth-of-type(3) > div > div > div > table > tbody > tr:nth-of-type(1) > td:nth-of-type(2) > div:nth-of-type(2) > div:nth-of-type(3) > span",
"uploaded_amount": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(1) div:nth-of-type(1) span",
"downloaded_amount": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(1) div:nth-of-type(2) span",
"bonus_points": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(2) div:nth-of-type(1) span span",
"buffer": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(1) div:nth-of-type(3)",
"seeding": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(1) div:nth-of-type(1)",
"leeching": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(1) div:nth-of-type(2)",
"ratio": "body div:nth-of-type(2) div:nth-of-type(2) div div:nth-of-type(1) span:nth-of-type(2) span:nth-of-type(1) div:nth-of-type(4)",
"warned": "",
"torrent_comments": "body > div:nth-of-type(6) > div > div > div > div:nth-of-type(3) > div > div > div > table > tbody > tr:nth-of-type(11) > td:nth-of-type(2)",
"class": "body > div:nth-of-type(6) > div > div > div > div:nth-of-type(3) > div > div > div > table > tbody > tr:nth-of-type(5) > td:nth-of-type(2)"
"torrent_comments": "body div:nth-of-type(5) div div div div:nth-of-type(3) div div div table tbody tr:nth-of-type(11) td:nth-of-type(2)",
"class": "body div:nth-of-type(5) div div div div:nth-of-type(3) div div div table tbody tr:nth-of-type(5) td:nth-of-type(2)"
}
}
}
Expand Down
7 changes: 2 additions & 5 deletions backend/indexers/tl.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func ProcessIndexerResponseTL(bodyString string, indexerInfo gjson.Result) map[s
doc, _ := goquery.NewDocumentFromReader(strings.NewReader(bodyString))

// fmt.Println(bodyString)
fmt.Println(doc.Find("body > div:nth-of-type(6) > div > div > div > div:nth-of-type(3) > div > div > div > table > tbody > tr:nth-of-type(1) > td:nth-of-type(2) > div:nth-of-type(2)").Text())
uploadRegexResult := re.FindStringSubmatch(doc.Find(indexerInfo.Get("scraping.xpaths.uploaded_amount").Str).Text())
if len(uploadRegexResult) == 0 {
fmt.Printf("An error occured while parsing %s's response", indexerInfo.Get("indexer_name").Str)
Expand All @@ -97,13 +96,13 @@ func ProcessIndexerResponseTL(bodyString string, indexerInfo gjson.Result) map[s
results["buffer"] = helpers.AnyUnitToBytes(cleanBuffer, downloadRegexResult[2])

bonusPoints := doc.Find(indexerInfo.Get("scraping.xpaths.bonus_points").Str).Text()
results["bonus_points"] = strings.ReplaceAll(bonusPoints, "", "")
results["bonus_points"] = strings.ReplaceAll(bonusPoints, "'", "")

seeding_html := doc.Find(indexerInfo.Get("scraping.xpaths.seeding").Str).Text()
results["seeding"] = regexp.MustCompile(`\((\d+)\)`).FindStringSubmatch(seeding_html)[1]

leeching_html := doc.Find(indexerInfo.Get("scraping.xpaths.leeching").Str).Text()
results["seeding"] = regexp.MustCompile(`\((\d+)\)`).FindStringSubmatch(leeching_html)[1]
results["leeching"] = regexp.MustCompile(`\((\d+)\)`).FindStringSubmatch(leeching_html)[1]

ratio_html := doc.Find(indexerInfo.Get("scraping.xpaths.ratio").Str).Text()
results["ratio"] = regexp.MustCompile(`(\d+)`).FindStringSubmatch(ratio_html)[1]
Expand All @@ -114,7 +113,5 @@ func ProcessIndexerResponseTL(bodyString string, indexerInfo gjson.Result) map[s
class := doc.Find(indexerInfo.Get("scraping.xpaths.class").Str).Text()
results["class"] = class

fmt.Println(results)

return results
}
Binary file added frontend/public/images/TorrentLeech.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 60e5e9b

Please sign in to comment.