server

package
v0.0.0-...-7c65f34 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2024 License: AGPL-3.0 Imports: 45 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ANIMATION_MUGEN_TAG_ID = "0377db02-3af6-43b8-9b08-c759df3d25c3"
View Source
var ANIME_TYPE = getMediaType("ANIME")
View Source
var AllScopes = Scopes{Kara: true, KaraRO: true, User: true}
View Source
var AudioTags = []AudioTag{
	{ID: "OP", Name: "Opening", Hue: 280, MugenTags: []string{"f02ad9b3-0bd9-4aad-85b3-9976739ba0e4"}, HasSongOrder: true},
	{ID: "ED", Name: "Ending", Hue: 280, MugenTags: []string{"38c77c56-2b95-4040-b676-0994a8cb0597"}, HasSongOrder: true},
	{ID: "INS", Name: "Insert", Hue: 280, MugenTags: []string{"5e5250d9-351a-4a82-98eb-55db50ad8962"}, HasSongOrder: true},
	{ID: "IS", Name: "Image Song", Hue: 280, MugenTags: []string{"10a1ad3e-a05c-4f5c-84b6-f491e3e3a92e"}, HasSongOrder: true},

	{ID: "LIVE", Name: "Live", Hue: 240, MugenTags: []string{"a0167949-580c-4de3-bf13-497e462e02f3", "55ce3d79-dcc2-453c-b00a-60ce0c1eba1c"}},

	{ID: "REMIX", Name: "Remix/Cover", Hue: 220, MugenTags: []string{"03e1e1d2-8641-47b7-bbcb-39a3df9ff21c", "188a5c46-63ff-4e9f-89e4-763468b6ea4a"}},
}

Audio tags

View Source
var CARTOON_TYPE = getMediaType("CARTOON")
View Source
var CONFIG = getKaraberusConfig()
View Source
var COVER_MUGEN_TAG_ID = "03e1e1d2-8641-47b7-bbcb-39a3df9ff21c"
View Source
var GAME_TYPE = getMediaType("GAME")
View Source
var LIVE_TYPE = getMediaType("LIVE")
View Source
var MediaTypes []MediaType = []MediaType{
	{ID: "ANIME", Name: "Anime", IconName: "tv"},
	{ID: "GAME", Name: "Game", IconName: "gamepad"},
	{ID: "LIVE", Name: "Live action", IconName: "film"},
	{ID: "CARTOON", Name: "Cartoon", IconName: "globe"},
}

Media types

View Source
var MugenDownloadSemaphore = semaphore.NewWeighted(5)
View Source
var S3_CLIENT *minio.Client = nil
View Source
var VIDEO_GAME_MUGEN_TAG_ID = "dbedd6b3-d125-4cd8-aa32-c4175e4ca3a3"
View Source
var VideoTags = []VideoTag{

	{ID: "FANMADE", Name: "Fanmade", Hue: 140, MugenTags: []string{"a6c79ce5-89ee-4d50-afe8-3abd7317f6c2"}},
	{ID: "STREAM", Name: "Stream", Hue: 160, MugenTags: []string{"55ce3d79-dcc2-453c-b00a-60ce0c1eba1c"}},
	{ID: "CONCERT", Name: "Concert", Hue: 260, MugenTags: []string{"a0167949-580c-4de3-bf13-497e462e02f3"}},
	{ID: "AD", Name: "Advertisement", Hue: 120, MugenTags: []string{"2ddb5358-e674-46fa-a6e1-7f5c5d56f8fa"}},
	{ID: "NSFW", Name: "Not Safe For Work", Hue: 0, MugenTags: []string{"e82ce681-6d7b-4fb6-abe4-daa8aaa9bbf9"}},
	{ID: "SPOILER", Name: "Spoiler", Hue: 20, MugenTags: []string{"24371984-5e4c-4485-a937-fb0c480ca23b"}},
	{ID: "EPILEPSY", Name: "Epilepsy", Hue: 0, MugenTags: []string{"51288600-29e0-4e41-a42b-77f0498e5691"}},
	{ID: "MV", Name: "Music Video", Hue: 120, MugenTags: []string{"7be1b15c-cff8-4b37-a649-5c90f3d569a9"}},
}

Video tags

View Source
var WEST_MUGEN_TAG_ID = "efe171c0-e8a1-4d03-98c0-60ecf741ad52"

Functions

func CheckValidFiletype

func CheckValidFiletype(type_directory string) bool

func Closer

func Closer(closer io.Closer)

func CreateJwtForUser

func CreateJwtForUser(
	ctx context.Context,
	sub string,
	expiresAt *time.Time,
	info *oidc.UserInfo) (*jwt.Token, string, error)

func CurrentArtists

func CurrentArtists(tx *gorm.DB) *gorm.DB

func CurrentKaras

func CurrentKaras(tx *gorm.DB) *gorm.DB

Filter out historic entries

func CurrentMedias

func CurrentMedias(tx *gorm.DB) *gorm.DB

func DBErrToHumaErr

func DBErrToHumaErr(err error) error

func DownloadFile

func DownloadFile(ctx context.Context, input *DownloadInput) (*huma.StreamResponse, error)

func DownloadFont

func DownloadFont(ctx context.Context, input *DownloadFontInput) (*huma.StreamResponse, error)

func GetDB

func GetDB(ctx context.Context) *gorm.DB

func GetFontObject

func GetFontObject(ctx context.Context, id uint) (*minio.Object, error)

func GetKaraLyrics

func GetKaraLyrics(ctx context.Context, kara KaraInfoDB) (string, error)

func GetKaraObject

func GetKaraObject(ctx context.Context, kara KaraInfoDB, filetype string) (*minio.Object, error)

func MakeCli

func MakeCli()

func MugenDownload

func MugenDownload(ctx context.Context, tx *gorm.DB, mugen_import MugenImport)

func RefreshMugen

func RefreshMugen(ctx context.Context, input *struct{}) (*struct{}, error)

func RefreshMugenImports

func RefreshMugenImports(ctx context.Context) error

func RunKaraberus

func RunKaraberus(app *fiber.App, api huma.API)

func SaveFontToS3

func SaveFontToS3(ctx context.Context, fd io.Reader, id uint, filesize int64) error

func StartDakaraSync

func StartDakaraSync(ctx context.Context, input *struct{}) (*struct{}, error)

func SyncDakara

func SyncDakara(ctx context.Context)

func SyncDakaraLoop

func SyncDakaraLoop(ctx context.Context)

func SyncDakaraNotify

func SyncDakaraNotify()

Notify the sync worker (non blocking)

func SyncMugen

func SyncMugen(ctx context.Context)

func UploadToS3

func UploadToS3(ctx context.Context, file io.Reader, filename string, filesize int64, user_metadata map[string]string) error

func UploadedKaras

func UploadedKaras(db *gorm.DB) *gorm.DB

func Warn

func Warn(msg string)

func WithAssociationsUpdate

func WithAssociationsUpdate(tx *gorm.DB) *gorm.DB

Types

type APIToken

type APIToken struct {
	ID        uint      `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	Scopes    Scopes    `gorm:"embedded" json:"scopes"`
}

type AdditionalName

type AdditionalName struct {
	gorm.Model
	Name string
}

func (*AdditionalName) BeforeSave

func (name *AdditionalName) BeforeSave(tx *gorm.DB) error

type AllArtistsOutput

type AllArtistsOutput struct {
	Body []Artist `json:"artists"`
}

func GetAllArtists

func GetAllArtists(ctx context.Context, input *struct{}) (*AllArtistsOutput, error)

type AllAuthorOutput

type AllAuthorOutput struct {
	Body []TimingAuthor `json:"authors"`
}

func GetAllAuthors

func GetAllAuthors(ctx context.Context, input *struct{}) (*AllAuthorOutput, error)

type AllMediaTypesOutput

type AllMediaTypesOutput struct {
	Body []MediaType `json:"media_types"`
}

func GetAllMediaTypes

func GetAllMediaTypes(ctx context.Context, input *struct{}) (*AllMediaTypesOutput, error)

type AllMediasOutput

type AllMediasOutput struct {
	Body []MediaDB `json:"medias"`
}

func GetAllMedias

func GetAllMedias(ctx context.Context, input *struct{}) (*AllMediasOutput, error)

type AllTags

type AllTags struct {
	Authors []TimingAuthor
	Artists []Artist
	Video   []VideoTagDB
	Audio   []AudioTagDB
	Media   []MediaDB
}

type Artist

type Artist struct {
	gorm.Model
	Name            string           `gorm:"uniqueIndex:idx_artist_name_v2,where:current_artist_id IS NULL AND deleted_at IS NULL"`
	AdditionalNames []AdditionalName `gorm:"many2many:artists_additional_name"`
	CurrentArtistID *uint
	CurrentArtist   *Artist
	Editor
}

func GetArtistByID

func GetArtistByID(tx *gorm.DB, Id uint) (*Artist, error)

func (*Artist) AfterUpdate

func (a *Artist) AfterUpdate(tx *gorm.DB) error

func (*Artist) BeforeSave

func (a *Artist) BeforeSave(tx *gorm.DB) error

func (*Artist) BeforeUpdate

func (a *Artist) BeforeUpdate(tx *gorm.DB) error

type ArtistInfo

type ArtistInfo struct {
	Name            string   `json:"name"`
	AdditionalNames []string `json:"additional_names"`
}

type ArtistOutput

type ArtistOutput struct {
	Body struct {
		Artist Artist `json:"artist"`
	}
}

func CreateArtist

func CreateArtist(ctx context.Context, input *CreateArtistInput) (*ArtistOutput, error)

func FindArtist

func FindArtist(ctx context.Context, input *FindArtistInput) (*ArtistOutput, error)

func GetArtist

func GetArtist(ctx context.Context, input *GetArtistInput) (*ArtistOutput, error)

func UpdateArtist

func UpdateArtist(ctx context.Context, input *UpdateArtistInput) (*ArtistOutput, error)

type AudioTag

type AudioTag struct {
	ID   string // used in the database/API
	Name string // user visible name
	// Hue in deg
	Hue uint
	// Mugen tag ID (optional)
	MugenTags []string
	// true if this type can have a song order
	HasSongOrder bool
}

type AudioTagDB

type AudioTagDB struct {
	ID string
}

type AudioTagsOutput

type AudioTagsOutput struct {
	Body []AudioTag `json:"audio_tags"`
}

func GetAudioTags

func GetAudioTags(ctx context.Context, input *struct{}) (*AudioTagsOutput, error)

type AuthorInfo

type AuthorInfo struct {
	Name string `json:"name"`
}

type AuthorOutput

type AuthorOutput struct {
	Body struct {
		Author TimingAuthor `json:"author"`
	}
}

func CreateAuthor

func CreateAuthor(ctx context.Context, input *CreateAuthorInput) (*AuthorOutput, error)

func FindAuthor

func FindAuthor(ctx context.Context, input *FindAuthorInput) (*AuthorOutput, error)

func GetAuthor

func GetAuthor(ctx context.Context, input *GetAuthorInput) (*AuthorOutput, error)

func UpdateAuthor

func UpdateAuthor(ctx context.Context, input *UpdateAuthorInput) (*AuthorOutput, error)

type CheckKaraOutput

func CheckKara

func CheckKara(ctx context.Context, kara KaraInfoDB) (*CheckKaraOutput, error)

func SaveFileToS3

func SaveFileToS3(ctx context.Context, tx *gorm.DB, fd io.Reader, kara *KaraInfoDB, type_directory string, filesize int64) (*CheckKaraOutput, error)

func SaveFileToS3WithMetadata

func SaveFileToS3WithMetadata(ctx context.Context, tx *gorm.DB, fd io.Reader, kara *KaraInfoDB, type_directory string, filesize int64, user_metadata map[string]string) (*CheckKaraOutput, error)

func SaveMugenResponseToS3

func SaveMugenResponseToS3(ctx context.Context, tx *gorm.DB, resp *http.Response, kara MugenImport, type_directory string, user_metadata map[string]string) (*CheckKaraOutput, error)

type CheckS3FileOutput

type CheckS3FileOutput struct {
	Passed bool `json:"passed" example:"true" doc:"true if file passed all checks"`
}

type CreateArtistInput

type CreateArtistInput struct {
	Body ArtistInfo
}

type CreateAuthorInput

type CreateAuthorInput struct {
	Body AuthorInfo
}

type CreateKaraInput

type CreateKaraInput struct {
	Body KaraInfo
}

type CreateMediaInput

type CreateMediaInput struct {
	Body MediaInfo
}

type CreateTokenInput

type CreateTokenInput struct {
	Body struct {
		Name   string `json:"name"`
		Scopes Scopes `json:"scopes"`
	}
}

type CreateTokenOutput

type CreateTokenOutput struct {
	Body struct {
		Token string `json:"token"`
	}
}

func CreateToken

func CreateToken(ctx context.Context, input *CreateTokenInput) (*CreateTokenOutput, error)

type DakaraArtist

type DakaraArtist struct {
	DakaraArtistBody
	ID        int `json:"id"`
	SongCount int `json:"song_count"`
}

type DakaraArtistBody

type DakaraArtistBody struct {
	Name string `json:"name"`
}

type DakaraGetArtistsResponse

type DakaraGetArtistsResponse struct {
	DakaraPaginatedResponse
	Results []DakaraArtist `json:"results"`
}

type DakaraGetSongsResponse

type DakaraGetSongsResponse struct {
	DakaraPaginatedResponse
	Results []DakaraSong `json:"results"`
}

type DakaraGetTagsResponse

type DakaraGetTagsResponse struct {
	DakaraPaginatedResponse
	Results []DakaraTag `json:"results"`
}

type DakaraGetWorkTypesResponse

type DakaraGetWorkTypesResponse struct {
	DakaraPaginatedResponse
	Results []DakaraWorkType `json:"results"`
}

type DakaraGetWorksResponse

type DakaraGetWorksResponse struct {
	DakaraPaginatedResponse
	Results []DakaraWork `json:"results"`
}

type DakaraLyricsPreview

type DakaraLyricsPreview struct {
	Text      string `json:"text"`
	Truncated bool   `json:"truncated"`
}

type DakaraOutput

type DakaraOutput struct {
	Status int
	Body   []byte
}

type DakaraPaginatedResponse

type DakaraPaginatedResponse struct {
	Pagination DakaraPagination `json:"pagination"`
	Count      int              `json:"count" example:"99"`
}

type DakaraPagination

type DakaraPagination struct {
	Current int `json:"current" example:"1"`
	Last    int `json:"last" example:"10"`
}

type DakaraSong

type DakaraSong struct {
	ID              int                 `json:"id"`
	Title           string              `json:"title"`
	Filename        string              `json:"filename"` // basically our ID
	Duration        int32               `json:"duration"`
	Directory       string              `json:"directory"`
	Version         string              `json:"version"`
	Detail          string              `json:"detail"`
	DetailVideo     string              `json:"detail_video"`
	Tags            []DakaraTag         `json:"tags"`
	Artists         []DakaraArtist      `json:"artists"`
	Works           []DakaraSongWork    `json:"works"`
	LyricsPreview   DakaraLyricsPreview `json:"lyrics_preview"`
	HasInstrumental bool                `json:"has_instrumental"`
	DateCreated     time.Time           `json:"date_created"`
	DateUpdated     time.Time           `json:"date_updated"`
}

type DakaraSongBody

type DakaraSongBody struct {
	Title           string           `json:"title"`
	Filename        string           `json:"filename"` // basically our ID
	Duration        int32            `json:"duration"`
	Directory       string           `json:"directory"`
	Version         string           `json:"version"`
	Detail          string           `json:"detail"`
	DetailVideo     string           `json:"detail_video"`
	Tags            []DakaraTag      `json:"tags"`
	Artists         []DakaraArtist   `json:"artists"`
	Works           []DakaraSongWork `json:"works"`
	Lyrics          string           `json:"lyrics"`
	HasInstrumental bool             `json:"has_instrumental"`
}

func (DakaraSongBody) HasChanged

func (body DakaraSongBody) HasChanged(ref DakaraSong) bool

type DakaraSongWork

type DakaraSongWork struct {
	Work           DakaraWork `json:"work"`
	LinkType       string     `json:"link_type"`
	LinkTypeNumber *uint      `json:"link_type_number"`
}

type DakaraTag

type DakaraTag struct {
	ID       int    `json:"id"`
	Name     string `json:"name"`
	ColorHue int    `json:"color_hue"`
	Disabled bool   `json:"disabled"`
}

type DakaraTagBody

type DakaraTagBody struct {
	Name string `json:"name"`
	Hue  uint   `json:"color_hue"`
}

type DakaraWork

type DakaraWork struct {
	ID                int                `json:"id"`
	Title             string             `json:"title"`
	Subtitle          string             `json:"subtitle"` // we ignore subtitles
	AlternativeTitles []string           `json:"AlternativeTitles"`
	WorkType          DakaraWorkTypeBody `json:"work_type"`
	SongCount         int                `json:"song_count"`
}

type DakaraWorkBody

type DakaraWorkBody struct {
	Title    string             `json:"title"`
	WorkType DakaraWorkTypeBody `json:"work_type"`
}

type DakaraWorkType

type DakaraWorkType struct {
	DakaraWorkTypeBody
}

type DakaraWorkTypeBody

type DakaraWorkTypeBody struct {
	QueryName  string `json:"query_name"`
	Name       string `json:"name"`
	NamePlural string `json:"name_plural"`
	IconName   string `json:"icon_name"`
}

type DeleteArtistResponse

type DeleteArtistResponse struct {
	Status int
}

func DeleteArtist

func DeleteArtist(ctx context.Context, input *GetArtistInput) (*DeleteArtistResponse, error)

type DeleteAuthorResponse

type DeleteAuthorResponse struct {
	Status int
}

func DeleteAuthor

func DeleteAuthor(ctx context.Context, input *GetArtistInput) (*DeleteAuthorResponse, error)

type DeleteKaraResponse

type DeleteKaraResponse struct {
	Status int
}

func DeleteKara

func DeleteKara(ctx context.Context, input *GetKaraInput) (*DeleteKaraResponse, error)

type DeleteMediaResponse

type DeleteMediaResponse struct {
	Status int
}

func DeleteMedia

func DeleteMedia(ctx context.Context, input *GetMediaInput) (*DeleteMediaResponse, error)

type DeleteMugenImportInput

type DeleteMugenImportInput struct {
	ID uuid.UUID `path:"id"`
}

type DeleteMugenImportOutput

type DeleteMugenImportOutput struct {
	Status int
}

type DeleteTokenInput

type DeleteTokenInput struct {
	TokenID uint `path:"token"`
}

type DeleteTokenOutput

type DeleteTokenOutput struct {
	Body struct {
		Message string `json:"message" example:"Token 123 deleted."`
	}
}

func DeleteToken

func DeleteToken(ctx context.Context, input *DeleteTokenInput) (*DeleteTokenOutput, error)

type DownloadFontInput

type DownloadFontInput struct {
	ID    uint   `path:"id" example:"1"`
	Range string `header:"Range"`
}

type DownloadHeadOutput

type DownloadHeadOutput struct {
	AcceptRange   string `header:"Accept-Range"`
	ContentLength int64  `header:"Content-Length"`
	ContentType   string `header:"Content-Type"`
}

func DownloadHead

func DownloadHead(ctx context.Context, input *DownloadInput) (*DownloadHeadOutput, error)

type DownloadInput

type DownloadInput struct {
	KID      uint   `path:"id" example:"1"`
	FileType string `path:"filetype" example:"video"`
	Range    string `header:"Range"`
}

type Editor

type Editor struct {
	EditorUserID *string
	EditorUser   *User `gorm:"foreignKey:EditorUserID;references:ID"`
}

type FileSender

type FileSender struct {
	// Reader should be already at the Range.Start location
	Fd        io.ReadCloser
	Range     httputils.Range
	BytesRead uint64
}

func (*FileSender) Close

func (f *FileSender) Close() error

func (*FileSender) Read

func (f *FileSender) Read(buf []byte) (int, error)

type FindArtistInput

type FindArtistInput struct {
	Name string `query:"name"`
}

type FindAuthorInput

type FindAuthorInput struct {
	Name string `query:"name"`
}

type FindMediaInput

type FindMediaInput struct {
	Name string `query:"name"`
}

type Font

type Font struct {
	gorm.Model
	Name       string
	UploadedAt time.Time
}

type GetAllFontsOutput

type GetAllFontsOutput struct {
	Body struct {
		Fonts []Font
	}
}

func GetAllFonts

func GetAllFonts(ctx context.Context, input *struct{}) (*GetAllFontsOutput, error)

type GetAllKarasOutput

type GetAllKarasOutput struct {
	Body struct {
		Karas []KaraInfoDB
	}
}

func GetAllKaras

func GetAllKaras(ctx context.Context, input *struct{}) (*GetAllKarasOutput, error)

type GetAllTokensOutput

type GetAllTokensOutput struct {
	Body []APIToken
}

func GetAllUserTokens

func GetAllUserTokens(ctx context.Context, input *struct{}) (*GetAllTokensOutput, error)

type GetArtistInput

type GetArtistInput struct {
	Id uint `path:"id" example:"1"`
}

type GetAuthorInput

type GetAuthorInput struct {
	Id uint `path:"id" example:"1"`
}

type GetKaraHistoryOutput

type GetKaraHistoryOutput struct {
	Body struct {
		History []KaraInfoDB `json:"history"`
	}
}

func GetKaraHistory

func GetKaraHistory(ctx context.Context, input *GetKaraInput) (*GetKaraHistoryOutput, error)

type GetKaraInput

type GetKaraInput struct {
	Id uint `path:"id"`
}

type GetMediaInput

type GetMediaInput struct {
	Id uint `path:"id" example:"1"`
}

type GetMugenImportsOutput

type GetMugenImportsOutput struct {
	Body struct {
		Imports []MugenImport `json:"imports"`
	}
}

func GetMugenImports

func GetMugenImports(ctx context.Context, input *struct{}) (*GetMugenImportsOutput, error)

type ImportMugenKaraInput

type ImportMugenKaraInput struct {
	Body struct {
		MugenKID uuid.UUID `json:"mugen_kid"`
	}
}

type ImportMugenKaraOutput

type ImportMugenKaraOutput struct {
	Status int
	Body   struct {
		Import MugenImport `json:"import"`
	}
}

type KaraInfo

type KaraInfo struct {
	// Main name of the karaoke
	Title string `json:"title" example:"Zankoku na Tenshi no These"`
	// More names relating to this karaoke
	ExtraTitles []string `json:"title_aliases" example:"[\"A Cruel Angel's Thesis\"]"`
	// Karaoke authors
	Authors []uint `json:"authors" example:"[1]"`
	// Artists of the original song
	Artists []uint `json:"artists" example:"[1]"`
	// Name of the Media
	SourceMedia uint `json:"source_media" example:"1"`
	// Number of the track related to the media.
	SongOrder uint `json:"song_order" example:"0"`
	// Medias related to the karaoke
	Medias []uint `json:"medias"`
	// Audio tags
	AudioTags []string `json:"audio_tags" example:"[\"Opening\"]"`
	// Video tags
	VideoTags []string `json:"video_tags" example:"[\"Opening\"]"`
	// Generic comment
	Comment string `json:"comment" example:"From https://youtu.be/dQw4w9WgXcQ"`
	// Version (8-bit, Episode 12, ...)
	Version string `json:"version" example:"iykyk"`
	// Language (FR, EN, ...)
	Language            string `json:"language" example:"FR"`
	KaraokeCreationDate *int64 `json:"karaoke_creation_time,omitempty" example:"42"`
	IsHardsub           *bool  `json:"is_hardsub,omitempty" example:"false"`
}

type KaraInfoDB

type KaraInfoDB struct {
	gorm.Model
	Authors       []TimingAuthor `gorm:"many2many:kara_authors_tags"`
	Artists       []Artist       `gorm:"many2many:kara_artist_tags"`
	VideoTags     []VideoTagDB   `gorm:"many2many:kara_video_tags"`
	AudioTags     []AudioTagDB   `gorm:"many2many:kara_audio_tags"`
	SourceMediaID *uint
	SourceMedia   *MediaDB  `gorm:"foreignKey:SourceMediaID;references:ID"`
	Medias        []MediaDB `gorm:"many2many:kara_media_tags"`
	Title         string
	ExtraTitles   []AdditionalName `gorm:"many2many:kara_info_additional_name"`
	Version       string
	Comment       string
	SongOrder     uint
	Language      string
	UploadInfo
	// Can't be set by users
	CurrentKaraInfoID *uint
	CurrentKaraInfo   *KaraInfoDB
	Editor
}

func GetKaraByID

func GetKaraByID(db *gorm.DB, kara_id uint) (KaraInfoDB, error)

func (*KaraInfoDB) AfterUpdate

func (ki *KaraInfoDB) AfterUpdate(tx *gorm.DB) error

func (KaraInfoDB) AudioFilename

func (k KaraInfoDB) AudioFilename() string

func (*KaraInfoDB) BeforeSave

func (ki *KaraInfoDB) BeforeSave(tx *gorm.DB) error

func (*KaraInfoDB) BeforeUpdate

func (ki *KaraInfoDB) BeforeUpdate(tx *gorm.DB) error

func (KaraInfoDB) SubsFilename

func (k KaraInfoDB) SubsFilename() string

func (KaraInfoDB) VideoFilename

func (k KaraInfoDB) VideoFilename() string

type KaraOutput

type KaraOutput struct {
	Body struct {
		Kara KaraInfoDB `json:"kara"`
	}
}

func CreateKara

func CreateKara(ctx context.Context, input *CreateKaraInput) (*KaraOutput, error)

func GetKara

func GetKara(ctx context.Context, input *GetKaraInput) (*KaraOutput, error)

func UpdateKara

func UpdateKara(ctx context.Context, input *UpdateKaraInput) (*KaraOutput, error)

type KaraberusClaims

type KaraberusClaims struct {
	IsAdmin bool `json:"is_admin"`
	Scopes
	oidc.IDTokenClaims
	jwt.MapClaims `json:"-"`
}

type KaraberusConfig

type KaraberusConfig struct {
	S3        KaraberusS3Config     `env_prefix:"S3"`
	OIDC      KaraberusOIDCConfig   `env_prefix:"OIDC"`
	Listen    KaraberusListenConfig `env_prefix:"LISTEN"`
	DB        KaraberusDBConfig     `env_prefix:"DB"`
	Dakara    KaraberusDakaraConfig `env_prefix:"DAKARA"`
	UIDistDir string                `envkey:"UI_DIST_DIR" default:"/usr/share/karaberus/ui_dist"`
}

type KaraberusDBConfig

type KaraberusDBConfig struct {
	Driver string `envkey:"DRIVER" default:"sqlite"`
	DSN    string `envkey:"DSN" default:"user=karaberus password=karaberus dbname=karaberus port=5123 sslmode=disable TimeZone=UTC"`
	File   string `envkey:"FILE" default:"karaberus.db"`
}

type KaraberusDakaraConfig

type KaraberusDakaraConfig struct {
	BaseURL string `envkey:"BASE_URL"`
	Token   string `envkey:"TOKEN"`
}

type KaraberusError

type KaraberusError struct {
	Message string
}

func (*KaraberusError) Error

func (m *KaraberusError) Error() string

type KaraberusListenConfig

type KaraberusListenConfig struct {
	Host      string `envkey:"HOST" default:"127.0.0.1"`
	Port      int    `envkey:"PORT" default:"8888"`
	BaseURL   string `envkey:"BASE_URL"`
	Profiling bool   `envkey:"PROFILING"`
}

func (KaraberusListenConfig) Addr

func (c KaraberusListenConfig) Addr() string

type KaraberusOIDCConfig

type KaraberusOIDCConfig struct {
	Issuer       string `envkey:"ISSUER"`
	ClientID     string `envkey:"CLIENT_ID"`
	ClientSecret string `envkey:"CLIENT_SECRET"`
	Scopes       string `envkey:"SCOPES" default:"openid profile email"`
	IDClaim      string `envkey:"ID_CLAIM"`
	GroupsClaim  string `envkey:"GROUPS_CLAIM"`
	AdminGroup   string `envkey:"ADMIN_GROUP"`
	JwtSignKey   string `envkey:"JWT_SIGN_KEY"`
}

func (KaraberusOIDCConfig) Validate

func (c KaraberusOIDCConfig) Validate() error

type KaraberusS3Config

type KaraberusS3Config struct {
	Endpoint   string `envkey:"ENDPOINT"`
	KeyID      string `envkey:"KEYID"`
	Secret     string `envkey:"SECRET"`
	Secure     bool   `envkey:"SECURE"`
	BucketName string `envkey:"BUCKET_NAME" default:"karaberus"`
}

type Media

type Media struct {
	Name      string `json:"name" example:"Shinseiki Evangelion"`
	MediaType string `json:"media_type" example:"Anime"`
}

type MediaDB

type MediaDB struct {
	gorm.Model
	Name            string           `` /* 138-byte string literal not displayed */
	Type            string           `` /* 129-byte string literal not displayed */
	AdditionalNames []AdditionalName `json:"additional_name" gorm:"many2many:media_additional_name"`
	CurrentMediaID  *uint
	CurrentMedia    *MediaDB
	Editor
}

func (*MediaDB) AfterUpdate

func (m *MediaDB) AfterUpdate(tx *gorm.DB) error

func (*MediaDB) BeforeSave

func (m *MediaDB) BeforeSave(tx *gorm.DB) error

func (*MediaDB) BeforeUpdate

func (m *MediaDB) BeforeUpdate(tx *gorm.DB) error

type MediaInfo

type MediaInfo struct {
	Name            string   `json:"name" example:"Shinseiki Evangelion"`
	MediaType       string   `json:"media_type" example:"ANIME"`
	AdditionalNames []string `json:"additional_names" example:"[]"`
}

type MediaOutput

type MediaOutput struct {
	Body struct {
		Media MediaDB `json:"media"`
	}
}

func CreateMedia

func CreateMedia(ctx context.Context, input *CreateMediaInput) (*MediaOutput, error)

func FindMedia

func FindMedia(ctx context.Context, input *FindMediaInput) (*MediaOutput, error)

func GetMedia

func GetMedia(ctx context.Context, input *GetMediaInput) (*MediaOutput, error)

func UpdateMedia

func UpdateMedia(ctx context.Context, input *UpdateMediaInput) (*MediaOutput, error)

type MediaType

type MediaType struct {
	ID       string // used in the database/API
	Name     string // user visible name
	IconName string // font-awesome icon name
}

type MugenImport

type MugenImport struct {
	MugenKID uuid.UUID `gorm:"primarykey"`
	KaraID   uint
	Kara     KaraInfoDB `gorm:"foreignKey:KaraID;references:ID;constraint:OnDelete:CASCADE"`
}

type Scopes

type Scopes struct {
	Kara   bool `json:"kara"`
	KaraRO bool `json:"kara_ro"`
	User   bool `json:"user"`
}

func (Scopes) HasScope

func (scopes Scopes) HasScope(scope string) bool

type SetKaraUploadTimeInput

type SetKaraUploadTimeInput struct {
	Id   uint `path:"id"`
	Body struct {
		CreationDate int64 `json:"creation_time" example:"42"`
	}
}

type TagInterface

type TagInterface interface {
	// contains filtered or unexported methods
}

type TagType

type TagType struct {
	ID   string // used in the database/API
	Name string // user visible name
	// Hue in deg
	Hue uint
	// Mugen tag ID (optional)
	MugenTags []string
}

type TimingAuthor

type TimingAuthor struct {
	gorm.Model
	Name    string     `gorm:"uniqueIndex:idx_timing_author_name"`
	MugenID *uuid.UUID `gorm:"uniqueIndex:idx_timing_author_mugen_id"`
}

func GetAuthorById

func GetAuthorById(tx *gorm.DB, Id uint) (*TimingAuthor, error)

func (*TimingAuthor) BeforeSave

func (name *TimingAuthor) BeforeSave(tx *gorm.DB) error

type TokenV2

type TokenV2 struct {
	ID        uint      `gorm:"primarykey" json:"id"`
	CreatedAt time.Time `json:"created_at"`
	Token     string    `gorm:"uniqueIndex:idx_token" json:"token"`
	UserID    string    `json:"user_id"`
	User      User      `gorm:"foreignKey:UserID;references:ID" json:"user"`
	Name      string    `json:"name"`
	Scopes    Scopes    `gorm:"embedded" json:"scopes"`
}

func (*TokenV2) BeforeSave

func (name *TokenV2) BeforeSave(tx *gorm.DB) error

type UpdateArtistInput

type UpdateArtistInput struct {
	Id   uint `path:"id"`
	Body ArtistInfo
}

type UpdateAssociations

type UpdateAssociations struct{}

type UpdateAuthorInput

type UpdateAuthorInput struct {
	Id   uint `path:"id"`
	Body AuthorInfo
}

type UpdateKaraInput

type UpdateKaraInput struct {
	Id   uint `path:"id"`
	Body KaraInfo
}

type UpdateMediaInput

type UpdateMediaInput struct {
	Id   uint `path:"id"`
	Body MediaInfo
}

type UploadData

type UploadData struct {
	UploadFile multipart.File `form-data:"file" required:"true"`
}

type UploadFontInput

type UploadFontInput struct {
	File UploadTempFile
}

func (*UploadFontInput) Resolve

func (i *UploadFontInput) Resolve(ctx huma.Context) []error

type UploadFontInputDefinition

type UploadFontInputDefinition struct {
	RawBody huma.MultipartFormFiles[UploadData]
}

type UploadFontOutput

type UploadFontOutput struct {
	Body struct {
		Font Font `json:"font"`
	}
}

func UploadFont

func UploadFont(ctx context.Context, input *UploadFontInput) (*UploadFontOutput, error)

type UploadInfo

type UploadInfo struct {
	VideoUploaded        bool
	VideoModTime         time.Time
	InstrumentalUploaded bool
	InstrumentalModTime  time.Time
	SubtitlesUploaded    bool
	SubtitlesModTime     time.Time
	Hardsubbed           bool
	Duration             int32
	// date of the first upload of the sub file
	KaraokeCreationTime time.Time
}

type UploadInput

type UploadInput struct {
	KID      uint   `path:"id" example:"1"`
	FileType string `path:"filetype" example:"video"`
	File     UploadTempFile
}

func (*UploadInput) Resolve

func (i *UploadInput) Resolve(ctx huma.Context) []error

type UploadInputDefinition

type UploadInputDefinition struct {
	KID      uint   `path:"id" example:"1"`
	FileType string `path:"filetype" example:"video"`
	RawBody  huma.MultipartFormFiles[UploadData]
}

type UploadOutput

type UploadOutput struct {
	Body struct {
		KID          uint            `json:"file_id" example:"1" doc:"karaoke ID"`
		CheckResults CheckKaraOutput `json:"check_results"`
	}
}

func UploadKaraFile

func UploadKaraFile(ctx context.Context, input *UploadInput) (*UploadOutput, error)

type UploadTempFile

type UploadTempFile struct {
	Fd   *os.File
	Size int64
	// original file name
	Name string
}

type User

type User struct {
	ID              string `gorm:"primarykey"`
	CreatedAt       time.Time
	UpdatedAt       time.Time
	DeletedAt       gorm.DeletedAt `gorm:"index"`
	Admin           bool
	TimingProfileID *uint
	TimingProfile   *TimingAuthor `gorm:"foreignKey:TimingProfileID;references:ID"`
}

Users

type VideoTag

type VideoTag TagType

type VideoTagDB

type VideoTagDB struct {
	ID string
}

type VideoTagsOutput

type VideoTagsOutput struct {
	Body []VideoTag `json:"video_tags"`
}

func GetVideoTags

func GetVideoTags(ctx context.Context, input *struct{}) (*VideoTagsOutput, error)

Directories

Path Synopsis
clients
mugen
SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7
SPDX-License-Identifier: AGPL-3.0-or-later Copyright (C) 2024 Japan7

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL