diff --git a/data/data.json b/data/data.json
deleted file mode 100644
index 10f31ea..0000000
--- a/data/data.json
+++ /dev/null
@@ -1,11 +0,0 @@
-[
- {
- "owner": "displayName",
- "timestamp": "2024-10-10T17:30:21.0999256+02:00",
- "rank": "",
- "upload": "",
- "current_upload": "",
- "current_download": "",
- "points": ""
- }
-]
diff --git a/index.html b/index.html
index 1d4cb8f..bb92143 100644
--- a/index.html
+++ b/index.html
@@ -151,16 +151,17 @@
)
profileCard.innerHTML = `
-
${owner}
-
-
Rank: ${latestRecord.rank}
-
Upload: ${latestRecord.upload}
-
Current Upload: ${latestRecord.current_upload}
-
Current Download: ${latestRecord.current_download}
-
Points: ${latestRecord.points}
-
-
- `
+ ${owner}
+
+
Rank: ${latestRecord.rank}
+
Upload: ${latestRecord.upload}
+
Current Upload: ${latestRecord.current_upload}
+
Current Download: ${latestRecord.current_download}
+
Points: ${latestRecord.points}
+
Seeding Count: ${latestRecord.seeding_count}
+
+
+ `
profilesDiv.appendChild(profileCard)
}
@@ -201,7 +202,7 @@
const labels = profileHistory.map(record =>
new Date(record.timestamp).toLocaleDateString()
)
- const rankData = profileHistory.map(record => parseFloat(record.rank))
+ const rankData = profileHistory.map(record => record.rank)
const uploadData = profileHistory.map(record =>
parseStorageValue(record.upload)
)
@@ -211,9 +212,9 @@
const downloadData = profileHistory.map(record =>
parseSpeedValue(record.current_download)
)
- const pointsData = profileHistory.map(record =>
- parseFloat(record.points)
- )
+ const pointsData = profileHistory.map(record => record.points)
+
+ const seedingCount = profileHistory.map(record => record.seeding_count)
const chartData = {
labels: labels,
@@ -248,6 +249,12 @@
borderColor: 'rgba(153, 102, 255, 1)',
fill: false,
},
+ {
+ label: 'Seeding Count',
+ data: seedingCount,
+ borderColor: 'rgba(255, 159, 64, 1)',
+ fill: false,
+ },
],
}
diff --git a/main.go b/main.go
index 80e99b9..cd2a5a5 100644
--- a/main.go
+++ b/main.go
@@ -7,6 +7,9 @@ import (
"log"
"net/http"
"os"
+ "regexp"
+ "strconv"
+ "strings"
"time"
"github.com/PuerkitoBio/goquery"
@@ -16,21 +19,22 @@ import (
type ProfileData struct {
Owner string `json:"owner"`
Timestamp time.Time `json:"timestamp"`
- Rank string `json:"rank"`
+ Rank int `json:"rank"`
Upload string `json:"upload"`
CurrentUpload string `json:"current_upload"`
CurrentDownload string `json:"current_download"`
- Points string `json:"points"`
+ Points int `json:"points"`
+ SeedingCount int `json:"seeding_count"`
}
var (
- profiles = map[string]string{}
- jsonFile = "./data/data.json"
+ profiles = map[string]string{}
+ jsonFile = "./data/data.json"
profilesFile = "profiles.json"
- baseUrl = "https://ncore.pro/profile.php?id="
- nick string
- pass string
- client *http.Client
+ baseUrl = "https://ncore.pro/profile.php?id="
+ nick string
+ pass string
+ client *http.Client
)
func init() {
@@ -93,7 +97,11 @@ func fetchProfile(url string, displayName string) (*ProfileData, error) {
switch label {
case "Helyezés:":
- profile.Rank = value
+ value = strings.TrimSuffix(value, ".")
+ rank, err := strconv.Atoi(value)
+ if err == nil {
+ profile.Rank = rank
+ }
case "Feltöltés:":
profile.Upload = value
case "Aktuális feltöltés:":
@@ -101,7 +109,19 @@ func fetchProfile(url string, displayName string) (*ProfileData, error) {
case "Aktuális letöltés:":
profile.CurrentDownload = value
case "Pontok száma:":
- profile.Points = value
+ points, err := strconv.Atoi(value)
+ if err == nil {
+ profile.Points = points
+ }
+ }
+ })
+
+ doc.Find(".lista_mini_fej").Each(func(i int, s *goquery.Selection) {
+ text := s.Text()
+ re := regexp.MustCompile(`\((\d+)\)`)
+ matches := re.FindStringSubmatch(text)
+ if len(matches) > 1 {
+ fmt.Sscanf(matches[1], "%d", &profile.SeedingCount)
}
})
diff --git a/profiles.json b/profiles.json
index 07d39cb..0967ef4 100644
--- a/profiles.json
+++ b/profiles.json
@@ -1,3 +1 @@
-{
- "displayName": "userId"
-}
+{}