This commit is contained in:
SimpleTracker 2024-04-18 09:58:26 +08:00 committed by Simple-Tracker
parent 0786a1b65b
commit 0880d027c8
2 changed files with 17 additions and 14 deletions

View File

@ -55,7 +55,7 @@ func BC_ParseSize(sizeStr string) int64 {
matched := false
multipler := 1
switch sizeStrSplit[1] {
switch strings.ToUpper(sizeStrSplit[1]) {
case "EB":
multipler *= 1024
fallthrough
@ -113,8 +113,8 @@ func BC_ParsePrecent(precentStr string) float64 {
return precent
}
func BC_ParseIP(ipStr string) (string, int) {
ipStr = StrTrim(ipStr)
if ipStr == "Myself" {
ipStr = strings.ToLower(StrTrim(ipStr))
if ipStr == "myself" {
return "", -1
}
@ -155,7 +155,7 @@ func BC_FetchTorrents() *map[int]BC_TorrentStruct {
}
torrentsMap := make(map[int]BC_TorrentStruct)
document.Find("table:last-child > tbody > tr").Each(func (index int, element *goquery.Selection) {
document.Find("table").Last().Find("tbody > tr").Each(func (index int, element *goquery.Selection) {
if index == 0 {
return
}
@ -167,7 +167,7 @@ func BC_FetchTorrents() *map[int]BC_TorrentStruct {
element.Find("td").EachWithBreak(func (tdIndex int, tdElement *goquery.Selection) bool {
switch tdIndex {
case 0:
if StrTrim(tdElement.Text()) != "BT" {
if strings.ToUpper(StrTrim(tdElement.Text())) != "BT" {
return false
}
case 1:
@ -178,7 +178,7 @@ func BC_FetchTorrents() *map[int]BC_TorrentStruct {
torrentID = BC_ParseTorrentLink(href)
case 2:
torrentStatus = StrTrim(tdElement.Text())
torrentStatus = strings.ToLower(StrTrim(tdElement.Text()))
case 4:
torrentSize = BC_ParseSize(tdElement.Text())
case 7:
@ -210,8 +210,8 @@ func BC_FetchTorrentPeers(infoHash string) *[]BC_PeerStruct {
return nil
}
torrentsMap := []BC_PeerStruct {}
document.Find("table:last-child > tbody > tr").Each(func (index int, element *goquery.Selection) {
torrentPeersMap := []BC_PeerStruct {}
document.Find("table").Last().Find("tbody > tr").Each(func (index int, element *goquery.Selection) {
if index == 0 {
return
}
@ -254,8 +254,8 @@ func BC_FetchTorrentPeers(infoHash string) *[]BC_PeerStruct {
}
peerStruct := BC_PeerStruct { IP: peerIP, Port: peerPort, Client: peerClient, Progress: peerProgress, Downloaded: peerDownloaded, Uploaded: peerUploaded, DlSpeed: peerDlSpeed, UpSpeed: peerUpSpeed }
torrentsMap = append(torrentsMap, peerStruct)
torrentPeersMap = append(torrentPeersMap, peerStruct)
})
return &torrentsMap
return &torrentPeersMap
}

View File

@ -26,10 +26,9 @@ type ReleaseStruct struct {
}
func ProcessVersion(version string) (int, int, int, int, string) {
version = strings.SplitN(version, " ", 2)[0]
versionSplit := strings.SplitN(version, ".", 2)
versionSplit := strings.SplitN(strings.SplitN(version, " ", 2)[0], ".", 2)
if versionSplit[0] == "Unknown" || len(versionSplit) != 2 {
if versionSplit[0] == "Unknown" {
return -1, 0, 0, 0, ""
}
@ -37,10 +36,14 @@ func ProcessVersion(version string) (int, int, int, int, string) {
return -2, 0, 0, 0, ""
}
if strings.Contains(version, "-") {
if strings.Contains(version, "-") || strings.Contains(version, "_") {
return -3, 0, 0, 0, ""
}
if len(versionSplit) != 2 {
return -1, 0, 0, 0, ""
}
mainVersion, err1 := strconv.Atoi(versionSplit[0])
versionType := 0 // 0: Public, 1: Beta.