A Go library and API server for scraping manga from multiple sources.
go get github.com/ThiagoFrag/mangascraperpackage main
import (
"fmt""github.com/ThiagoFrag/mangascraper"
)
funcmain() {
scraper:=mangascraper.New()
// Search for mangaresults, _:=scraper.SearchManga("mangalivre.blog", "naruto")
for_, manga:=rangeresults {
fmt.Println(manga.Title)
}
// Get popular mangapopular, _:=scraper.GetPopularMangas("mangalivre.blog")
fmt.Printf("Found %d popular manga\n", len(popular))
}The sync package provides synchronization functionality for GoAnime applications. It allows syncing favorites, watch history, and settings between devices.
go get github.com/ThiagoFrag/mangascraper/syncpackage main
import (
"fmt""net/http""github.com/ThiagoFrag/mangascraper/sync"
)
funcmain() {
// Create a new sync storestore:=sync.NewStore("data/sync.json")
// Create HTTP handlerhandler:=sync.NewHandler(store)
// Register routesmux:=http.NewServeMux()
handler.RegisterRoutes(mux)
// Start serverhttp.ListenAndServe(":8080", mux)
}// Get user datauserData:=store.Get("user_123")
// Merge client data with servermerged, itemsAdded, err:=store.Merge("user_123", &clientData)
// Add a favoritestore.AddFavorite("user_123", sync.FavoriteItem{
ItemID: "manga_001",
Title: "Naruto",
CoverImage: "https://...",
URL: "https://...",
Type: "manga",
})
// Remove a favoritestore.RemoveFavorite("user_123", "manga_001", "manga")
// Get store statisticsstats:=store.GetStats()When using handler.RegisterRoutes(mux), the following endpoints are registered:
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/sync?user_id=X | Get user sync data |
| POST | /api/sync | Sync user data (merge) |
| POST | /api/sync/favorites | Add favorite |
| DELETE | /api/sync/favorites?user_id=X&item_id=Y&type=Z | Remove favorite |
| GET | /api/sync/status | Get sync stats |
| GET | /api/sync/status?user_id=X | Get user status |
| POST | /api/sync/register | Register new user |
typeSyncDatastruct {
UserIDstring`json:"user_id"`Usernamestring`json:"username,omitempty"`Avatarstring`json:"avatar,omitempty"`Favorites []FavoriteItem`json:"favorites"`WatchHistory []WatchedItem`json:"watch_history,omitempty"`ReadHistory []ReadItem`json:"read_history,omitempty"`SettingsUserSettings`json:"settings,omitempty"`LastSyncAtstring`json:"last_sync_at"`DeviceInfostring`json:"device_info,omitempty"`CreatedAtstring`json:"created_at,omitempty"`
}typeFavoriteItemstruct {
ItemIDstring`json:"item_id"`Titlestring`json:"title"`CoverImagestring`json:"cover_image"`URLstring`json:"url"`Typestring`json:"type"`// "anime" or "manga"Sourcestring`json:"source,omitempty"`Genres []string`json:"genres,omitempty"`AddedAtstring`json:"added_at"`LastReadAtstring`json:"last_read_at,omitempty"`LastReadstring`json:"last_read,omitempty"`Progressfloat64`json:"progress,omitempty"`
}# Build
go build -o server ./cmd/server/
# Run
./server -port 8080 -sync-file data/sync.jsonMIT