rename
This commit is contained in:
parent
45f7eff8b1
commit
2553a35a4a
2
.github/workflows/docker.yml
vendored
2
.github/workflows/docker.yml
vendored
@ -17,7 +17,7 @@ jobs:
|
||||
uses: docker/metadata-action@v5
|
||||
with:
|
||||
images: |
|
||||
nite07/pcgamedb
|
||||
nite07/game-crawler
|
||||
tags: |
|
||||
type=semver,pattern={{version}}
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
|
@ -1,4 +1,4 @@
|
||||
project_name: pcgamedb
|
||||
project_name: game-crawler
|
||||
before:
|
||||
hooks:
|
||||
- go install github.com/swaggo/swag/cmd/swag@latest
|
||||
@ -16,7 +16,7 @@ builds:
|
||||
- arm
|
||||
- "386"
|
||||
ldflags:
|
||||
- -s -w -X pcgamedb/constant.Version={{ .Version }}
|
||||
- -s -w -X game-crawler/constant.Version={{ .Version }}
|
||||
flags:
|
||||
- -trimpath
|
||||
archives:
|
||||
|
@ -14,10 +14,10 @@ ARG version=dev
|
||||
RUN if [ "$version" = "dev" ]; then \
|
||||
version=$(git describe --tags --always); \
|
||||
fi && \
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X pcgamedb/constant.Version=${version}" -o pcgamedb .
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X game-crawler/constant.Version=${version}" -o game-crawler .
|
||||
|
||||
FROM alpine:latest
|
||||
WORKDIR /app
|
||||
COPY --from=builder /app/pcgamedb /app/pcgamedb
|
||||
COPY --from=builder /app/game-crawler /app/game-crawler
|
||||
|
||||
ENTRYPOINT ["/app/pcgamedb", "server"]
|
||||
ENTRYPOINT ["/app/game-crawler", "server"]
|
@ -1,6 +1,6 @@
|
||||
# pcgamedb
|
||||
# game-crawler
|
||||
|
||||
pcgamedb is a powerful command-line tool designed to scrape and manage repack game data from various online sources. With support for multiple data sources and the ability to provide a RESTful API.
|
||||
game-crawler is a powerful command-line tool designed to scrape and manage repack game data from various online sources. With support for multiple data sources and the ability to provide a RESTful API.
|
||||
|
||||
## Features
|
||||
|
||||
|
2
build.sh
2
build.sh
@ -1,4 +1,4 @@
|
||||
go install github.com/swaggo/swag/cmd/swag@latest
|
||||
swag init
|
||||
CGO_ENABLED=0
|
||||
go build -o pcgamedb -ldflags "-s -w -X pcgamedb/constant.Version=$(git describe --tags --always)" .
|
||||
go build -o game-crawler -ldflags "-s -w -X game-crawler/constant.Version=$(git describe --tags --always)" .
|
||||
|
4
cache/redis.go
vendored
4
cache/redis.go
vendored
@ -6,8 +6,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/config"
|
||||
"game-crawler/log"
|
||||
|
||||
"github.com/redis/go-redis/v9"
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"pcgamedb/log"
|
||||
"pcgamedb/task"
|
||||
"game-crawler/log"
|
||||
"game-crawler/task"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/log"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/log"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
"go.uber.org/zap"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
)
|
||||
|
||||
type importCommandConfig struct {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.uber.org/zap"
|
||||
|
@ -4,9 +4,9 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/server"
|
||||
"game-crawler/config"
|
||||
"game-crawler/server"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -1,9 +1,9 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/log"
|
||||
"go.uber.org/zap"
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/log"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
@ -1,8 +1,8 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"pcgamedb/log"
|
||||
"pcgamedb/task"
|
||||
"game-crawler/log"
|
||||
"game-crawler/task"
|
||||
|
||||
"github.com/robfig/cron/v3"
|
||||
"github.com/spf13/cobra"
|
||||
|
@ -4,15 +4,15 @@ import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"game-crawler/constant"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Long: "Get version of pcgamedb",
|
||||
Short: "Get version of pcgamedb",
|
||||
Long: "Get version of game-crawler",
|
||||
Short: "Get version of game-crawler",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Printf("Version: %s\n", constant.Version)
|
||||
fmt.Printf("Go: %s\n", runtime.Version())
|
||||
|
@ -8,10 +8,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"go.uber.org/zap"
|
||||
|
@ -2,15 +2,16 @@ package crawler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"go.uber.org/zap"
|
||||
@ -47,7 +48,6 @@ func (c *ChovkaCrawler) CrawlByUrl(URL string) (*model.GameItem, error) {
|
||||
item.RawName = doc.Find(".inner-entry__title").First().Text()
|
||||
item.Name = ChovkaFormatter(item.RawName)
|
||||
item.Author = "Chovka"
|
||||
item.UpdateFlag = item.RawName
|
||||
item.Platform = "windows"
|
||||
downloadURL := doc.Find(".download-torrent").AttrOr("href", "")
|
||||
if downloadURL == "" {
|
||||
@ -83,7 +83,7 @@ func (c *ChovkaCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
return
|
||||
}
|
||||
urls = append(urls, u)
|
||||
updateFlags = append(updateFlags, s.Find(".entry__title.h2 a").Text())
|
||||
updateFlags = append(updateFlags, base64.StdEncoding.EncodeToString([]byte(s.Find(".entry__title.h2 a").Text())))
|
||||
})
|
||||
var res []*model.GameItem
|
||||
for i, u := range urls {
|
||||
@ -96,6 +96,7 @@ func (c *ChovkaCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
c.logger.Warn("Failed to crawl", zap.Error(err), zap.String("URL", u))
|
||||
continue
|
||||
}
|
||||
item.UpdateFlag = updateFlags[i]
|
||||
if err := db.SaveGameItem(item); err != nil {
|
||||
c.logger.Warn("Failed to save", zap.Error(err), zap.String("URL", u))
|
||||
continue
|
||||
|
@ -1,7 +1,7 @@
|
||||
package crawler
|
||||
|
||||
import (
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -4,8 +4,8 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -2,16 +2,17 @@ package crawler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"go.uber.org/zap"
|
||||
@ -91,7 +92,7 @@ func (c *FitGirlCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
d, exist2 := s.Find("time").First().Attr("datetime")
|
||||
if exist1 && exist2 {
|
||||
urls = append(urls, u)
|
||||
updateFlags = append(updateFlags, fmt.Sprintf("%s%s", u, d))
|
||||
updateFlags = append(updateFlags, base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s%s", u, d))))
|
||||
}
|
||||
})
|
||||
var res []*model.GameItem
|
||||
|
@ -11,11 +11,11 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/config"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"git.nite07.com/nite/ccs"
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
@ -79,7 +79,7 @@ func (c *FreeGOGCrawler) Crawl(num int) ([]*model.GameItem, error) {
|
||||
var updateFlags []string //rawName+link
|
||||
doc.Find(".items-outer li a").Each(func(i int, s *goquery.Selection) {
|
||||
urls = append(urls, s.AttrOr("href", ""))
|
||||
updateFlags = append(updateFlags, s.Text()+s.AttrOr("href", ""))
|
||||
updateFlags = append(updateFlags, base64.StdEncoding.EncodeToString([]byte(s.Text()+s.AttrOr("href", ""))))
|
||||
})
|
||||
|
||||
var res []*model.GameItem
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
|
@ -1,17 +1,18 @@
|
||||
package crawler
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/config"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"git.nite07.com/nite/ccs"
|
||||
"go.uber.org/zap"
|
||||
@ -116,7 +117,7 @@ func (c *GOGGamesCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
var updateFlags []string //link+date
|
||||
for _, item := range data.Data {
|
||||
urls = append(urls, fmt.Sprintf(constant.GOGGamesPageURL, item.Slug))
|
||||
updateFlags = append(updateFlags, fmt.Sprintf("%s%s", item.GogURL, item.LastUpdate))
|
||||
updateFlags = append(updateFlags, base64.StdEncoding.EncodeToString([]byte(fmt.Sprintf("%s%s", item.GogURL, item.LastUpdate))))
|
||||
}
|
||||
res := make([]*model.GameItem, 0)
|
||||
for i, u := range urls {
|
||||
@ -130,12 +131,6 @@ func (c *GOGGamesCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
continue
|
||||
}
|
||||
item.UpdateFlag = updateFlags[i]
|
||||
|
||||
oldItem, err := db.GetGameItemByUrl(u)
|
||||
if err == nil {
|
||||
db.MergeGameItem(oldItem, item)
|
||||
}
|
||||
|
||||
if err := db.SaveGameItem(item); err != nil {
|
||||
c.logger.Warn("Failed to save", zap.Error(err), zap.String("URL", u))
|
||||
continue
|
||||
|
@ -11,12 +11,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/config"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"github.com/go-resty/resty/v2"
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -2,6 +2,7 @@ package crawler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
@ -13,12 +14,12 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/config"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"go.uber.org/zap"
|
||||
@ -61,8 +62,7 @@ func (c *OnlineFixCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
urls = append(urls, s.Find(".big-link").First().AttrOr("href", ""))
|
||||
updateFlags = append(
|
||||
updateFlags,
|
||||
s.Find(".big-link").First().AttrOr("href", "")+
|
||||
s.Find("time").Text(),
|
||||
base64.StdEncoding.EncodeToString([]byte(s.Find(".big-link").First().AttrOr("href", "")+s.Find("time").Text())),
|
||||
)
|
||||
})
|
||||
|
||||
|
@ -9,10 +9,10 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
)
|
||||
|
||||
func GetSteamAppDetail(id int) (*model.SteamAppDetail, error) {
|
||||
|
@ -4,16 +4,16 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/db"
|
||||
"net/url"
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/db"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
)
|
||||
|
@ -2,15 +2,16 @@ package crawler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"go.uber.org/zap"
|
||||
@ -98,7 +99,7 @@ func (c *SteamRIPCrawler) Crawl(num int) ([]*model.GameItem, error) {
|
||||
return
|
||||
}
|
||||
urls = append(urls, fmt.Sprintf("%s%s", constant.SteamRIPBaseURL, u))
|
||||
updateFlags = append(updateFlags, s.Text())
|
||||
updateFlags = append(updateFlags, base64.StdEncoding.EncodeToString([]byte(s.Text())))
|
||||
})
|
||||
for i, u := range urls {
|
||||
if count == num {
|
||||
@ -114,12 +115,6 @@ func (c *SteamRIPCrawler) Crawl(num int) ([]*model.GameItem, error) {
|
||||
continue
|
||||
}
|
||||
item.UpdateFlag = updateFlags[i]
|
||||
|
||||
oldItem, err := db.GetGameItemByUrl(u)
|
||||
if err == nil {
|
||||
db.MergeGameItem(oldItem, item)
|
||||
}
|
||||
|
||||
if err := db.SaveGameItem(item); err != nil {
|
||||
c.logger.Warn("Failed to save item", zap.Error(err))
|
||||
continue
|
||||
|
@ -2,16 +2,17 @@ package crawler
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"github.com/PuerkitoBio/goquery"
|
||||
"go.uber.org/zap"
|
||||
@ -51,7 +52,7 @@ func (c *XatabCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
return
|
||||
}
|
||||
urls = append(urls, u)
|
||||
updateFlags = append(updateFlags, s.Find(".entry__title.h2 a").Text())
|
||||
updateFlags = append(updateFlags, base64.StdEncoding.EncodeToString([]byte(s.Find(".entry__title.h2 a").Text())))
|
||||
})
|
||||
var res []*model.GameItem
|
||||
for i, u := range urls {
|
||||
@ -64,6 +65,7 @@ func (c *XatabCrawler) Crawl(page int) ([]*model.GameItem, error) {
|
||||
c.logger.Warn("Failed to crawl", zap.Error(err), zap.String("URL", u))
|
||||
continue
|
||||
}
|
||||
item.UpdateFlag = updateFlags[i]
|
||||
err = db.SaveGameItem(item)
|
||||
if err != nil {
|
||||
c.logger.Warn("Failed to save", zap.Error(err))
|
||||
@ -95,7 +97,6 @@ func (c *XatabCrawler) CrawlByUrl(URL string) (*model.GameItem, error) {
|
||||
item.RawName = doc.Find(".inner-entry__title").First().Text()
|
||||
item.Name = XatabFormatter(item.RawName)
|
||||
item.Author = "Xatab"
|
||||
item.UpdateFlag = item.RawName
|
||||
item.Platform = "windows"
|
||||
downloadURL := doc.Find("#download>a").First().AttrOr("href", "")
|
||||
if downloadURL == "" {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
)
|
||||
|
||||
func GetDODIGameItems() ([]*model.GameItem, error) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package db
|
||||
|
||||
import "pcgamedb/model"
|
||||
import "game-crawler/model"
|
||||
|
||||
func IsARMGDDNCrawled(flag string) bool {
|
||||
return IsGameCrawled(flag, "armgddn")
|
||||
|
@ -3,7 +3,7 @@ package db
|
||||
import (
|
||||
"context"
|
||||
|
||||
"pcgamedb/config"
|
||||
"game-crawler/config"
|
||||
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
"go.mongodb.org/mongo-driver/mongo/options"
|
||||
|
4
db/db.go
4
db/db.go
@ -6,8 +6,8 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/config"
|
||||
"game-crawler/log"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
@ -5,8 +5,8 @@ import (
|
||||
"encoding/json"
|
||||
"time"
|
||||
|
||||
"game-crawler/model"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"pcgamedb/model"
|
||||
)
|
||||
|
||||
func Export() ([]byte, []byte, error) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
package db
|
||||
|
||||
import "pcgamedb/model"
|
||||
import "game-crawler/model"
|
||||
|
||||
func GetFitgirlAllGameItems() ([]*model.GameItem, error) {
|
||||
return GetGameItemsByAuthor("fitgirl")
|
||||
|
@ -1,7 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
)
|
||||
|
||||
func GetFreeGOGGameItems() ([]*model.GameItem, error) {
|
||||
|
@ -5,13 +5,13 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/utils"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/model"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
)
|
||||
|
||||
func ImportGameInfo(filePath string) error {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
)
|
||||
|
||||
func GetOnlineFixGameItems() ([]*model.GameItem, error) {
|
||||
|
@ -1,7 +1,7 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"pcgamedb/model"
|
||||
"game-crawler/model"
|
||||
)
|
||||
|
||||
func GetXatabGameItems() ([]*model.GameItem, error) {
|
||||
|
@ -1,22 +1,22 @@
|
||||
services:
|
||||
pcgamedb:
|
||||
image: nite07/pcgamedb
|
||||
game-crawler:
|
||||
image: nite07/game-crawler
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8080:8080"
|
||||
environment:
|
||||
- LOG_LEVEL=info
|
||||
- SERVER_PORT=8080
|
||||
- DATABASE_HOST=pcgamedb-mongodb
|
||||
- DATABASE_HOST=game-crawler-mongodb
|
||||
- DATABASE_PORT=27017
|
||||
- DATABASE_USER=root
|
||||
- DATABASE_PASSWORD=password
|
||||
- DATABASE_NAME=pcgamedb
|
||||
- REDIS_HOST=pcgamedb-redis
|
||||
- DATABASE_NAME=game-crawler
|
||||
- REDIS_HOST=game-crawler-redis
|
||||
- REDIS_PORT=6379
|
||||
- REDIS_DB=0
|
||||
# Read more about environment variables: config/config.go
|
||||
pcgamedb-mongodb:
|
||||
game-crawler-mongodb:
|
||||
image: mongo:latest
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
@ -24,7 +24,7 @@ services:
|
||||
MONGO_INITDB_ROOT_PASSWORD: password
|
||||
volumes:
|
||||
- ./mongodb:/data/db
|
||||
pcgamedb-redis:
|
||||
game-crawler-redis:
|
||||
image: redis:latest
|
||||
volumes:
|
||||
- ./redis:/data
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -4,7 +4,7 @@ import (
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/config"
|
||||
"game-crawler/config"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
|
4
main.go
4
main.go
@ -3,8 +3,8 @@ package main
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"pcgamedb/cmd"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/cmd"
|
||||
"game-crawler/log"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -50,7 +50,7 @@ type GameItem struct {
|
||||
Password string `json:"password,omitempty" bson:"password"`
|
||||
Author string `json:"author,omitempty" bson:"author"`
|
||||
Platform string `json:"platform,omitempty" bson:"platform"`
|
||||
UpdateFlag string `json:"-" bson:"update_flag,omitempty"`
|
||||
UpdateFlag string `json:"update_flag,omitempty" bson:"update_flag"`
|
||||
CreatedAt time.Time `json:"created_at" bson:"created_at"`
|
||||
UpdatedAt time.Time `json:"updated_at" bson:"updated_at"`
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/log"
|
||||
"pcgamedb/task"
|
||||
"game-crawler/log"
|
||||
"game-crawler/task"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -3,7 +3,7 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"game-crawler/db"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -3,7 +3,7 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"game-crawler/db"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/mongo"
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -1,10 +1,10 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"net/http"
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -6,9 +6,9 @@ import (
|
||||
"runtime"
|
||||
"time"
|
||||
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/constant"
|
||||
"pcgamedb/db"
|
||||
"game-crawler/config"
|
||||
"game-crawler/constant"
|
||||
"game-crawler/db"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
|
@ -3,8 +3,8 @@ package handler
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -4,7 +4,7 @@ import (
|
||||
"net/http"
|
||||
"strings"
|
||||
|
||||
"pcgamedb/config"
|
||||
"game-crawler/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
@ -2,7 +2,7 @@ package middleware
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"pcgamedb/log"
|
||||
"game-crawler/log"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
@ -3,7 +3,7 @@ package middleware
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"pcgamedb/log"
|
||||
"game-crawler/log"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"go.uber.org/zap"
|
||||
|
@ -3,14 +3,14 @@ package server
|
||||
import (
|
||||
"embed"
|
||||
"errors"
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
"game-crawler/server/handler"
|
||||
"game-crawler/server/middleware"
|
||||
"io/fs"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
"pcgamedb/server/handler"
|
||||
"pcgamedb/server/middleware"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
@ -20,7 +20,7 @@ import (
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.uber.org/zap"
|
||||
|
||||
"pcgamedb/docs"
|
||||
"game-crawler/docs"
|
||||
|
||||
swaggerfiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
@ -133,7 +133,7 @@ func initFrontend(app *gin.Engine) {
|
||||
page := ctx.Query("page")
|
||||
key = strings.TrimSpace(key)
|
||||
if len(key) < 2 {
|
||||
ctx.HTML(400, "400.html", errors.New("Search key should be at least 2 characters long"))
|
||||
ctx.HTML(400, "400.html", errors.New("search key should be at least 2 characters long"))
|
||||
return
|
||||
}
|
||||
if page == "" {
|
||||
|
@ -4,12 +4,12 @@ import (
|
||||
"io"
|
||||
"time"
|
||||
|
||||
"pcgamedb/cache"
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/log"
|
||||
"pcgamedb/server/middleware"
|
||||
"pcgamedb/task"
|
||||
"game-crawler/cache"
|
||||
"game-crawler/config"
|
||||
"game-crawler/db"
|
||||
"game-crawler/log"
|
||||
"game-crawler/server/middleware"
|
||||
"game-crawler/task"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/robfig/cron/v3"
|
||||
|
@ -3,8 +3,7 @@
|
||||
<footer class="text-light py-4 mt-5">
|
||||
<div class="container">
|
||||
<div class="col text-center">
|
||||
<div><a href="https://git.nite07.com/nite/pcgamedb" target="_blank">Open Source</a> | <a
|
||||
href="/api/swagger/index.html">API Doc</a></div>
|
||||
<div><a href="/api/swagger/index.html">API Doc</a></div>
|
||||
<div>Made by <a href="https://www.nite07.com" target="_blank">Nite</a></div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -1,7 +1,7 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"pcgamedb/db"
|
||||
"game-crawler/db"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -3,11 +3,11 @@ package task
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"pcgamedb/config"
|
||||
"pcgamedb/crawler"
|
||||
"pcgamedb/db"
|
||||
"pcgamedb/model"
|
||||
"pcgamedb/utils"
|
||||
"game-crawler/config"
|
||||
"game-crawler/crawler"
|
||||
"game-crawler/db"
|
||||
"game-crawler/model"
|
||||
"game-crawler/utils"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
"go.uber.org/zap"
|
||||
|
@ -1,7 +1,7 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"pcgamedb/crawler"
|
||||
"game-crawler/crawler"
|
||||
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user