Spaces:
Paused
Paused
Update bin/modules/manga/repositories/queries/manga_query_impl.go
Browse files
bin/modules/manga/repositories/queries/manga_query_impl.go
CHANGED
|
@@ -71,19 +71,33 @@ func (g MangaQueryImpl) GetComicInfo(endpoint string) utils.Result {
|
|
| 71 |
// Info komik tetap menggunakan BaseURL
|
| 72 |
g.URL = config.GlobalEnv.BaseURL + endpoint
|
| 73 |
|
|
|
|
| 74 |
g.Collector.OnHTML("table.inftable", func(e *colly.HTMLElement) {
|
| 75 |
-
e.ForEach("
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 81 |
})
|
| 82 |
})
|
| 83 |
|
|
|
|
| 84 |
g.Collector.OnHTML("ul.genre", func(e *colly.HTMLElement) {
|
| 85 |
e.ForEach("li.genre", func(i int, element *colly.HTMLElement) {
|
| 86 |
-
|
|
|
|
|
|
|
|
|
|
| 87 |
})
|
| 88 |
})
|
| 89 |
|
|
|
|
| 71 |
// Info komik tetap menggunakan BaseURL
|
| 72 |
g.URL = config.GlobalEnv.BaseURL + endpoint
|
| 73 |
|
| 74 |
+
// PERBAIKAN 1: Membaca tabel secara dinamis agar kebal terhadap perubahan urutan baris
|
| 75 |
g.Collector.OnHTML("table.inftable", func(e *colly.HTMLElement) {
|
| 76 |
+
e.ForEach("tr", func(i int, element *colly.HTMLElement) {
|
| 77 |
+
label := strings.ToLower(strings.TrimSpace(element.ChildText("td:nth-child(1)")))
|
| 78 |
+
value := strings.TrimSpace(element.ChildText("td:nth-child(2)"))
|
| 79 |
+
|
| 80 |
+
if strings.Contains(label, "judul") {
|
| 81 |
+
comicInfo.Title = value
|
| 82 |
+
} else if strings.Contains(label, "jenis") || strings.Contains(label, "tipe") || strings.Contains(label, "type") {
|
| 83 |
+
comicInfo.Type = value
|
| 84 |
+
} else if strings.Contains(label, "pengarang") || strings.Contains(label, "author") {
|
| 85 |
+
comicInfo.Author = value
|
| 86 |
+
} else if strings.Contains(label, "status") {
|
| 87 |
+
comicInfo.Status = value
|
| 88 |
+
} else if strings.Contains(label, "umur") || strings.Contains(label, "rating") {
|
| 89 |
+
comicInfo.Rating = value
|
| 90 |
+
}
|
| 91 |
})
|
| 92 |
})
|
| 93 |
|
| 94 |
+
// PERBAIKAN 2: Membersihkan karakter \n dan spasi berlebih pada Genre
|
| 95 |
g.Collector.OnHTML("ul.genre", func(e *colly.HTMLElement) {
|
| 96 |
e.ForEach("li.genre", func(i int, element *colly.HTMLElement) {
|
| 97 |
+
cleanGenre := strings.TrimSpace(element.Text)
|
| 98 |
+
if cleanGenre != "" {
|
| 99 |
+
comicInfo.Genre = append(comicInfo.Genre, cleanGenre)
|
| 100 |
+
}
|
| 101 |
})
|
| 102 |
})
|
| 103 |
|