fix
This commit is contained in:
parent
5f24397d80
commit
692042685d
@ -1,6 +1,8 @@
|
|||||||
FROM golang:1.21-alpine AS builder
|
FROM golang:1.21-alpine AS builder
|
||||||
LABEL authors="Nite07"
|
LABEL authors="Nite07"
|
||||||
|
|
||||||
|
RUN apk add --no-cache git
|
||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
@ -9,7 +11,10 @@ COPY . .
|
|||||||
RUN go install github.com/swaggo/swag/cmd/swag@latest
|
RUN go install github.com/swaggo/swag/cmd/swag@latest
|
||||||
RUN swag init
|
RUN swag init
|
||||||
ARG version=dev
|
ARG version=dev
|
||||||
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X pcgamedb/constant.Version=${version}" -o pcgamedb .
|
RUN if [ "$version" = "dev" ]; then \
|
||||||
|
version=$(git describe --tags --always); \
|
||||||
|
fi && \
|
||||||
|
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X github.com/nitezs/pcgamedb/constant.Version=${version}" -o pcgamedb .
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
2
build.sh
2
build.sh
@ -1,4 +1,4 @@
|
|||||||
go install github.com/swaggo/swag/cmd/swag@latest
|
go install github.com/swaggo/swag/cmd/swag@latest
|
||||||
swag init
|
swag init
|
||||||
CGO_ENABLED=0
|
CGO_ENABLED=0
|
||||||
go build -o gamedb .
|
go build -o pcgamedb -ldflags "-s -w -X github.com/nitezs/pcgamedb/constant.Version=$(git describe --tags --always)" .
|
||||||
|
5
cache/redis.go
vendored
5
cache/redis.go
vendored
@ -3,11 +3,12 @@ package cache
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/redis/go-redis/v9"
|
"github.com/redis/go-redis/v9"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/log"
|
"github.com/nitezs/pcgamedb/log"
|
||||||
"pcgamedb/task"
|
"github.com/nitezs/pcgamedb/task"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -3,12 +3,13 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/crawler"
|
|
||||||
"pcgamedb/log"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/crawler"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/db"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
"pcgamedb/log"
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/crawler"
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
"pcgamedb/db"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
"pcgamedb/log"
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -3,9 +3,10 @@ package cmd
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
"pcgamedb/crawler"
|
|
||||||
"pcgamedb/db"
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
"pcgamedb/log"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/config"
|
"github.com/nitezs/pcgamedb/config"
|
||||||
"pcgamedb/server"
|
"github.com/nitezs/pcgamedb/server"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/log"
|
"github.com/nitezs/pcgamedb/log"
|
||||||
"pcgamedb/task"
|
"github.com/nitezs/pcgamedb/task"
|
||||||
|
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/crawler"
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
"pcgamedb/db"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
"pcgamedb/log"
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
@ -2,9 +2,10 @@ package cmd
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/constant"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
package constant
|
package constant
|
||||||
|
|
||||||
const (
|
var (
|
||||||
Version = "dev"
|
Version = "dev"
|
||||||
)
|
)
|
||||||
|
@ -8,10 +8,10 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"pcgamedb/constant"
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
"pcgamedb/db"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
"pcgamedb/utils"
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -6,14 +6,15 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/url"
|
"net/url"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/jlaffaye/ftp"
|
"github.com/jlaffaye/ftp"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -4,13 +4,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package crawler
|
package crawler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package crawler
|
package crawler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,14 +4,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -4,13 +4,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"html"
|
"html"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -2,13 +2,14 @@ package crawler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
)
|
)
|
||||||
|
@ -2,13 +2,14 @@ package crawler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -4,14 +4,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -5,16 +5,17 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"pcgamedb/cache"
|
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/cache"
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var TwitchToken string
|
var TwitchToken string
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package crawler
|
package crawler
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -7,15 +7,16 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -5,15 +5,16 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/url"
|
"net/url"
|
||||||
"pcgamedb/cache"
|
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/cache"
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
func _GetSteamID(name string) (int, error) {
|
func _GetSteamID(name string) (int, error) {
|
||||||
|
@ -4,16 +4,17 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/cache"
|
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/cache"
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -4,13 +4,14 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -4,14 +4,15 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/constant"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"pcgamedb/utils"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/constant"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"github.com/PuerkitoBio/goquery"
|
"github.com/PuerkitoBio/goquery"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetDODIGameDownloads() ([]*model.GameDownload, error) {
|
func GetDODIGameDownloads() ([]*model.GameDownload, error) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import "pcgamedb/model"
|
import "github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
func IsARMGDDNCrawled(flag string) bool {
|
func IsARMGDDNCrawled(flag string) bool {
|
||||||
return IsGameCrawled(flag, "armgddn")
|
return IsGameCrawled(flag, "armgddn")
|
||||||
|
@ -2,7 +2,8 @@ package db
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"pcgamedb/config"
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
5
db/db.go
5
db/db.go
@ -3,11 +3,12 @@ package db
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
"go.mongodb.org/mongo-driver/mongo/options"
|
"go.mongodb.org/mongo-driver/mongo/options"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import "pcgamedb/model"
|
import "github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
func GetFitgirlAllGameDownloads() ([]*model.GameDownload, error) {
|
func GetFitgirlAllGameDownloads() ([]*model.GameDownload, error) {
|
||||||
return GetGameDownloadsByAuthor("fitgirl")
|
return GetGameDownloadsByAuthor("fitgirl")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetFreeGOGGameDownloads() ([]*model.GameDownload, error) {
|
func GetFreeGOGGameDownloads() ([]*model.GameDownload, error) {
|
||||||
|
@ -5,14 +5,15 @@ import (
|
|||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"pcgamedb/cache"
|
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"regexp"
|
"regexp"
|
||||||
"slices"
|
"slices"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/cache"
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson"
|
"go.mongodb.org/mongo-driver/bson"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetOnlineFixGameDownloads() ([]*model.GameDownload, error) {
|
func GetOnlineFixGameDownloads() ([]*model.GameDownload, error) {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package db
|
package db
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetXatabGameDownloads() ([]*model.GameDownload, error) {
|
func GetXatabGameDownloads() ([]*model.GameDownload, error) {
|
||||||
|
2
go.mod
2
go.mod
@ -1,4 +1,4 @@
|
|||||||
module pcgamedb
|
module github.com/nitezs/pcgamedb
|
||||||
|
|
||||||
go 1.21.5
|
go 1.21.5
|
||||||
|
|
||||||
|
@ -2,9 +2,10 @@ package log
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"pcgamedb/config"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"go.uber.org/zap/zapcore"
|
"go.uber.org/zap/zapcore"
|
||||||
"gopkg.in/natefinch/lumberjack.v2"
|
"gopkg.in/natefinch/lumberjack.v2"
|
||||||
|
5
main.go
5
main.go
@ -1,10 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/cmd"
|
|
||||||
"pcgamedb/log"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/cmd"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/log"
|
|
||||||
"pcgamedb/task"
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
"github.com/nitezs/pcgamedb/task"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,8 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
@ -2,7 +2,8 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/mongo"
|
"go.mongodb.org/mongo-driver/mongo"
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/crawler"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -3,11 +3,12 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/crawler"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
|
@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
@ -2,11 +2,12 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/crawler"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/model"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
)
|
)
|
||||||
|
@ -2,9 +2,10 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/config"
|
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package middleware
|
package middleware
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/log"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,8 @@ package middleware
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"pcgamedb/log"
|
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package server
|
package server
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/server/handler"
|
"github.com/nitezs/pcgamedb/server/handler"
|
||||||
"pcgamedb/server/middleware"
|
"github.com/nitezs/pcgamedb/server/middleware"
|
||||||
|
|
||||||
"github.com/gin-contrib/cors"
|
"github.com/gin-contrib/cors"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
|
||||||
docs "pcgamedb/docs"
|
docs "github.com/nitezs/pcgamedb/docs"
|
||||||
|
|
||||||
swaggerfiles "github.com/swaggo/files"
|
swaggerfiles "github.com/swaggo/files"
|
||||||
ginSwagger "github.com/swaggo/gin-swagger"
|
ginSwagger "github.com/swaggo/gin-swagger"
|
||||||
|
@ -2,14 +2,15 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io"
|
"io"
|
||||||
"pcgamedb/cache"
|
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/db"
|
|
||||||
"pcgamedb/log"
|
|
||||||
"pcgamedb/server/middleware"
|
|
||||||
"pcgamedb/task"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/nitezs/pcgamedb/cache"
|
||||||
|
"github.com/nitezs/pcgamedb/config"
|
||||||
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
"github.com/nitezs/pcgamedb/log"
|
||||||
|
"github.com/nitezs/pcgamedb/server/middleware"
|
||||||
|
"github.com/nitezs/pcgamedb/task"
|
||||||
|
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package task
|
package task
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"pcgamedb/db"
|
"github.com/nitezs/pcgamedb/db"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -3,10 +3,11 @@ package task
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"pcgamedb/config"
|
|
||||||
"pcgamedb/crawler"
|
"github.com/nitezs/pcgamedb/config"
|
||||||
"pcgamedb/model"
|
"github.com/nitezs/pcgamedb/crawler"
|
||||||
"pcgamedb/utils"
|
"github.com/nitezs/pcgamedb/model"
|
||||||
|
"github.com/nitezs/pcgamedb/utils"
|
||||||
|
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
@ -19,13 +20,13 @@ func Crawl(logger *zap.Logger) {
|
|||||||
if c, ok := item.(crawler.PagedCrawler); ok {
|
if c, ok := item.(crawler.PagedCrawler); ok {
|
||||||
g, err := c.CrawlMulti([]int{1, 2, 3})
|
g, err := c.CrawlMulti([]int{1, 2, 3})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to crawl games", zap.String("crawler", c.Name()), zap.Error(err))
|
logger.Warn("Failed to crawl games", zap.String("crawler", c.Name()), zap.Error(err))
|
||||||
}
|
}
|
||||||
games = append(games, g...)
|
games = append(games, g...)
|
||||||
} else if c, ok := item.(crawler.SimpleCrawler); ok {
|
} else if c, ok := item.(crawler.SimpleCrawler); ok {
|
||||||
g, err := c.CrawlAll()
|
g, err := c.CrawlAll()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error("Failed to crawl games", zap.String("crawler", c.Name()), zap.Error(err))
|
logger.Warn("Failed to crawl games", zap.String("crawler", c.Name()), zap.Error(err))
|
||||||
}
|
}
|
||||||
games = append(games, g...)
|
games = append(games, g...)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user