mirror of
https://github.com/skidoodle/ncore-stats.git
synced 2025-02-15 05:09:14 +01:00
+Seeding count
This commit is contained in:
parent
c6ac549281
commit
9acfc490f0
4 changed files with 52 additions and 38 deletions
|
@ -1,11 +0,0 @@
|
||||||
[
|
|
||||||
{
|
|
||||||
"owner": "displayName",
|
|
||||||
"timestamp": "2024-10-10T17:30:21.0999256+02:00",
|
|
||||||
"rank": "",
|
|
||||||
"upload": "",
|
|
||||||
"current_upload": "",
|
|
||||||
"current_download": "",
|
|
||||||
"points": ""
|
|
||||||
}
|
|
||||||
]
|
|
35
index.html
35
index.html
|
@ -151,16 +151,17 @@
|
||||||
)
|
)
|
||||||
|
|
||||||
profileCard.innerHTML = `
|
profileCard.innerHTML = `
|
||||||
<h2 class="text-2xl font-semibold mb-4"><i class='bx bxs-user text-2xl mr-2'></i>${owner}</h2>
|
<h2 class="text-2xl font-semibold mb-4"><i class='bx bxs-user text-2xl mr-2'></i>${owner}</h2>
|
||||||
<div class="space-y-2">
|
<div class="space-y-2">
|
||||||
<p><i class='bx bx-trophy mr-2'></i> Rank: ${latestRecord.rank}</p>
|
<p><i class='bx bx-trophy mr-2'></i> Rank: ${latestRecord.rank}</p>
|
||||||
<p><i class='bx bx-cloud-upload mr-2'></i> Upload: ${latestRecord.upload}</p>
|
<p><i class='bx bx-cloud-upload mr-2'></i> Upload: ${latestRecord.upload}</p>
|
||||||
<p><i class='bx bx-upload mr-2'></i> Current Upload: ${latestRecord.current_upload}</p>
|
<p><i class='bx bx-upload mr-2'></i> Current Upload: ${latestRecord.current_upload}</p>
|
||||||
<p><i class='bx bx-download mr-2'></i> Current Download: ${latestRecord.current_download}</p>
|
<p><i class='bx bx-download mr-2'></i> Current Download: ${latestRecord.current_download}</p>
|
||||||
<p><i class='bx bx-coin mr-2'></i> Points: ${latestRecord.points}</p>
|
<p><i class='bx bx-coin mr-2'></i> Points: ${latestRecord.points}</p>
|
||||||
</div>
|
<p><i class='bx bx-folder mr-2'></i> Seeding Count: ${latestRecord.seeding_count}</p>
|
||||||
<button class="mt-6 px-4 py-2 text-white rounded" onclick="showHistory('${owner}', event)">View History</button>
|
</div>
|
||||||
`
|
<button class="mt-6 px-4 py-2 text-white rounded" onclick="showHistory('${owner}', event)">View History</button>
|
||||||
|
`
|
||||||
|
|
||||||
profilesDiv.appendChild(profileCard)
|
profilesDiv.appendChild(profileCard)
|
||||||
}
|
}
|
||||||
|
@ -201,7 +202,7 @@
|
||||||
const labels = profileHistory.map(record =>
|
const labels = profileHistory.map(record =>
|
||||||
new Date(record.timestamp).toLocaleDateString()
|
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 =>
|
const uploadData = profileHistory.map(record =>
|
||||||
parseStorageValue(record.upload)
|
parseStorageValue(record.upload)
|
||||||
)
|
)
|
||||||
|
@ -211,9 +212,9 @@
|
||||||
const downloadData = profileHistory.map(record =>
|
const downloadData = profileHistory.map(record =>
|
||||||
parseSpeedValue(record.current_download)
|
parseSpeedValue(record.current_download)
|
||||||
)
|
)
|
||||||
const pointsData = profileHistory.map(record =>
|
const pointsData = profileHistory.map(record => record.points)
|
||||||
parseFloat(record.points)
|
|
||||||
)
|
const seedingCount = profileHistory.map(record => record.seeding_count)
|
||||||
|
|
||||||
const chartData = {
|
const chartData = {
|
||||||
labels: labels,
|
labels: labels,
|
||||||
|
@ -248,6 +249,12 @@
|
||||||
borderColor: 'rgba(153, 102, 255, 1)',
|
borderColor: 'rgba(153, 102, 255, 1)',
|
||||||
fill: false,
|
fill: false,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: 'Seeding Count',
|
||||||
|
data: seedingCount,
|
||||||
|
borderColor: 'rgba(255, 159, 64, 1)',
|
||||||
|
fill: false,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
40
main.go
40
main.go
|
@ -7,6 +7,9 @@ import (
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"regexp"
|
||||||
|
"strconv"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
|
@ -16,21 +19,22 @@ import (
|
||||||
type ProfileData struct {
|
type ProfileData struct {
|
||||||
Owner string `json:"owner"`
|
Owner string `json:"owner"`
|
||||||
Timestamp time.Time `json:"timestamp"`
|
Timestamp time.Time `json:"timestamp"`
|
||||||
Rank string `json:"rank"`
|
Rank int `json:"rank"`
|
||||||
Upload string `json:"upload"`
|
Upload string `json:"upload"`
|
||||||
CurrentUpload string `json:"current_upload"`
|
CurrentUpload string `json:"current_upload"`
|
||||||
CurrentDownload string `json:"current_download"`
|
CurrentDownload string `json:"current_download"`
|
||||||
Points string `json:"points"`
|
Points int `json:"points"`
|
||||||
|
SeedingCount int `json:"seeding_count"`
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
profiles = map[string]string{}
|
profiles = map[string]string{}
|
||||||
jsonFile = "./data/data.json"
|
jsonFile = "./data/data.json"
|
||||||
profilesFile = "profiles.json"
|
profilesFile = "profiles.json"
|
||||||
baseUrl = "https://ncore.pro/profile.php?id="
|
baseUrl = "https://ncore.pro/profile.php?id="
|
||||||
nick string
|
nick string
|
||||||
pass string
|
pass string
|
||||||
client *http.Client
|
client *http.Client
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -93,7 +97,11 @@ func fetchProfile(url string, displayName string) (*ProfileData, error) {
|
||||||
|
|
||||||
switch label {
|
switch label {
|
||||||
case "Helyezés:":
|
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:":
|
case "Feltöltés:":
|
||||||
profile.Upload = value
|
profile.Upload = value
|
||||||
case "Aktuális feltöltés:":
|
case "Aktuális feltöltés:":
|
||||||
|
@ -101,7 +109,19 @@ func fetchProfile(url string, displayName string) (*ProfileData, error) {
|
||||||
case "Aktuális letöltés:":
|
case "Aktuális letöltés:":
|
||||||
profile.CurrentDownload = value
|
profile.CurrentDownload = value
|
||||||
case "Pontok száma:":
|
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)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1 @@
|
||||||
{
|
{}
|
||||||
"displayName": "userId"
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue