mirror of
https://github.com/simon-ding/polaris.git
synced 2026-06-10 03:57:39 +08:00
feat: embed default tmdb api key
This commit is contained in:
2
.github/workflows/go.yml
vendored
2
.github/workflows/go.yml
vendored
@@ -58,4 +58,6 @@ jobs:
|
|||||||
platforms: linux/amd64
|
platforms: linux/amd64
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
build-args: |
|
||||||
|
TMDB_API_KEY=${{ secrets.TMDB_API_KEY }}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ ENV GO111MODULE=on
|
|||||||
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
|
ARG TMDB_API_KEY
|
||||||
|
|
||||||
COPY go.mod .
|
COPY go.mod .
|
||||||
COPY go.sum .
|
COPY go.sum .
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
@@ -13,7 +15,7 @@ RUN go mod download
|
|||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# 指定OS等,并go build
|
# 指定OS等,并go build
|
||||||
RUN CGO_ENABLED=0 go build -o polaris -ldflags="-X polaris/db.Version=$(git describe --tags --long)" ./cmd/
|
RUN CGO_ENABLED=0 go build -o polaris -ldflags="-X polaris/db.Version=$(git describe --tags --long) -X polaris/db.TmdbApiKey=$(echo $TMDB_API_KEY)" ./cmd/
|
||||||
|
|
||||||
FROM debian:stable-slim
|
FROM debian:stable-slim
|
||||||
|
|
||||||
|
|||||||
10
db/const.go
10
db/const.go
@@ -2,7 +2,10 @@ package db
|
|||||||
|
|
||||||
import "polaris/ent/media"
|
import "polaris/ent/media"
|
||||||
|
|
||||||
var Version = "undefined"
|
var (
|
||||||
|
Version = "undefined"
|
||||||
|
TmdbApiKey = ""
|
||||||
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
SettingTmdbApiKey = "tmdb_api_key"
|
SettingTmdbApiKey = "tmdb_api_key"
|
||||||
@@ -48,15 +51,16 @@ const DefaultNamingFormat = "{{.NameCN}} {{.NameEN}} {{if .Year}} ({{.Year}}) {{
|
|||||||
|
|
||||||
//https://en.wikipedia.org/wiki/Video_file_format
|
//https://en.wikipedia.org/wiki/Video_file_format
|
||||||
var defaultAcceptedVideoFormats = []string{
|
var defaultAcceptedVideoFormats = []string{
|
||||||
".webm", ".mkv", ".flv", ".vob", ".ogv", ".ogg", ".drc", ".mng", ".avi", ".mts", ".m2ts",".ts",
|
".webm", ".mkv", ".flv", ".vob", ".ogv", ".ogg", ".drc", ".mng", ".avi", ".mts", ".m2ts", ".ts",
|
||||||
".mov", ".qt", ".wmv", ".yuv", ".rm", ".rmvb", ".viv", ".amv", ".mp4", ".m4p", ".m4v",
|
".mov", ".qt", ".wmv", ".yuv", ".rm", ".rmvb", ".viv", ".amv", ".mp4", ".m4p", ".m4v",
|
||||||
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".m4v",
|
".mpg", ".mp2", ".mpeg", ".mpe", ".mpv", ".m2v", ".m4v",
|
||||||
".svi", ".3gp", ".3g2", ".nsv",
|
".svi", ".3gp", ".3g2", ".nsv",
|
||||||
}
|
}
|
||||||
|
|
||||||
var defaultAcceptedSubtitleFormats = []string{
|
var defaultAcceptedSubtitleFormats = []string{
|
||||||
".ass", ".srt",".vtt", ".webvtt", ".sub", ".idx",
|
".ass", ".srt", ".vtt", ".webvtt", ".sub", ".idx",
|
||||||
}
|
}
|
||||||
|
|
||||||
type NamingInfo struct {
|
type NamingInfo struct {
|
||||||
NameCN string
|
NameCN string
|
||||||
NameEN string
|
NameEN string
|
||||||
|
|||||||
9
db/db.go
9
db/db.go
@@ -733,3 +733,12 @@ func (c *Client) GetAcceptedSubtitleFormats() ([]string, error) {
|
|||||||
func (c *Client) SetAcceptedSubtitleFormats(key string, v []string) error {
|
func (c *Client) SetAcceptedSubtitleFormats(key string, v []string) error {
|
||||||
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
|
return c.setAcceptedFormats(SettingAcceptedSubtitleFormats, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
func (c *Client) GetTmdbApiKey() string {
|
||||||
|
k := c.GetSetting(SettingTmdbApiKey)
|
||||||
|
if k == "" {
|
||||||
|
return TmdbApiKey
|
||||||
|
}
|
||||||
|
return k
|
||||||
|
}
|
||||||
@@ -145,7 +145,7 @@ func (c *Client) GetDownloadClient() (pkg.Downloader, *ent.DownloadClients, erro
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) TMDB() (*tmdb.Client, error) {
|
func (c *Client) TMDB() (*tmdb.Client, error) {
|
||||||
api := c.db.GetSetting(db.SettingTmdbApiKey)
|
api := c.db.GetTmdbApiKey()
|
||||||
if api == "" {
|
if api == "" {
|
||||||
return nil, errors.New("TMDB apiKey not set")
|
return nil, errors.New("TMDB apiKey not set")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ func (s *Server) Serve() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) TMDB() (*tmdb.Client, error) {
|
func (s *Server) TMDB() (*tmdb.Client, error) {
|
||||||
api := s.db.GetSetting(db.SettingTmdbApiKey)
|
api := s.db.GetTmdbApiKey()
|
||||||
if api == "" {
|
if api == "" {
|
||||||
return nil, errors.New("TMDB apiKey not set")
|
return nil, errors.New("TMDB apiKey not set")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user