2021-03-14 12:49:24 +00:00
|
|
|
package settings
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"openmediacenter/apiGo/database"
|
|
|
|
)
|
|
|
|
|
|
|
|
func GetPassword() *string {
|
|
|
|
pwd := LoadSettings().Pasword
|
|
|
|
if pwd == "-1" {
|
|
|
|
return nil
|
|
|
|
} else {
|
|
|
|
return &pwd
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type SettingsType struct {
|
2021-04-16 20:44:56 +00:00
|
|
|
DarkMode bool
|
|
|
|
Pasword string
|
|
|
|
MediacenterName string
|
|
|
|
VideoPath string
|
|
|
|
TVShowPath string
|
2021-03-14 12:49:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func LoadSettings() *SettingsType {
|
2021-04-16 20:44:56 +00:00
|
|
|
query := "SELECT DarkMode, password, mediacenter_name, video_path, episode_path from settings"
|
2021-03-14 12:49:24 +00:00
|
|
|
|
2021-04-16 20:44:56 +00:00
|
|
|
result := SettingsType{}
|
|
|
|
var darkmode uint8
|
2021-03-14 12:49:24 +00:00
|
|
|
|
2021-04-16 20:44:56 +00:00
|
|
|
err := database.QueryRow(query).Scan(&darkmode, &result.Pasword, &result.MediacenterName, &result.VideoPath, &result.TVShowPath)
|
2021-03-14 12:49:24 +00:00
|
|
|
if err != nil {
|
|
|
|
fmt.Println("error while parsing db data: " + err.Error())
|
|
|
|
}
|
|
|
|
|
2021-04-16 20:44:56 +00:00
|
|
|
result.DarkMode = darkmode != 0
|
|
|
|
return &result
|
2021-03-14 12:49:24 +00:00
|
|
|
}
|