2021-02-23 16:01:29 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
2021-04-02 17:04:15 +00:00
|
|
|
"log"
|
|
|
|
"net/http"
|
2021-02-23 16:01:29 +00:00
|
|
|
"openmediacenter/apiGo/api"
|
|
|
|
"openmediacenter/apiGo/database"
|
2021-06-08 19:55:54 +00:00
|
|
|
settings2 "openmediacenter/apiGo/database/settings"
|
2021-04-02 17:04:15 +00:00
|
|
|
"openmediacenter/apiGo/static"
|
2021-04-18 19:16:38 +00:00
|
|
|
"openmediacenter/apiGo/videoparser"
|
2021-02-23 16:01:29 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
fmt.Println("init OpenMediaCenter server")
|
2021-04-02 17:04:15 +00:00
|
|
|
port := 8081
|
2021-02-23 16:01:29 +00:00
|
|
|
|
|
|
|
db, verbose, pathPrefix := handleCommandLineArguments()
|
|
|
|
// todo some verbosity logger or sth
|
|
|
|
|
|
|
|
fmt.Printf("Use verbose output: %t\n", verbose)
|
|
|
|
fmt.Printf("Videopath prefix: %s\n", *pathPrefix)
|
|
|
|
|
|
|
|
// set pathprefix in database settings object
|
|
|
|
database.SettingsVideoPrefix = *pathPrefix
|
|
|
|
|
|
|
|
database.InitDB(db)
|
|
|
|
defer database.Close()
|
|
|
|
|
2021-04-18 19:16:38 +00:00
|
|
|
videoparser.SetupSettingsWebsocket()
|
|
|
|
|
2021-04-02 17:04:15 +00:00
|
|
|
// add the static files
|
|
|
|
static.ServeStaticFiles()
|
|
|
|
|
2021-08-20 19:20:33 +00:00
|
|
|
api.Init()
|
2021-04-02 17:04:15 +00:00
|
|
|
|
|
|
|
fmt.Printf("OpenMediacenter server up and running on port %d\n", port)
|
|
|
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", port), nil))
|
2021-02-23 16:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func handleCommandLineArguments() (*database.DatabaseConfig, bool, *string) {
|
|
|
|
dbhostPtr := flag.String("DBHost", "127.0.0.1", "database host name")
|
|
|
|
dbPortPtr := flag.Int("DBPort", 3306, "database port")
|
|
|
|
dbUserPtr := flag.String("DBUser", "mediacenteruser", "database username")
|
|
|
|
dbPassPtr := flag.String("DBPassword", "mediapassword", "database username")
|
|
|
|
dbNamePtr := flag.String("DBName", "mediacenter", "database name")
|
|
|
|
|
|
|
|
verbosePtr := flag.Bool("v", true, "Verbose log output")
|
|
|
|
|
|
|
|
pathPrefix := flag.String("ReindexPrefix", "/var/www/openmediacenter", "Prefix path for videos to reindex")
|
|
|
|
|
2021-06-08 19:55:54 +00:00
|
|
|
disableTVShowSupport := flag.Bool("DisableTVSupport", false, "Disable the TVShow support and pages")
|
|
|
|
|
2021-02-23 16:01:29 +00:00
|
|
|
flag.Parse()
|
|
|
|
|
2021-06-08 19:55:54 +00:00
|
|
|
settings2.SetTVShowEnabled(!*disableTVShowSupport)
|
|
|
|
|
2021-02-23 16:01:29 +00:00
|
|
|
return &database.DatabaseConfig{
|
|
|
|
DBHost: *dbhostPtr,
|
|
|
|
DBPort: *dbPortPtr,
|
|
|
|
DBUser: *dbUserPtr,
|
|
|
|
DBPassword: *dbPassPtr,
|
|
|
|
DBName: *dbNamePtr,
|
|
|
|
}, *verbosePtr, pathPrefix
|
|
|
|
}
|