From c9450de603282c68d2614350138b0da1c7a5e818 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Tue, 27 Aug 2024 23:46:37 +0200 Subject: [PATCH 01/33] init --- .gitignore | 2 + cmd/action/initcmd/process.go | 42 +++++++++++++++++++++ cmd/action/watchcmd/process.go | 44 ++++++++++++++++++++++ cmd/client/main.go | 64 +++++++++++++++++++++++++++++++ cmd/server/main.go | 47 +++++++++++++++++++++++ config/client/config.go | 40 ++++++++++++++++++++ file/reader.go | 13 +++++++ go.mod | 17 +++++++++ go.sum | 25 ++++++++++++ model/playlist.go | 11 ++++++ model/profile.go | 8 ++++ model/subscription.go | 7 ++++ model/video.go | 19 ++++++++++ store/file/history.go | 23 ++++++++++++ store/file/playlist.go | 27 +++++++++++++ store/file/subscription.go | 27 +++++++++++++ web/client/client.go | 69 ++++++++++++++++++++++++++++++++++ web/route/route.go | 15 ++++++++ 18 files changed, 500 insertions(+) create mode 100644 .gitignore create mode 100644 cmd/action/initcmd/process.go create mode 100644 cmd/action/watchcmd/process.go create mode 100644 cmd/client/main.go create mode 100644 cmd/server/main.go create mode 100644 config/client/config.go create mode 100644 file/reader.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 model/playlist.go create mode 100644 model/profile.go create mode 100644 model/subscription.go create mode 100644 model/video.go create mode 100644 store/file/history.go create mode 100644 store/file/playlist.go create mode 100644 store/file/subscription.go create mode 100644 web/client/client.go create mode 100644 web/route/route.go diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3d33a15 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +/client +/server diff --git a/cmd/action/initcmd/process.go b/cmd/action/initcmd/process.go new file mode 100644 index 0000000..0422526 --- /dev/null +++ b/cmd/action/initcmd/process.go @@ -0,0 +1,42 @@ +package initcmd + +import ( + "log" + "os" + + filestore "gitnet.fr/deblan/freetube-sync/store/file" + "gitnet.fr/deblan/freetube-sync/web/client" + "gitnet.fr/deblan/freetube-sync/web/route" +) + +func Process(name, route string, data any) bool { + log.Print("Init of " + name) + response, err := client.Init(route, data) + res := true + + if err != nil { + log.Print("Error while initializing " + name + ": " + err.Error()) + res = false + } else { + if response.Code == 201 { + log.Print(name + " initialized!") + } else { + log.Print("Error while initializing " + name + ": " + response.Message) + res = false + } + } + + return res +} + +func Run() { + a := Process("history", route.HistoryInit, filestore.LoadHistory()) + b := Process("playlists", route.PlaylistInit, filestore.LoadPlaylists()) + c := Process("profiles", route.ProfileInit, filestore.LoadProfiles()) + + if a && b && c { + os.Exit(0) + } + + os.Exit(1) +} diff --git a/cmd/action/watchcmd/process.go b/cmd/action/watchcmd/process.go new file mode 100644 index 0000000..a71e6a1 --- /dev/null +++ b/cmd/action/watchcmd/process.go @@ -0,0 +1,44 @@ +package watchcmd + +import ( + "fmt" + "log" + + "github.com/fsnotify/fsnotify" + config "gitnet.fr/deblan/freetube-sync/config/client" +) + +func Run() { + watcher, err := fsnotify.NewWatcher() + + if err != nil { + log.Print("Error while creating the watcher: " + err.Error()) + } + + defer watcher.Close() + + go func() { + for { + select { + case event, ok := <-watcher.Events: + if !ok { + return + } + if event.Has(fsnotify.Write) { + switch event.Name { + case config.GetConfig().Path + "/history.db": + fmt.Printf("%+v\n", "update history") + case config.GetConfig().Path + "/playlists.db": + fmt.Printf("%+v\n", "update playlists") + case config.GetConfig().Path + "/profiles.db": + fmt.Printf("%+v\n", "update profiles") + } + } + } + } + }() + + watcher.Add(config.GetConfig().Path) + + <-make(chan struct{}) +} diff --git a/cmd/client/main.go b/cmd/client/main.go new file mode 100644 index 0000000..b4e51da --- /dev/null +++ b/cmd/client/main.go @@ -0,0 +1,64 @@ +package main + +import ( + "flag" + "fmt" + "os" + + "gitnet.fr/deblan/freetube-sync/cmd/action/initcmd" + "gitnet.fr/deblan/freetube-sync/cmd/action/watchcmd" + config "gitnet.fr/deblan/freetube-sync/config/client" +) + +func main() { + config.InitConfig() + action := flag.Arg(0) + + switch action { + case "init": + initcmd.Run() + case "watch": + watchcmd.Run() + default: + fmt.Print("You must pass a sub-command: init, watch") + os.Exit(1) + } + + // lines := file.GetLines("/home/simon/.config/FreeTube/history.db") + // collection := []model.Video{} + // + // for _, line := range lines { + // var item model.Video + // json.Unmarshal([]byte(line), &item) + // + // collection = append(collection, item) + // } + // + // data, err := json.Marshal(collection) + // + // if err != nil { + // panic(err) + // } + // + // req, err := http.NewRequest("POST", "http://localhost:1323/history/push", bytes.NewBuffer(data)) + // req.Header.Set("X-Machine", "endurance") + // req.Header.Set("Content-Type", "application/json") + // + // if err != nil { + // panic(err) + // } + // + // client := &http.Client{} + // resp, err := client.Do(req) + // if err != nil { + // panic(err) + // } + // defer resp.Body.Close() + // fmt.Println("response Status:", resp.Status) + // fmt.Println("response Headers:", resp.Header) + // body, _ := io.ReadAll(resp.Body) + // fmt.Println("response Body:", string(body)) + // + // fmt.Printf("%+v\n", data) + // fmt.Printf("%+v\n", collection) +} diff --git a/cmd/server/main.go b/cmd/server/main.go new file mode 100644 index 0000000..f29d0a9 --- /dev/null +++ b/cmd/server/main.go @@ -0,0 +1,47 @@ +package main + +import ( + "github.com/labstack/echo/v4" + "gitnet.fr/deblan/freetube-sync/model" + "gitnet.fr/deblan/freetube-sync/web/route" +) + +func main() { + e := echo.New() + + e.POST(route.HistoryInit, func(c echo.Context) error { + payload := []model.Video{} + err := c.Bind(&payload) + + if err != nil { + return c.JSON(400, map[string]any{ + "code": 400, + "message": err, + }) + } + + return c.JSON(201, map[string]any{ + "code": 201, + "message": "ok", + }) + }) + + e.POST(route.HistoryPush, func(c echo.Context) error { + payload := []model.Video{} + err := c.Bind(&payload) + + if err != nil { + return c.JSON(400, map[string]any{ + "code": 400, + "message": err, + }) + } + + return c.JSON(201, map[string]any{ + "code": 201, + "message": "ok", + }) + }) + + e.Logger.Fatal(e.Start(":1323")) +} diff --git a/config/client/config.go b/config/client/config.go new file mode 100644 index 0000000..d03139d --- /dev/null +++ b/config/client/config.go @@ -0,0 +1,40 @@ +package client + +import ( + "flag" + "os" + "strings" +) + +type Config struct { + Server string + Path string + Hostname string +} + +var config *Config + +func GetConfig() *Config { + if config == nil { + config = &Config{} + } + + return config +} + +func (c *Config) Define(server, hostname, path string) { + c.Server = strings.TrimRight(server, "/") + c.Hostname = hostname + c.Path = path +} + +func InitConfig() { + defaultHostname, _ := os.Hostname() + + path := flag.String("p", os.Getenv("HOME")+"/.config/FreeTube", "Path to FreeTube config directory") + hostname := flag.String("h", defaultHostname, "Hostname") + server := flag.String("s", "", "Server to sync") + flag.Parse() + + GetConfig().Define(*server, *hostname, *path) +} diff --git a/file/reader.go b/file/reader.go new file mode 100644 index 0000000..49e40b7 --- /dev/null +++ b/file/reader.go @@ -0,0 +1,13 @@ +package file + +import ( + "io/ioutil" + "strings" +) + +func GetLines(file string) []string { + bytesRead, _ := ioutil.ReadFile(file) + fileContent := string(bytesRead) + + return strings.Split(fileContent, "\n") +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..5e253e2 --- /dev/null +++ b/go.mod @@ -0,0 +1,17 @@ +module gitnet.fr/deblan/freetube-sync + +go 1.23.0 + +require ( + github.com/fsnotify/fsnotify v1.7.0 // indirect + github.com/labstack/echo/v4 v4.12.0 // indirect + github.com/labstack/gommon v0.4.2 // indirect + github.com/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/valyala/bytebufferpool v1.0.0 // indirect + github.com/valyala/fasttemplate v1.2.2 // indirect + golang.org/x/crypto v0.22.0 // indirect + golang.org/x/net v0.24.0 // indirect + golang.org/x/sys v0.19.0 // indirect + golang.org/x/text v0.14.0 // indirect +) diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e81948d --- /dev/null +++ b/go.sum @@ -0,0 +1,25 @@ +github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= +github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= +github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= +github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= +github.com/labstack/gommon v0.4.2/go.mod h1:QlUFxVM+SNXhDL/Z7YhocGIBYOiwB0mXm1+1bAPHPyU= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= +github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= +github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= +github.com/valyala/fasttemplate v1.2.2/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= +golang.org/x/crypto v0.22.0 h1:g1v0xeRhjcugydODzvb3mEM9SQ0HGp9s/nh3COQ/C30= +golang.org/x/crypto v0.22.0/go.mod h1:vr6Su+7cTlO45qkww3VDJlzDn0ctJvRgYbC2NvXHt+M= +golang.org/x/net v0.24.0 h1:1PcaxkF854Fu3+lvBIx5SYn9wRlBzzcnHZSiaFFAb0w= +golang.org/x/net v0.24.0/go.mod h1:2Q7sJY5mzlzWjKtYUEXSlBWCdyaioyXzRB2RtU8KVE8= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= +golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= diff --git a/model/playlist.go b/model/playlist.go new file mode 100644 index 0000000..e082a4c --- /dev/null +++ b/model/playlist.go @@ -0,0 +1,11 @@ +package model + +type Playlist struct { + PlaylistName string `json:"playlistName"` + Protected bool `json:"protected"` + Description string `json:"description"` + Videos []Video `json:"videos"` + Id string `json:"_id"` + CreatedAt uint64 `json:"createdAt"` + LastUpdatedAt uint64 `json:"lastUpdatedAt"` +} diff --git a/model/profile.go b/model/profile.go new file mode 100644 index 0000000..95654ce --- /dev/null +++ b/model/profile.go @@ -0,0 +1,8 @@ +package model + +type Profile struct { + Name string `json:"name"` + BgColor string `json:"bgColor"` + TextColor string `json:"textColor"` + Subscriptions []Subscription `json:"subscriptions"` +} diff --git a/model/subscription.go b/model/subscription.go new file mode 100644 index 0000000..ae63db2 --- /dev/null +++ b/model/subscription.go @@ -0,0 +1,7 @@ +package model + +type Subscription struct { + Id string `json:"id"` + Name string `json:"name"` + Thumbnail string `json:"thumbnail"` +} diff --git a/model/video.go b/model/video.go new file mode 100644 index 0000000..c8187b8 --- /dev/null +++ b/model/video.go @@ -0,0 +1,19 @@ +package model + +type Video struct { + VideoId string `json:"videoId"` + Title string `json:"title"` + Author string `json:"author"` + AuthorId string `json:"authorId"` + Published uint64 `json:"published"` + Description string `json:"description"` + ViewCount uint64 `json:"viewCount"` + LengthSeconds uint64 `json:"lengthSeconds"` + WatchProgress uint64 `json:"watchProgress"` + TimeWatched uint64 `json:"timeWatched"` + LsLive bool `json:"isLive"` + Type string `json:"type"` + Id string `json:"_id"` + LastViewedPlaylistType string `json:"lastViewedPlaylistType"` + LastViewedPlaylistItemId string `json:"lastViewedPlaylistItemId"` +} diff --git a/store/file/history.go b/store/file/history.go new file mode 100644 index 0000000..c757055 --- /dev/null +++ b/store/file/history.go @@ -0,0 +1,23 @@ +package file + +import ( + "encoding/json" + + config "gitnet.fr/deblan/freetube-sync/config/client" + "gitnet.fr/deblan/freetube-sync/file" + "gitnet.fr/deblan/freetube-sync/model" +) + +func LoadHistory() []model.Video { + lines := file.GetLines(config.GetConfig().Path + "/history.db") + collection := []model.Video{} + + for _, line := range lines { + var item model.Video + json.Unmarshal([]byte(line), &item) + + collection = append(collection, item) + } + + return collection +} diff --git a/store/file/playlist.go b/store/file/playlist.go new file mode 100644 index 0000000..357d49f --- /dev/null +++ b/store/file/playlist.go @@ -0,0 +1,27 @@ +package file + +import ( + "encoding/json" + + config "gitnet.fr/deblan/freetube-sync/config/client" + "gitnet.fr/deblan/freetube-sync/file" + "gitnet.fr/deblan/freetube-sync/model" +) + +func LoadPlaylists() []model.Playlist { + lines := file.GetLines(config.GetConfig().Path + "/playlists.db") + collection := []model.Playlist{} + added := make(map[string]bool) + + for i := len(lines) - 1; i >= 0; i-- { + var item model.Playlist + json.Unmarshal([]byte(lines[i]), &item) + + if !added[item.Id] { + added[item.Id] = true + collection = append(collection, item) + } + } + + return collection +} diff --git a/store/file/subscription.go b/store/file/subscription.go new file mode 100644 index 0000000..80754ca --- /dev/null +++ b/store/file/subscription.go @@ -0,0 +1,27 @@ +package file + +import ( + "encoding/json" + + config "gitnet.fr/deblan/freetube-sync/config/client" + "gitnet.fr/deblan/freetube-sync/file" + "gitnet.fr/deblan/freetube-sync/model" +) + +func LoadProfiles() []model.Profile { + lines := file.GetLines(config.GetConfig().Path + "/profiles.db") + collection := []model.Profile{} + added := make(map[string]bool) + + for i := len(lines) - 1; i >= 0; i-- { + var item model.Profile + json.Unmarshal([]byte(lines[i]), &item) + + if !added[item.Name] { + added[item.Name] = true + collection = append(collection, item) + } + } + + return collection +} diff --git a/web/client/client.go b/web/client/client.go new file mode 100644 index 0000000..1cd4432 --- /dev/null +++ b/web/client/client.go @@ -0,0 +1,69 @@ +package client + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "net/http" + + config "gitnet.fr/deblan/freetube-sync/config/client" +) + +type Data any + +type PostResponse struct { + Code int `json:"code"` + Message string `json:"message"` +} + +func Request(method, route string, data Data) ([]byte, error) { + value, err := json.Marshal(data) + + if err != nil { + return nil, err + } + + url := fmt.Sprintf("%s%s", config.GetConfig().Server, route) + request, _ := http.NewRequest(method, url, bytes.NewBuffer(value)) + request.Header.Set("X-Machine", config.GetConfig().Hostname) + request.Header.Set("Content-Type", "application/json") + + if err != nil { + return nil, err + } + + client := &http.Client{} + response, err := client.Do(request) + + if err != nil { + return nil, err + } + + defer response.Body.Close() + + body, err := io.ReadAll(response.Body) + + if err != nil { + return nil, err + } + + return body, nil +} + +func Post(route string, data Data) ([]byte, error) { + return Request("POST", route, data) +} + +func Get(route string, data Data) ([]byte, error) { + return Request("POST", route, data) +} + +func Init(route string, data Data) (PostResponse, error) { + var value PostResponse + + body, err := Post(route, data) + json.Unmarshal(body, &value) + + return value, err +} diff --git a/web/route/route.go b/web/route/route.go new file mode 100644 index 0000000..2947a63 --- /dev/null +++ b/web/route/route.go @@ -0,0 +1,15 @@ +package route + +const ( + HistoryInit = "/history/init" + HistoryPush = "/history/push" + HistoryPull = "/history/pull" + + ProfileInit = "/profile/init" + ProfilePush = "/profile/push" + ProfilePull = "/profile/pull" + + PlaylistInit = "/playlist/init" + PlaylistPush = "/playlist/push" + PlaylistPull = "/playlist/pull" +) From 3af050caa0cf655546fe0f6a3020ca640954556c Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Wed, 28 Aug 2024 20:36:03 +0200 Subject: [PATCH 02/33] add gorm add history init/pull/push --- cmd/action/initcmd/process.go | 2 +- cmd/action/pullcmd/process.go | 45 +++++++++++++++++++++ cmd/action/watchcmd/process.go | 37 +++++++++++++---- cmd/client/main.go | 44 ++------------------ cmd/server/main.go | 52 ++++++++---------------- config/client/config.go | 4 ++ config/server/config.go | 34 ++++++++++++++++ file/writer.go | 12 ++++++ go.mod | 16 ++++++-- go.sum | 26 +++++++++++- model/playlist.go | 19 +++++---- model/profile.go | 7 +++- model/pull.go | 13 ++++++ model/subscription.go | 12 ++++-- model/video.go | 54 +++++++++++++++++-------- store/database/database.go | 40 ++++++++++++++++++ store/file/history.go | 12 ++++-- store/file/playlist.go | 2 +- store/file/subscription.go | 2 +- web/client/client.go | 17 ++++++-- web/controller/helper.go | 17 ++++++++ web/controller/history/controller.go | 51 +++++++++++++++++++++++ web/controller/playlist/controller.go | 58 +++++++++++++++++++++++++++ web/controller/profile/controller.go | 58 +++++++++++++++++++++++++++ web/helper/helper.go | 17 ++++++++ 25 files changed, 526 insertions(+), 125 deletions(-) create mode 100644 cmd/action/pullcmd/process.go create mode 100644 config/server/config.go create mode 100644 file/writer.go create mode 100644 model/pull.go create mode 100644 store/database/database.go create mode 100644 web/controller/helper.go create mode 100644 web/controller/history/controller.go create mode 100644 web/controller/playlist/controller.go create mode 100644 web/controller/profile/controller.go create mode 100644 web/helper/helper.go diff --git a/cmd/action/initcmd/process.go b/cmd/action/initcmd/process.go index 0422526..4cf13da 100644 --- a/cmd/action/initcmd/process.go +++ b/cmd/action/initcmd/process.go @@ -11,7 +11,7 @@ import ( func Process(name, route string, data any) bool { log.Print("Init of " + name) - response, err := client.Init(route, data) + response, err := client.InitPush(route, data) res := true if err != nil { diff --git a/cmd/action/pullcmd/process.go b/cmd/action/pullcmd/process.go new file mode 100644 index 0000000..fff3745 --- /dev/null +++ b/cmd/action/pullcmd/process.go @@ -0,0 +1,45 @@ +package pullcmd + +import ( + "encoding/json" + "log" + "os" + + "gitnet.fr/deblan/freetube-sync/store/file" + "gitnet.fr/deblan/freetube-sync/web/client" +) + +func ProcessHistory() bool { + log.Print("Pull of history") + items, err := client.PullHistory() + res := true + + if err != nil { + log.Print("Error while pulling history: " + err.Error()) + res = false + } else { + lines := []string{} + + for _, item := range items { + line, _ := json.Marshal(item) + lines = append(lines, string(line)) + } + + file.UpdateHistory(lines) + } + + return res +} + +func Run() { + a := ProcessHistory() + // b := Process("playlists", route.PlaylistPull) + // c := Process("profiles", route.ProfilePull) + + // if a && b && c { + if a { + os.Exit(0) + } + + os.Exit(1) +} diff --git a/cmd/action/watchcmd/process.go b/cmd/action/watchcmd/process.go index a71e6a1..3cb078e 100644 --- a/cmd/action/watchcmd/process.go +++ b/cmd/action/watchcmd/process.go @@ -1,13 +1,35 @@ package watchcmd import ( - "fmt" "log" "github.com/fsnotify/fsnotify" config "gitnet.fr/deblan/freetube-sync/config/client" + filestore "gitnet.fr/deblan/freetube-sync/store/file" + "gitnet.fr/deblan/freetube-sync/web/client" + "gitnet.fr/deblan/freetube-sync/web/route" ) +func Process(name, route string, data any) bool { + log.Print("Push of " + name) + response, err := client.InitPush(route, data) + res := true + + if err != nil { + log.Print("Error while pushing " + name + ": " + err.Error()) + res = false + } else { + if response.Code == 201 { + log.Print(name + " pushed!") + } else { + log.Print("Error while pushing " + name + ": " + response.Message) + res = false + } + } + + return res +} + func Run() { watcher, err := fsnotify.NewWatcher() @@ -16,6 +38,7 @@ func Run() { } defer watcher.Close() + c := config.GetConfig() go func() { for { @@ -26,12 +49,12 @@ func Run() { } if event.Has(fsnotify.Write) { switch event.Name { - case config.GetConfig().Path + "/history.db": - fmt.Printf("%+v\n", "update history") - case config.GetConfig().Path + "/playlists.db": - fmt.Printf("%+v\n", "update playlists") - case config.GetConfig().Path + "/profiles.db": - fmt.Printf("%+v\n", "update profiles") + case c.DbPath("history"): + Process("history", route.HistoryPush, filestore.LoadHistory()) + case c.DbPath("playlists"): + Process("playlists", route.PlaylistPush, filestore.LoadPlaylists()) + case c.DbPath("profiles"): + Process("profiles", route.ProfilePush, filestore.LoadProfiles()) } } } diff --git a/cmd/client/main.go b/cmd/client/main.go index b4e51da..f142598 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -6,59 +6,23 @@ import ( "os" "gitnet.fr/deblan/freetube-sync/cmd/action/initcmd" + "gitnet.fr/deblan/freetube-sync/cmd/action/pullcmd" "gitnet.fr/deblan/freetube-sync/cmd/action/watchcmd" config "gitnet.fr/deblan/freetube-sync/config/client" ) func main() { config.InitConfig() - action := flag.Arg(0) - switch action { + switch flag.Arg(0) { case "init": initcmd.Run() case "watch": watchcmd.Run() + case "pull": + pullcmd.Run() default: fmt.Print("You must pass a sub-command: init, watch") os.Exit(1) } - - // lines := file.GetLines("/home/simon/.config/FreeTube/history.db") - // collection := []model.Video{} - // - // for _, line := range lines { - // var item model.Video - // json.Unmarshal([]byte(line), &item) - // - // collection = append(collection, item) - // } - // - // data, err := json.Marshal(collection) - // - // if err != nil { - // panic(err) - // } - // - // req, err := http.NewRequest("POST", "http://localhost:1323/history/push", bytes.NewBuffer(data)) - // req.Header.Set("X-Machine", "endurance") - // req.Header.Set("Content-Type", "application/json") - // - // if err != nil { - // panic(err) - // } - // - // client := &http.Client{} - // resp, err := client.Do(req) - // if err != nil { - // panic(err) - // } - // defer resp.Body.Close() - // fmt.Println("response Status:", resp.Status) - // fmt.Println("response Headers:", resp.Header) - // body, _ := io.ReadAll(resp.Body) - // fmt.Println("response Body:", string(body)) - // - // fmt.Printf("%+v\n", data) - // fmt.Printf("%+v\n", collection) } diff --git a/cmd/server/main.go b/cmd/server/main.go index f29d0a9..6d0ce4e 100644 --- a/cmd/server/main.go +++ b/cmd/server/main.go @@ -2,46 +2,26 @@ package main import ( "github.com/labstack/echo/v4" - "gitnet.fr/deblan/freetube-sync/model" - "gitnet.fr/deblan/freetube-sync/web/route" + "github.com/labstack/echo/v4/middleware" + config "gitnet.fr/deblan/freetube-sync/config/server" + "gitnet.fr/deblan/freetube-sync/store/database" + "gitnet.fr/deblan/freetube-sync/web/controller/history" + "gitnet.fr/deblan/freetube-sync/web/controller/playlist" + "gitnet.fr/deblan/freetube-sync/web/controller/profile" ) func main() { + config.InitConfig() + + database.GetManager().AutoMigrate() + e := echo.New() + e.HideBanner = true + e.Use(middleware.Logger()) - e.POST(route.HistoryInit, func(c echo.Context) error { - payload := []model.Video{} - err := c.Bind(&payload) + history.Register(e) + playlist.Register(e) + profile.Register(e) - if err != nil { - return c.JSON(400, map[string]any{ - "code": 400, - "message": err, - }) - } - - return c.JSON(201, map[string]any{ - "code": 201, - "message": "ok", - }) - }) - - e.POST(route.HistoryPush, func(c echo.Context) error { - payload := []model.Video{} - err := c.Bind(&payload) - - if err != nil { - return c.JSON(400, map[string]any{ - "code": 400, - "message": err, - }) - } - - return c.JSON(201, map[string]any{ - "code": 201, - "message": "ok", - }) - }) - - e.Logger.Fatal(e.Start(":1323")) + e.Logger.Fatal(e.Start(config.GetConfig().BindAddress)) } diff --git a/config/client/config.go b/config/client/config.go index d03139d..06e843d 100644 --- a/config/client/config.go +++ b/config/client/config.go @@ -28,6 +28,10 @@ func (c *Config) Define(server, hostname, path string) { c.Path = path } +func (c *Config) DbPath(name string) string { + return c.Path + "/" + name + ".db" +} + func InitConfig() { defaultHostname, _ := os.Hostname() diff --git a/config/server/config.go b/config/server/config.go new file mode 100644 index 0000000..da31977 --- /dev/null +++ b/config/server/config.go @@ -0,0 +1,34 @@ +package server + +import ( + "flag" + "os" +) + +type Config struct { + BindAddress string + DbPath string +} + +var config *Config + +func GetConfig() *Config { + if config == nil { + config = &Config{} + } + + return config +} + +func (c *Config) Define(bindAddress, dbPath string) { + c.BindAddress = bindAddress + c.DbPath = dbPath +} + +func InitConfig() { + dbPath := flag.String("d", os.Getenv("HOME")+"/.config/FreeTube/sync.sqlite", "Path to SQlite database") + bindAddress := flag.String("b", ":1323", "Bind address") + flag.Parse() + + GetConfig().Define(*bindAddress, *dbPath) +} diff --git a/file/writer.go b/file/writer.go new file mode 100644 index 0000000..0c16990 --- /dev/null +++ b/file/writer.go @@ -0,0 +1,12 @@ +package file + +import ( + "os" + "strings" +) + +func WriteDatabase(file string, data []string) error { + content := []byte(strings.Join(data, "\n") + "\n") + + return os.WriteFile(file, content, 0644) +} diff --git a/go.mod b/go.mod index 5e253e2..95d60c5 100644 --- a/go.mod +++ b/go.mod @@ -3,15 +3,25 @@ module gitnet.fr/deblan/freetube-sync go 1.23.0 require ( - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/labstack/echo/v4 v4.12.0 // indirect + github.com/fsnotify/fsnotify v1.7.0 + github.com/labstack/echo/v4 v4.12.0 + gorm.io/driver/sqlite v1.5.6 + gorm.io/gorm v1.25.11 +) + +require ( + github.com/golang-jwt/jwt v3.2.2+incompatible // indirect + github.com/jinzhu/inflection v1.0.0 // indirect + github.com/jinzhu/now v1.1.5 // indirect github.com/labstack/gommon v0.4.2 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-sqlite3 v1.14.22 // indirect github.com/valyala/bytebufferpool v1.0.0 // indirect github.com/valyala/fasttemplate v1.2.2 // indirect golang.org/x/crypto v0.22.0 // indirect golang.org/x/net v0.24.0 // indirect golang.org/x/sys v0.19.0 // indirect - golang.org/x/text v0.14.0 // indirect + golang.org/x/text v0.17.0 // indirect + golang.org/x/time v0.5.0 // indirect ) diff --git a/go.sum b/go.sum index e81948d..dc34bca 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,13 @@ +github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= +github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY= +github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I= +github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E= +github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc= +github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ= +github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8= github.com/labstack/echo/v4 v4.12.0 h1:IKpw49IMryVB2p1a4dzwlhP1O2Tf2E0Ir/450lH+kI0= github.com/labstack/echo/v4 v4.12.0/go.mod h1:UP9Cr2DJXbOK3Kr9ONYzNowSh7HP0aG0ShAyycHSJvM= github.com/labstack/gommon v0.4.2 h1:F8qTUNXgG1+6WQmqoUWnz8WiEU60mXVVw0P4ht1WRA0= @@ -9,6 +17,12 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU= +github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw= github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc= github.com/valyala/fasttemplate v1.2.2 h1:lxLXG0uE3Qnshl9QyaK6XJxMXlQZELvChBOCmQD0Loo= @@ -21,5 +35,13 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o= golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= +golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= +golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/time v0.5.0 h1:o7cqy6amK/52YcAKIPlM3a+Fpj35zvRj2TP+e1xFSfk= +golang.org/x/time v0.5.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= +gorm.io/driver/sqlite v1.5.6 h1:fO/X46qn5NUEEOZtnjJRWRzZMe8nqJiQ9E+0hi+hKQE= +gorm.io/driver/sqlite v1.5.6/go.mod h1:U+J8craQU6Fzkcvu8oLeAQmi50TkwPEhHDEjQZXDah4= +gorm.io/gorm v1.25.11 h1:/Wfyg1B/je1hnDx3sMkX+gAlxrlZpn6X0BXRlwXlvHg= +gorm.io/gorm v1.25.11/go.mod h1:xh7N7RHfYlNc5EmcI/El95gXusucDrQnHXe0+CgWcLQ= diff --git a/model/playlist.go b/model/playlist.go index e082a4c..c3926b6 100644 --- a/model/playlist.go +++ b/model/playlist.go @@ -1,11 +1,16 @@ package model +import "time" + type Playlist struct { - PlaylistName string `json:"playlistName"` - Protected bool `json:"protected"` - Description string `json:"description"` - Videos []Video `json:"videos"` - Id string `json:"_id"` - CreatedAt uint64 `json:"createdAt"` - LastUpdatedAt uint64 `json:"lastUpdatedAt"` + ID uint `json:"-";gorm:"primary_key"` + DeletedAt *time.Time `json:"-";sql:"index"` + + PlaylistName string `json:"playlistName"` + Protected bool `json:"protected"` + Description string `json:"description"` + Videos []PlaylistVideo `json:"videos"` + Id string `json:"_id"` + CreatedAt uint64 `json:"createdAt"` + LastUpdatedAt uint64 `json:"lastUpdatedAt"` } diff --git a/model/profile.go b/model/profile.go index 95654ce..601e7ac 100644 --- a/model/profile.go +++ b/model/profile.go @@ -1,8 +1,13 @@ package model +import "time" + type Profile struct { + ID uint `json:"-";gorm:"primary_key"` + DeletedAt *time.Time `json:"-";sql:"index"` + Name string `json:"name"` BgColor string `json:"bgColor"` TextColor string `json:"textColor"` - Subscriptions []Subscription `json:"subscriptions"` + Subscriptions []Subscription `json:"subscriptions" gorm:"many2many:profile_subscription"` } diff --git a/model/pull.go b/model/pull.go new file mode 100644 index 0000000..8991053 --- /dev/null +++ b/model/pull.go @@ -0,0 +1,13 @@ +package model + +import ( + "time" +) + +type Pull struct { + ID uint `json:"-";gorm:"primary_key"` + + Hostname string + Database string + PullAt time.Time +} diff --git a/model/subscription.go b/model/subscription.go index ae63db2..c2bc12d 100644 --- a/model/subscription.go +++ b/model/subscription.go @@ -1,7 +1,13 @@ package model +import "time" + type Subscription struct { - Id string `json:"id"` - Name string `json:"name"` - Thumbnail string `json:"thumbnail"` + ID uint `json:"-";gorm:"primary_key"` + DeletedAt *time.Time `json:"-";sql:"index"` + + Profiles []Profile `gorm:"many2many:profile_subscription"` + Id string `json:"id"` + Name string `json:"name"` + Thumbnail string `json:"thumbnail"` } diff --git a/model/video.go b/model/video.go index c8187b8..9fe3646 100644 --- a/model/video.go +++ b/model/video.go @@ -1,19 +1,41 @@ package model -type Video struct { - VideoId string `json:"videoId"` - Title string `json:"title"` - Author string `json:"author"` - AuthorId string `json:"authorId"` - Published uint64 `json:"published"` - Description string `json:"description"` - ViewCount uint64 `json:"viewCount"` - LengthSeconds uint64 `json:"lengthSeconds"` - WatchProgress uint64 `json:"watchProgress"` - TimeWatched uint64 `json:"timeWatched"` - LsLive bool `json:"isLive"` - Type string `json:"type"` - Id string `json:"_id"` - LastViewedPlaylistType string `json:"lastViewedPlaylistType"` - LastViewedPlaylistItemId string `json:"lastViewedPlaylistItemId"` +import ( + "time" +) + +type WatchedVideo struct { + ID uint `json:"-";gorm:"primary_key"` + DeletedAt *time.Time `json:"-";sql:"index"` + + VideoId string `json:"videoId"` + Title string `json:"title"` + Author string `json:"author"` + AuthorId string `json:"authorId"` + Published uint64 `json:"published"` + Description string `json:"description"` + ViewCount uint64 `json:"viewCount"` + LengthSeconds uint64 `json:"lengthSeconds"` + WatchProgress uint64 `json:"watchProgress"` + TimeWatched uint64 `json:"timeWatched"` + IsLive bool `json:"isLive"` + Type string `json:"type"` + Id string `json:"_id"` + LastViewedPlaylistType string `json:"lastViewedPlaylistType"` + LastViewedPlaylistItemId *string `json:"lastViewedPlaylistItemId"` +} + +type PlaylistVideo struct { + ID uint `gorm:"primary_key"` + DeletedAt *time.Time `json:"-";sql:"index"` + + PlaylistID uint + VideoId string `json:"videoId"` + Title string `json:"title"` + AuthorId string `json:"authorId"` + LengthSeconds uint64 `json:"lengthSeconds"` + TimeWatched uint64 `json:"timeWatched"` + TimeAdded uint64 `json:"timeAdded"` + PlaylistItemId string `json:"playlistItemId"` + Type string `json:"type"` } diff --git a/store/database/database.go b/store/database/database.go new file mode 100644 index 0000000..31d953c --- /dev/null +++ b/store/database/database.go @@ -0,0 +1,40 @@ +package database + +import ( + "log" + + config "gitnet.fr/deblan/freetube-sync/config/server" + "gitnet.fr/deblan/freetube-sync/model" + "gorm.io/driver/sqlite" + "gorm.io/gorm" +) + +type Manager struct { + Db *gorm.DB +} + +var manager *Manager + +func GetManager() *Manager { + if manager == nil { + manager = &Manager{} + db, err := gorm.Open(sqlite.Open(config.GetConfig().DbPath), &gorm.Config{}) + + if err != nil { + log.Fatal(err) + } + + manager.Db = db + } + + return manager +} + +func (m *Manager) AutoMigrate() { + m.Db.AutoMigrate(&model.Pull{}) + m.Db.AutoMigrate(&model.WatchedVideo{}) + m.Db.AutoMigrate(&model.PlaylistVideo{}) + m.Db.AutoMigrate(&model.Subscription{}) + m.Db.AutoMigrate(&model.Playlist{}) + m.Db.AutoMigrate(&model.Profile{}) +} diff --git a/store/file/history.go b/store/file/history.go index c757055..771fca3 100644 --- a/store/file/history.go +++ b/store/file/history.go @@ -8,12 +8,12 @@ import ( "gitnet.fr/deblan/freetube-sync/model" ) -func LoadHistory() []model.Video { - lines := file.GetLines(config.GetConfig().Path + "/history.db") - collection := []model.Video{} +func LoadHistory() []model.WatchedVideo { + lines := file.GetLines(config.GetConfig().DbPath("history")) + collection := []model.WatchedVideo{} for _, line := range lines { - var item model.Video + var item model.WatchedVideo json.Unmarshal([]byte(line), &item) collection = append(collection, item) @@ -21,3 +21,7 @@ func LoadHistory() []model.Video { return collection } + +func UpdateHistory(data []string) { + file.WriteDatabase(config.GetConfig().DbPath("history"), data) +} diff --git a/store/file/playlist.go b/store/file/playlist.go index 357d49f..3639d74 100644 --- a/store/file/playlist.go +++ b/store/file/playlist.go @@ -9,7 +9,7 @@ import ( ) func LoadPlaylists() []model.Playlist { - lines := file.GetLines(config.GetConfig().Path + "/playlists.db") + lines := file.GetLines(config.GetConfig().DbPath("playlists")) collection := []model.Playlist{} added := make(map[string]bool) diff --git a/store/file/subscription.go b/store/file/subscription.go index 80754ca..fb17c26 100644 --- a/store/file/subscription.go +++ b/store/file/subscription.go @@ -9,7 +9,7 @@ import ( ) func LoadProfiles() []model.Profile { - lines := file.GetLines(config.GetConfig().Path + "/profiles.db") + lines := file.GetLines(config.GetConfig().DbPath("profiles")) collection := []model.Profile{} added := make(map[string]bool) diff --git a/web/client/client.go b/web/client/client.go index 1cd4432..c4db9fd 100644 --- a/web/client/client.go +++ b/web/client/client.go @@ -8,6 +8,8 @@ import ( "net/http" config "gitnet.fr/deblan/freetube-sync/config/client" + "gitnet.fr/deblan/freetube-sync/model" + "gitnet.fr/deblan/freetube-sync/web/route" ) type Data any @@ -55,11 +57,11 @@ func Post(route string, data Data) ([]byte, error) { return Request("POST", route, data) } -func Get(route string, data Data) ([]byte, error) { - return Request("POST", route, data) +func Get(route string) ([]byte, error) { + return Request("GET", route, nil) } -func Init(route string, data Data) (PostResponse, error) { +func InitPush(route string, data Data) (PostResponse, error) { var value PostResponse body, err := Post(route, data) @@ -67,3 +69,12 @@ func Init(route string, data Data) (PostResponse, error) { return value, err } + +func PullHistory() ([]model.WatchedVideo, error) { + var items []model.WatchedVideo + + body, err := Get(route.HistoryPull) + json.Unmarshal(body, &items) + + return items, err +} diff --git a/web/controller/helper.go b/web/controller/helper.go new file mode 100644 index 0000000..1dbc662 --- /dev/null +++ b/web/controller/helper.go @@ -0,0 +1,17 @@ +package helper + +import "github.com/labstack/echo/v4" + +func Ko(c echo.Context, err error) error { + return c.JSON(400, map[string]any{ + "code": 400, + "message": err, + }) +} + +func Ok(c echo.Context) error { + return c.JSON(201, map[string]any{ + "code": 201, + "message": "ok", + }) +} diff --git a/web/controller/history/controller.go b/web/controller/history/controller.go new file mode 100644 index 0000000..6536d87 --- /dev/null +++ b/web/controller/history/controller.go @@ -0,0 +1,51 @@ +package history + +import ( + "time" + + "github.com/labstack/echo/v4" + "gitnet.fr/deblan/freetube-sync/model" + "gitnet.fr/deblan/freetube-sync/store/database" + "gitnet.fr/deblan/freetube-sync/web/helper" + "gitnet.fr/deblan/freetube-sync/web/route" +) + +func InitPush(c echo.Context) error { + payload := []model.WatchedVideo{} + err := c.Bind(&payload) + manager := database.GetManager() + + if err != nil { + return helper.Ko(c, err) + } + + for _, item := range payload { + manager.Db.Where(item).FirstOrCreate(&item) + } + + return helper.Ok(c) +} + +func Pull(c echo.Context) error { + entities := []model.WatchedVideo{} + manager := database.GetManager() + + manager.Db.Find(&entities) + + pull := model.Pull{ + Hostname: c.Request().Header.Get("X-Machine"), + Database: "history", + } + + manager.Db.Where(pull).FirstOrCreate(&pull) + pull.PullAt = time.Now() + manager.Db.Save(&pull) + + return c.JSON(200, entities) +} + +func Register(e *echo.Echo) { + e.POST(route.HistoryInit, InitPush) + e.POST(route.HistoryPush, InitPush) + e.GET(route.HistoryPull, Pull) +} diff --git a/web/controller/playlist/controller.go b/web/controller/playlist/controller.go new file mode 100644 index 0000000..b6c5e99 --- /dev/null +++ b/web/controller/playlist/controller.go @@ -0,0 +1,58 @@ +package playlist + +import ( + "github.com/labstack/echo/v4" + "gitnet.fr/deblan/freetube-sync/web/route" +) + +func Ko(c echo.Context, err error) error { + return c.JSON(400, map[string]any{ + "code": 400, + "message": err, + }) +} + +func Ok(c echo.Context) error { + return c.JSON(201, map[string]any{ + "code": 201, + "message": "ok", + }) +} + +func OkKo(c echo.Context, err error) error { + if err != nil { + return Ko(c, err) + } + + return Ok(c) +} + +func Init(c echo.Context) error { + // payload := []model.Video{} + // err := c.Bind(&payload) + var err error + + return OkKo(c, err) +} + +func Push(c echo.Context) error { + // payload := []model.Video{} + // err := c.Bind(&payload) + var err error + + return OkKo(c, err) +} + +func Pull(c echo.Context) error { + // payload := []model.Video{} + // err := c.Bind(&payload) + var err error + + return OkKo(c, err) +} + +func Register(e *echo.Echo) { + e.POST(route.PlaylistInit, Init) + e.POST(route.PlaylistPush, Push) + e.GET(route.PlaylistPull, Pull) +} diff --git a/web/controller/profile/controller.go b/web/controller/profile/controller.go new file mode 100644 index 0000000..416d764 --- /dev/null +++ b/web/controller/profile/controller.go @@ -0,0 +1,58 @@ +package profile + +import ( + "github.com/labstack/echo/v4" + "gitnet.fr/deblan/freetube-sync/web/route" +) + +func Ko(c echo.Context, err error) error { + return c.JSON(400, map[string]any{ + "code": 400, + "message": err, + }) +} + +func Ok(c echo.Context) error { + return c.JSON(201, map[string]any{ + "code": 201, + "message": "ok", + }) +} + +func OkKo(c echo.Context, err error) error { + if err != nil { + return Ko(c, err) + } + + return Ok(c) +} + +func Init(c echo.Context) error { + // payload := []model.Video{} + // err := c.Bind(&payload) + var err error + + return OkKo(c, err) +} + +func Push(c echo.Context) error { + // payload := []model.Video{} + // err := c.Bind(&payload) + var err error + + return OkKo(c, err) +} + +func Pull(c echo.Context) error { + // payload := []model.Video{} + // err := c.Bind(&payload) + var err error + + return OkKo(c, err) +} + +func Register(e *echo.Echo) { + e.POST(route.ProfileInit, Init) + e.POST(route.ProfilePush, Push) + e.GET(route.ProfilePull, Pull) +} diff --git a/web/helper/helper.go b/web/helper/helper.go new file mode 100644 index 0000000..1dbc662 --- /dev/null +++ b/web/helper/helper.go @@ -0,0 +1,17 @@ +package helper + +import "github.com/labstack/echo/v4" + +func Ko(c echo.Context, err error) error { + return c.JSON(400, map[string]any{ + "code": 400, + "message": err, + }) +} + +func Ok(c echo.Context) error { + return c.JSON(201, map[string]any{ + "code": 201, + "message": "ok", + }) +} From fe5eb2db344e86f91a07932f61b8821ab2a448bd Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 00:47:17 +0200 Subject: [PATCH 03/33] add playlists and profiles init/pull/push --- cmd/action/initcmd/process.go | 4 +- cmd/action/pullcmd/process.go | 53 +++++++- cmd/action/watchcmd/process.go | 4 +- model/playlist.go | 19 +-- model/profile.go | 6 +- model/pull.go | 2 +- model/subscription.go | 7 +- model/video.go | 10 +- store/file/{playlist.go => playlists.go} | 8 +- store/file/{subscription.go => profiles.go} | 8 +- web/client/client.go | 18 +++ web/controller/history/controller.go | 14 +-- web/controller/playlist/controller.go | 131 +++++++++++++++----- web/controller/profile/controller.go | 127 ++++++++++++++----- web/route/route.go | 12 +- 15 files changed, 307 insertions(+), 116 deletions(-) rename store/file/{playlist.go => playlists.go} (75%) rename store/file/{subscription.go => profiles.go} (76%) diff --git a/cmd/action/initcmd/process.go b/cmd/action/initcmd/process.go index 4cf13da..14557e8 100644 --- a/cmd/action/initcmd/process.go +++ b/cmd/action/initcmd/process.go @@ -31,8 +31,8 @@ func Process(name, route string, data any) bool { func Run() { a := Process("history", route.HistoryInit, filestore.LoadHistory()) - b := Process("playlists", route.PlaylistInit, filestore.LoadPlaylists()) - c := Process("profiles", route.ProfileInit, filestore.LoadProfiles()) + b := Process("playlists", route.PlaylistsInit, filestore.LoadPlaylists()) + c := Process("profiles", route.ProfilesInit, filestore.LoadProfiles()) if a && b && c { os.Exit(0) diff --git a/cmd/action/pullcmd/process.go b/cmd/action/pullcmd/process.go index fff3745..c05957a 100644 --- a/cmd/action/pullcmd/process.go +++ b/cmd/action/pullcmd/process.go @@ -31,13 +31,58 @@ func ProcessHistory() bool { return res } +func ProcessPlaylists() bool { + log.Print("Pull of playlists") + items, err := client.PullPlaylists() + res := true + _ = items + + if err != nil { + log.Print("Error while pulling playlists: " + err.Error()) + res = false + } else { + lines := []string{} + + for _, item := range items { + line, _ := json.Marshal(item) + lines = append(lines, string(line)) + } + + file.UpdatePlaylists(lines) + } + + return res +} + +func ProcessProfiles() bool { + log.Print("Pull of profiles") + items, err := client.PullProfiles() + res := true + _ = items + + if err != nil { + log.Print("Error while pulling profiles: " + err.Error()) + res = false + } else { + lines := []string{} + + for _, item := range items { + line, _ := json.Marshal(item) + lines = append(lines, string(line)) + } + + file.UpdateProfiles(lines) + } + + return res +} + func Run() { a := ProcessHistory() - // b := Process("playlists", route.PlaylistPull) - // c := Process("profiles", route.ProfilePull) + b := ProcessPlaylists() + c := ProcessProfiles() - // if a && b && c { - if a { + if a && b && c { os.Exit(0) } diff --git a/cmd/action/watchcmd/process.go b/cmd/action/watchcmd/process.go index 3cb078e..54e3267 100644 --- a/cmd/action/watchcmd/process.go +++ b/cmd/action/watchcmd/process.go @@ -52,9 +52,9 @@ func Run() { case c.DbPath("history"): Process("history", route.HistoryPush, filestore.LoadHistory()) case c.DbPath("playlists"): - Process("playlists", route.PlaylistPush, filestore.LoadPlaylists()) + Process("playlists", route.PlaylistsPush, filestore.LoadPlaylists()) case c.DbPath("profiles"): - Process("profiles", route.ProfilePush, filestore.LoadProfiles()) + Process("profiles", route.ProfilesPush, filestore.LoadProfiles()) } } } diff --git a/model/playlist.go b/model/playlist.go index c3926b6..beaf7e3 100644 --- a/model/playlist.go +++ b/model/playlist.go @@ -3,14 +3,15 @@ package model import "time" type Playlist struct { - ID uint `json:"-";gorm:"primary_key"` - DeletedAt *time.Time `json:"-";sql:"index"` + ID uint `json:"-" gorm:"primary_key"` + CreatedAt time.Time `json:"-"` - PlaylistName string `json:"playlistName"` - Protected bool `json:"protected"` - Description string `json:"description"` - Videos []PlaylistVideo `json:"videos"` - Id string `json:"_id"` - CreatedAt uint64 `json:"createdAt"` - LastUpdatedAt uint64 `json:"lastUpdatedAt"` + Hostname string `json:"-"` + PlaylistName string `json:"playlistName"` + Protected bool `json:"protected"` + Description string `json:"description"` + Videos []PlaylistVideo `json:"videos"` + RemoteId string `json:"_id"` + RemoteCreatedAt uint64 `json:"createdAt"` + LastUpdatedAt uint64 `json:"lastUpdatedAt"` } diff --git a/model/profile.go b/model/profile.go index 601e7ac..e3c10fb 100644 --- a/model/profile.go +++ b/model/profile.go @@ -1,13 +1,11 @@ package model -import "time" - type Profile struct { - ID uint `json:"-";gorm:"primary_key"` - DeletedAt *time.Time `json:"-";sql:"index"` + ID uint `json:"-" gorm:"primary_key"` Name string `json:"name"` BgColor string `json:"bgColor"` TextColor string `json:"textColor"` Subscriptions []Subscription `json:"subscriptions" gorm:"many2many:profile_subscription"` + RemoteId string `json:"_id"` } diff --git a/model/pull.go b/model/pull.go index 8991053..ddb4c63 100644 --- a/model/pull.go +++ b/model/pull.go @@ -5,7 +5,7 @@ import ( ) type Pull struct { - ID uint `json:"-";gorm:"primary_key"` + ID uint `json:"-" gorm:"primary_key"` Hostname string Database string diff --git a/model/subscription.go b/model/subscription.go index c2bc12d..26516fb 100644 --- a/model/subscription.go +++ b/model/subscription.go @@ -1,13 +1,10 @@ package model -import "time" - type Subscription struct { - ID uint `json:"-";gorm:"primary_key"` - DeletedAt *time.Time `json:"-";sql:"index"` + ID uint `json:"-" gorm:"primary_key"` Profiles []Profile `gorm:"many2many:profile_subscription"` - Id string `json:"id"` + RemoteId string `json:"id"` Name string `json:"name"` Thumbnail string `json:"thumbnail"` } diff --git a/model/video.go b/model/video.go index 9fe3646..e931cad 100644 --- a/model/video.go +++ b/model/video.go @@ -2,11 +2,13 @@ package model import ( "time" + + "gorm.io/gorm" ) type WatchedVideo struct { - ID uint `json:"-";gorm:"primary_key"` - DeletedAt *time.Time `json:"-";sql:"index"` + ID uint `json:"-" gorm:"primary_key"` + DeletedAt gorm.DeletedAt `json:"-" sql:"index"` VideoId string `json:"videoId"` Title string `json:"title"` @@ -20,14 +22,14 @@ type WatchedVideo struct { TimeWatched uint64 `json:"timeWatched"` IsLive bool `json:"isLive"` Type string `json:"type"` - Id string `json:"_id"` + RemoteId string `json:"_id"` LastViewedPlaylistType string `json:"lastViewedPlaylistType"` LastViewedPlaylistItemId *string `json:"lastViewedPlaylistItemId"` } type PlaylistVideo struct { ID uint `gorm:"primary_key"` - DeletedAt *time.Time `json:"-";sql:"index"` + DeletedAt *time.Time `json:"-" sql:"index"` PlaylistID uint VideoId string `json:"videoId"` diff --git a/store/file/playlist.go b/store/file/playlists.go similarity index 75% rename from store/file/playlist.go rename to store/file/playlists.go index 3639d74..dd853e0 100644 --- a/store/file/playlist.go +++ b/store/file/playlists.go @@ -17,11 +17,15 @@ func LoadPlaylists() []model.Playlist { var item model.Playlist json.Unmarshal([]byte(lines[i]), &item) - if !added[item.Id] { - added[item.Id] = true + if !added[item.RemoteId] { + added[item.RemoteId] = true collection = append(collection, item) } } return collection } + +func UpdatePlaylists(data []string) { + file.WriteDatabase(config.GetConfig().DbPath("playlists"), data) +} diff --git a/store/file/subscription.go b/store/file/profiles.go similarity index 76% rename from store/file/subscription.go rename to store/file/profiles.go index fb17c26..18e9c3f 100644 --- a/store/file/subscription.go +++ b/store/file/profiles.go @@ -17,11 +17,15 @@ func LoadProfiles() []model.Profile { var item model.Profile json.Unmarshal([]byte(lines[i]), &item) - if !added[item.Name] { - added[item.Name] = true + if !added[item.RemoteId] { + added[item.RemoteId] = true collection = append(collection, item) } } return collection } + +func UpdateProfiles(data []string) { + file.WriteDatabase(config.GetConfig().DbPath("profiles"), data) +} diff --git a/web/client/client.go b/web/client/client.go index c4db9fd..a94262c 100644 --- a/web/client/client.go +++ b/web/client/client.go @@ -78,3 +78,21 @@ func PullHistory() ([]model.WatchedVideo, error) { return items, err } + +func PullPlaylists() ([]model.Playlist, error) { + var items []model.Playlist + + body, err := Get(route.PlaylistsPull) + json.Unmarshal(body, &items) + + return items, err +} + +func PullProfiles() ([]model.Profile, error) { + var items []model.Profile + + body, err := Get(route.ProfilesPull) + json.Unmarshal(body, &items) + + return items, err +} diff --git a/web/controller/history/controller.go b/web/controller/history/controller.go index 6536d87..b25a452 100644 --- a/web/controller/history/controller.go +++ b/web/controller/history/controller.go @@ -11,26 +11,26 @@ import ( ) func InitPush(c echo.Context) error { - payload := []model.WatchedVideo{} - err := c.Bind(&payload) + watchedVideos := []model.WatchedVideo{} + err := c.Bind(&watchedVideos) manager := database.GetManager() if err != nil { return helper.Ko(c, err) } - for _, item := range payload { - manager.Db.Where(item).FirstOrCreate(&item) + for _, watchedVideo := range watchedVideos { + manager.Db.Where(watchedVideo).FirstOrCreate(&watchedVideo) } return helper.Ok(c) } func Pull(c echo.Context) error { - entities := []model.WatchedVideo{} + watchedVideos := []model.WatchedVideo{} manager := database.GetManager() - manager.Db.Find(&entities) + manager.Db.Find(&watchedVideos) pull := model.Pull{ Hostname: c.Request().Header.Get("X-Machine"), @@ -41,7 +41,7 @@ func Pull(c echo.Context) error { pull.PullAt = time.Now() manager.Db.Save(&pull) - return c.JSON(200, entities) + return c.JSON(200, watchedVideos) } func Register(e *echo.Echo) { diff --git a/web/controller/playlist/controller.go b/web/controller/playlist/controller.go index b6c5e99..847cb10 100644 --- a/web/controller/playlist/controller.go +++ b/web/controller/playlist/controller.go @@ -1,58 +1,121 @@ package playlist import ( + "time" + "github.com/labstack/echo/v4" + "gitnet.fr/deblan/freetube-sync/model" + "gitnet.fr/deblan/freetube-sync/store/database" + "gitnet.fr/deblan/freetube-sync/web/helper" "gitnet.fr/deblan/freetube-sync/web/route" + "gorm.io/gorm/clause" ) -func Ko(c echo.Context, err error) error { - return c.JSON(400, map[string]any{ - "code": 400, - "message": err, - }) -} +func Init(c echo.Context) error { + playlists := []model.Playlist{} + err := c.Bind(&playlists) + manager := database.GetManager() -func Ok(c echo.Context) error { - return c.JSON(201, map[string]any{ - "code": 201, - "message": "ok", - }) -} - -func OkKo(c echo.Context, err error) error { if err != nil { - return Ko(c, err) + return helper.Ko(c, err) } - return Ok(c) -} + for _, playlist := range playlists { + manager.Db.Create(&playlist) + } -func Init(c echo.Context) error { - // payload := []model.Video{} - // err := c.Bind(&payload) - var err error - - return OkKo(c, err) + return helper.Ok(c) } func Push(c echo.Context) error { - // payload := []model.Video{} - // err := c.Bind(&payload) - var err error + playlists := []model.Playlist{} + err := c.Bind(&playlists) + manager := database.GetManager() - return OkKo(c, err) + if err != nil { + return helper.Ko(c, err) + } + + hostname := c.Request().Header.Get("X-Machine") + + pull := model.Pull{ + Hostname: hostname, + Database: "playlists", + } + + manager.Db.Where(pull).First(&pull) + + ids := []string{} + + for _, playlist := range playlists { + if playlist.PlaylistName == "" { + continue + } + + var existingPlaylist model.Playlist + manager.Db.Preload("Videos").Where(model.Playlist{ + RemoteId: playlist.RemoteId, + }).First(&existingPlaylist) + + if existingPlaylist.ID == 0 { + playlist.Hostname = hostname + manager.Db.Create(&playlist) + ids = append(ids, playlist.RemoteId) + } else { + existingPlaylist.Description = playlist.Description + existingPlaylist.LastUpdatedAt = playlist.LastUpdatedAt + existingPlaylist.PlaylistName = playlist.PlaylistName + existingPlaylist.Protected = playlist.Protected + + for _, v := range existingPlaylist.Videos { + manager.Db.Delete(v) + } + + existingPlaylist.Videos = playlist.Videos + manager.Db.Save(&existingPlaylist) + ids = append(ids, existingPlaylist.RemoteId) + } + } + + if len(ids) > 0 { + var playlistsToDelete []model.Playlist + + manager.Db.Find( + &playlistsToDelete, + "remote_id not in (?) and (created_at < ? or hostname = ?)", + ids, + pull.PullAt, + hostname, + ) + + for _, entity := range playlistsToDelete { + manager.Db.Select(clause.Associations).Delete(&entity) + } + } + + return helper.Ok(c) } func Pull(c echo.Context) error { - // payload := []model.Video{} - // err := c.Bind(&payload) - var err error + playlists := []model.Playlist{} + manager := database.GetManager() - return OkKo(c, err) + manager.Db.Preload("Videos").Find(&playlists) + + pull := model.Pull{ + Hostname: c.Request().Header.Get("X-Machine"), + Database: "playlist", + } + + manager.Db.Where(pull).FirstOrCreate(&pull) + pull.PullAt = time.Now() + manager.Db.Save(&pull) + + return c.JSON(200, playlists) } func Register(e *echo.Echo) { - e.POST(route.PlaylistInit, Init) - e.POST(route.PlaylistPush, Push) - e.GET(route.PlaylistPull, Pull) + e.POST(route.PlaylistsInit, Init) + e.POST(route.PlaylistsPush, Push) + e.GET(route.PlaylistsPull, Pull) } diff --git a/web/controller/profile/controller.go b/web/controller/profile/controller.go index 416d764..e1ca649 100644 --- a/web/controller/profile/controller.go +++ b/web/controller/profile/controller.go @@ -1,58 +1,117 @@ package profile import ( + "time" + "github.com/labstack/echo/v4" + "gitnet.fr/deblan/freetube-sync/model" + "gitnet.fr/deblan/freetube-sync/store/database" + "gitnet.fr/deblan/freetube-sync/web/helper" "gitnet.fr/deblan/freetube-sync/web/route" + "gorm.io/gorm/clause" ) -func Ko(c echo.Context, err error) error { - return c.JSON(400, map[string]any{ - "code": 400, - "message": err, - }) -} +func Init(c echo.Context) error { + profiles := []model.Profile{} + err := c.Bind(&profiles) + manager := database.GetManager() -func Ok(c echo.Context) error { - return c.JSON(201, map[string]any{ - "code": 201, - "message": "ok", - }) -} - -func OkKo(c echo.Context, err error) error { if err != nil { - return Ko(c, err) + return helper.Ko(c, err) } - return Ok(c) -} + for _, profile := range profiles { + manager.Db.Create(&profile) + } -func Init(c echo.Context) error { - // payload := []model.Video{} - // err := c.Bind(&payload) - var err error - - return OkKo(c, err) + return helper.Ok(c) } func Push(c echo.Context) error { - // payload := []model.Video{} - // err := c.Bind(&payload) - var err error + profiles := []model.Profile{} + err := c.Bind(&profiles) + manager := database.GetManager() - return OkKo(c, err) + if err != nil { + return helper.Ko(c, err) + } + + hostname := c.Request().Header.Get("X-Machine") + + pull := model.Pull{ + Hostname: hostname, + Database: "playlist", + } + + manager.Db.Where(pull).First(&pull) + + ids := []string{} + + for _, profile := range profiles { + if profile.Name == "" { + continue + } + + var existingProfile model.Profile + manager.Db.Preload("Subscriptions").Where(model.Profile{ + RemoteId: profile.RemoteId, + }).First(&existingProfile) + + if existingProfile.ID == 0 { + manager.Db.Create(&profile) + ids = append(ids, profile.Name) + } else { + existingProfile.Name = profile.Name + existingProfile.BgColor = profile.BgColor + existingProfile.TextColor = profile.TextColor + + for _, v := range existingProfile.Subscriptions { + manager.Db.Select(clause.Associations).Delete(v) + } + + existingProfile.Subscriptions = profile.Subscriptions + manager.Db.Save(&existingProfile) + ids = append(ids, existingProfile.Name) + } + } + + if len(ids) > 0 { + var profilesToDelete []model.Profile + + manager.Db.Find( + &profilesToDelete, + "name not in (?)", + ids, + ) + + for _, entity := range profilesToDelete { + manager.Db.Select(clause.Associations).Delete(&entity) + } + } + + return helper.Ok(c) } func Pull(c echo.Context) error { - // payload := []model.Video{} - // err := c.Bind(&payload) - var err error + profiles := []model.Profile{} + manager := database.GetManager() - return OkKo(c, err) + manager.Db.Preload("Subscriptions").Find(&profiles) + + pull := model.Pull{ + Hostname: c.Request().Header.Get("X-Machine"), + Database: "profiles", + } + + manager.Db.Where(pull).FirstOrCreate(&pull) + pull.PullAt = time.Now() + manager.Db.Save(&pull) + + return c.JSON(200, profiles) } func Register(e *echo.Echo) { - e.POST(route.ProfileInit, Init) - e.POST(route.ProfilePush, Push) - e.GET(route.ProfilePull, Pull) + e.POST(route.ProfilesInit, Init) + e.POST(route.ProfilesPush, Push) + e.GET(route.ProfilesPull, Pull) } diff --git a/web/route/route.go b/web/route/route.go index 2947a63..b0d5095 100644 --- a/web/route/route.go +++ b/web/route/route.go @@ -5,11 +5,11 @@ const ( HistoryPush = "/history/push" HistoryPull = "/history/pull" - ProfileInit = "/profile/init" - ProfilePush = "/profile/push" - ProfilePull = "/profile/pull" + ProfilesInit = "/profiles/init" + ProfilesPush = "/profiles/push" + ProfilesPull = "/profiles/pull" - PlaylistInit = "/playlist/init" - PlaylistPush = "/playlist/push" - PlaylistPull = "/playlist/pull" + PlaylistsInit = "/playlists/init" + PlaylistsPush = "/playlists/push" + PlaylistsPull = "/playlists/pull" ) From 0ced6ceaef07ce6cdb3e1bf8aa1eed0250c511e1 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 12:56:29 +0200 Subject: [PATCH 04/33] add makefile --- Makefile | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..a53b12a --- /dev/null +++ b/Makefile @@ -0,0 +1,25 @@ +CC = go build +CFLAGS = -trimpath +LDFLAGS = all=-w -s +GCFLAGS = all= +ASMFLAGS = all= + +all: client server + +.PHONY: client +client: + GO111MODULE=$(GOMOD) \ + GOARCH=$(GO_ARCH_AMD) \ + GOOS=$(GO_OS_LINUX) \ + CGO_ENABLED=0 \ + $(CC) $(CFLAGS) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" \ + -o ./client ./cmd/client + +.PHONY: server +server: + GO111MODULE=$(GOMOD) \ + GOARCH=$(GO_ARCH_AMD) \ + GOOS=$(GO_OS_LINUX) \ + CGO_ENABLED=1 \ + $(CC) $(CFLAGS) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" \ + -o ./server ./cmd/server From 71a05fd864ed4c6d403d97c0231d6d7085c3d919 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 12:56:56 +0200 Subject: [PATCH 05/33] fix default server database path --- config/server/config.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/server/config.go b/config/server/config.go index da31977..fee892f 100644 --- a/config/server/config.go +++ b/config/server/config.go @@ -26,7 +26,7 @@ func (c *Config) Define(bindAddress, dbPath string) { } func InitConfig() { - dbPath := flag.String("d", os.Getenv("HOME")+"/.config/FreeTube/sync.sqlite", "Path to SQlite database") + dbPath := flag.String("d", os.Getenv("HOME")+"/freetube.sqlite", "Path to SQlite database") bindAddress := flag.String("b", ":1323", "Bind address") flag.Parse() From 269ffac4526e05a29d0190993ca5d245dee2d816 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 12:57:06 +0200 Subject: [PATCH 06/33] update documentation --- README.md | 22 ++++++++++++++++++++++ cmd/client/main.go | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..9808cbf --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +# FreeTube sync + +```mermaid +sequenceDiagram + participant Client + participant Server + + Note over Client, Server: Only once + Client->>+Server: Send initial history, playlists, profiles + Server-->>-Client: Response OK/KO + + Note over Client, Server: Before launching FreeTube + Client->>+Server: Pull update to date history, playlists, profiles + Server-->>-Client: Response datas + Client->>+Client: Update databases + + Note over Client, Server: While FreeTube is running + loop Watch local db updates + Client->>+Server: Send updated history, playlists, profiles + Server-->>-Client: Response OK/KO + end +``` diff --git a/cmd/client/main.go b/cmd/client/main.go index f142598..fcb2549 100644 --- a/cmd/client/main.go +++ b/cmd/client/main.go @@ -22,7 +22,7 @@ func main() { case "pull": pullcmd.Run() default: - fmt.Print("You must pass a sub-command: init, watch") + fmt.Print("You must pass a sub-command: init, watch, pull") os.Exit(1) } } From 01eef4c5f1be8b810e87850cb68f0efec82885f6 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 13:39:25 +0200 Subject: [PATCH 07/33] update documentation --- README.md | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 9808cbf..664ee45 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,22 @@ -# FreeTube sync +# FreeTube Sync + +[FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. + +It does not require an account, all datas are on your local storage. In case of you use FreeTube on several computers, you can't synchronize them easily. FreeTube stores datas on plain text files, loaded in memory and rewrite them on each updates. + +**FreeTube Sync** tries to solve this problem. + +## What are requirements? + +**FreeTube Sync** requires a server accessible by all machines running FreeTube (on a local network, through a VPN or on the web). + +## How does it work? + +The role of the server is to store the history, the playlists and the profiles of FreeTube instances (clients). + +After starting the server, each client must init its local datas on the server. This action must be processed only once. +At each time you want to use FreeTube, you have to pull datas from the server before. A watcher will push updates on the server when your history, your playlists or your profiles are updated. +When FreeTube is restarted, history, playlists and profiles will be updated. ```mermaid sequenceDiagram From 790c7c84f6b8d8d01e429310cbc4d82c335cf6cc Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 15:39:06 +0200 Subject: [PATCH 08/33] update documentation --- README.md | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/README.md b/README.md index 664ee45..9912845 100644 --- a/README.md +++ b/README.md @@ -38,3 +38,67 @@ sequenceDiagram Server-->>-Client: Response OK/KO end ``` + +## How to use it? + +### Server + +To start the server, simply run: + +``` +/path/to/server +``` + +### Client + +First, sync your local datas to the server: + +``` +/path/to/client -s http://ip.of.the.server:1323 init +``` + +Create `~/.bin/freetube-wrapper` and fill it with: + +``` +#!/bin/sh + +/path/to/client -s http://ip.of.the.server:1323 pull +exec /opt/FreeTube/freetube $@ +``` + +Then run `chmod +x ~/.bin/freetube-wrapper`. + +Create `~/.local/share/applications/FreeTubeSync.desktop` and fill it with: + +``` +[Desktop Entry] +Type=Application +Icon=freetube +Terminal=false +Exec=/home/foo/.bin/freetube-wrapper +Name=FreeTube (synced) +``` + +Create `~/.config/systemd/user/freetubesync-watcher.service` and fill it with: + +``` +[Unit] +Description=FreeTube Sync Watcher + +[Service] +Type=simple +StandardOutput=journal +ExecStart=/path/to/client -s http://ip.of.the.server:1323 watch + +[Install] +WantedBy=default.target +``` + +Then run: + +``` +systemctl --user daemon-reload +systemctl --user start freetubesync-watcher.service +``` + +Choose `FreeTube (synced)` to open FreeTube. From d1876f46ead94c357001110231367d5206aa8637 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 16:45:02 +0200 Subject: [PATCH 09/33] update documentation --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9912845..1a742bb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# FreeTube Sync +# ↕️ FreeTube Sync [FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. @@ -6,11 +6,11 @@ It does not require an account, all datas are on your local storage. In case of **FreeTube Sync** tries to solve this problem. -## What are requirements? +## ⚙️ What are requirements? **FreeTube Sync** requires a server accessible by all machines running FreeTube (on a local network, through a VPN or on the web). -## How does it work? +## 🧬 How does it work? The role of the server is to store the history, the playlists and the profiles of FreeTube instances (clients). @@ -39,7 +39,7 @@ sequenceDiagram end ``` -## How to use it? +## 📗 How to use it? ### Server From 6ba4c63bfdf373c4954a8b8b4bc600da87b5c189 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 17:06:21 +0200 Subject: [PATCH 10/33] add logo --- logo.svg | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100644 logo.svg diff --git a/logo.svg b/logo.svg new file mode 100644 index 0000000..93515dd --- /dev/null +++ b/logo.svg @@ -0,0 +1,94 @@ + + + + + + From 3489c90bd809e3bd9ba8ef83a5b50de2d06c96b5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 17:09:12 +0200 Subject: [PATCH 11/33] update documentation --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1a742bb..677de10 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# ↕️ FreeTube Sync +![](https://deblan.gitnet.page/freetube-sync/logo.svg) + +# FreeTube Sync [FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. From 33289e5e004dbc7b09f8acbc89ca3aee3344a2c9 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 17:09:35 +0200 Subject: [PATCH 12/33] update documentation --- README.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/README.md b/README.md index 677de10..86e4c57 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ ![](https://deblan.gitnet.page/freetube-sync/logo.svg) -# FreeTube Sync - [FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. It does not require an account, all datas are on your local storage. In case of you use FreeTube on several computers, you can't synchronize them easily. FreeTube stores datas on plain text files, loaded in memory and rewrite them on each updates. From 95d318a9fb0e5b52c906ec1dc66e4031130af145 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 19:23:26 +0200 Subject: [PATCH 13/33] update documentation --- .gitignore | 3 +-- CHANGELOG.md | 5 +++++ Makefile | 43 ++++++++++++++++++++++++++----------------- README.md | 46 +++++++++++++++++++++++++++++++++++++++------- 4 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 CHANGELOG.md diff --git a/.gitignore b/.gitignore index 3d33a15..796b96d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1 @@ -/client -/server +/build diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..f36e6b0 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +[Unreleased] + +# v1.0.0 +## Added +- First release! 😍 diff --git a/Makefile b/Makefile index a53b12a..1821d94 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,34 @@ -CC = go build -CFLAGS = -trimpath -LDFLAGS = all=-w -s -GCFLAGS = all= -ASMFLAGS = all= +DIR = ./build +GO_ARCH_AMD = amd64 +GO_ARCH_ARM = arm64 +GO_OS_LINUX = linux +EXECUTABLE_PREFIX = freetube-sync + +BIN_LINUX_SERVER_AMD64 = $(DIR)/$(EXECUTABLE_PREFIX)-server-$(GO_ARCH_AMD) +BIN_LINUX_SERVER_ARM64 = $(DIR)/$(EXECUTABLE_PREFIX)-server-$(GO_ARCH_ARM) + +BIN_LINUX_CLIENT_AMD64 = $(DIR)/$(EXECUTABLE_PREFIX)-client-$(GO_ARCH_AMD) +BIN_LINUX_CLIENT_ARM64 = $(DIR)/$(EXECUTABLE_PREFIX)-client-$(GO_ARCH_ARM) + +LDFLAGS = -extldflags=-static + +.PHONY: all: client server .PHONY: client client: - GO111MODULE=$(GOMOD) \ - GOARCH=$(GO_ARCH_AMD) \ - GOOS=$(GO_OS_LINUX) \ - CGO_ENABLED=0 \ - $(CC) $(CFLAGS) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" \ - -o ./client ./cmd/client + GOARCH=$(GO_ARCH_AMD) GOOS=$(GO_OS_LINUX) CGO_ENABLED=0 go build -o $(BIN_LINUX_CLIENT_AMD64) ./cmd/client + GOARCH=$(GO_ARCH_ARM) GOOS=$(GO_OS_LINUX) CGO_ENABLED=0 go build -o $(BIN_LINUX_CLIENT_ARM64) ./cmd/client .PHONY: server server: - GO111MODULE=$(GOMOD) \ - GOARCH=$(GO_ARCH_AMD) \ - GOOS=$(GO_OS_LINUX) \ - CGO_ENABLED=1 \ - $(CC) $(CFLAGS) -ldflags="$(LDFLAGS)" -gcflags="$(GCFLAGS)" -asmflags="$(ASMFLAGS)" \ - -o ./server ./cmd/server + GOARCH=$(GO_ARCH_AMD) GOOS=$(GO_OS_LINUX) CGO_ENABLED=$(CGO_ENABLED) \ + go build -ldflags="$(LDFLAGS)" -tags osusergo,netgo,sqlite_omit_load_extension -o $(BIN_LINUX_SERVER_AMD64) ./cmd/server + + GOARCH=$(GO_ARCH_ARM) GOOS=$(GO_OS_LINUX) GOARM=7 CGO_ENABLED=$(CGO_ENABLED) \ + CC=arm-linux-gnueabihf-gcc CXX=arm-linux-gnueabihf-g++ \ + go build -ldflags="$(LDFLAGS)" -tags osusergo,netgo,sqlite_omit_load_extension -o $(BIN_LINUX_SERVER_ARM64) ./cmd/server + +clean: + rm $(DIR)/* diff --git a/README.md b/README.md index 86e4c57..f7ead82 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](https://deblan.gitnet.page/freetube-sync/logo.svg) -[FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. +[FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. It does not require an account, all datas are on your local storage. In case of you use FreeTube on several computers, you can't synchronize them easily. FreeTube stores datas on plain text files, loaded in memory and rewrite them on each updates. @@ -14,7 +14,7 @@ It does not require an account, all datas are on your local storage. In case of The role of the server is to store the history, the playlists and the profiles of FreeTube instances (clients). -After starting the server, each client must init its local datas on the server. This action must be processed only once. +After starting the server, each client must initialize their local datas on the server. This action must be processed only once. At each time you want to use FreeTube, you have to pull datas from the server before. A watcher will push updates on the server when your history, your playlists or your profiles are updated. When FreeTube is restarted, history, playlists and profiles will be updated. @@ -41,20 +41,40 @@ sequenceDiagram ## 📗 How to use it? +Go to [releases](https://gitnet.fr/deblan/freetube-sync/releases) and download the client and the server according of your system architecture. + +On the server: + +```bash +chmod +x freetube-sync-server-xxx +sudo mv freetube-sync-server-xxx /usr/local/bin/freetube-sync-server +``` + +On clients: + +``` +chmod +x freetube-sync-client-xxx +sudo mv freetube-sync-client-xxx /usr/local/bin/freetube-sync-client +``` + ### Server To start the server, simply run: ``` -/path/to/server +freetube-sync-server ``` +By default, it listens on all interfaces, port 1323. + +⚠️ Consider installing a proxy to secure access (HTTPS, IP access restriction, …). + ### Client First, sync your local datas to the server: ``` -/path/to/client -s http://ip.of.the.server:1323 init +freetube-sync-client -s http://ip.of.the.server:1323 init ``` Create `~/.bin/freetube-wrapper` and fill it with: @@ -62,8 +82,8 @@ Create `~/.bin/freetube-wrapper` and fill it with: ``` #!/bin/sh -/path/to/client -s http://ip.of.the.server:1323 pull -exec /opt/FreeTube/freetube $@ +freetube-sync-client -s http://ip.of.the.server:1323 pull +exec freetube $@ ``` Then run `chmod +x ~/.bin/freetube-wrapper`. @@ -88,7 +108,7 @@ Description=FreeTube Sync Watcher [Service] Type=simple StandardOutput=journal -ExecStart=/path/to/client -s http://ip.of.the.server:1323 watch +ExecStart=freetube-sync-client -s http://ip.of.the.server:1323 watch [Install] WantedBy=default.target @@ -102,3 +122,15 @@ systemctl --user start freetubesync-watcher.service ``` Choose `FreeTube (synced)` to open FreeTube. + +## 🧪 Compilation sources + +- [GO 1.23](https://go.dev/dl/) +- `build-essential` +- `gcc-arm-linux-gnueabihf` in case of cross compilation + +```bash +git clone https://gitnet.fr/deblan/freetube-sync +cd freetube-sync +make +``` From 185723cb7850ae75da315b6ec2b0e4e4f9855145 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Thu, 29 Aug 2024 23:20:40 +0200 Subject: [PATCH 14/33] add logos --- logo_small.png | Bin 0 -> 6296 bytes logo_small.svg | 101 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) create mode 100644 logo_small.png create mode 100644 logo_small.svg diff --git a/logo_small.png b/logo_small.png new file mode 100644 index 0000000000000000000000000000000000000000..7bcf7828dda8ee0fd146846c9a1d3fc2b46cfc9a GIT binary patch literal 6296 zcmb_>XEa=2^tKQ!qDKq~5(FU_KQ(Him(htJ$`A=gXGSMFV-P{~9xZx_HagM!Fv=Ju z1TjX57A^jh|9U^ZpWgL;IQQK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8Ve5H2La;H%!va%L^c6x`AtdI(21SOvINs#(?8^6C3Wyy| z2lL~I1z~qXaYyG*>CeNwaQ;_>&PNw7{amaV)P_4Z@SXPi?eCeAW9^q!&@Tz-!*#TE z6deBNjK#4SX`L}TYJ9l=1sAgaeA@x94%(E9dI)`4u z(<^UXPtVH0Zw-zq&`MSf9i4-&eKh+g`CrGVu=iqC$ouj!0mLt1jpCT|KZj_qkJwgI zTCOlC-sew^IHc#|1U>3C71ZKzEx<3p0dFhtT%zRqFd?~HezxF$NZoN7NuO8a_5?VN zmWZ&B=jF1c;|SW`xy!Vty>DgO64T#*6q4|!{BdGK2Zby}ClgOc#rSRFrjNCUi9w@EIf*Um55`jH~OO&eNNsKkW8vkMP=}T3Z>^ z{I*h==cFGH&Ed}6uorEhKc0;F+H`Ok?5rd+WvHpIr}x1iwP40AkJ-#y-JZHk5htB2 z9gQ{zBD^R4NP{}JwtPY3z&nYdZN6iC%B-LM|F+KmbyEMg34f&^Ty~%+Z>BFz_^Uvq Mp`xQ)rDz@cKa@O4761SM literal 0 HcmV?d00001 diff --git a/logo_small.svg b/logo_small.svg new file mode 100644 index 0000000..0029e46 --- /dev/null +++ b/logo_small.svg @@ -0,0 +1,101 @@ + + + + + + From 0fd711860433dd3fc2251e93b99c312bec54c564 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Fri, 30 Aug 2024 08:49:29 +0200 Subject: [PATCH 15/33] update readme --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f7ead82..307aae1 100644 --- a/README.md +++ b/README.md @@ -109,6 +109,8 @@ Description=FreeTube Sync Watcher Type=simple StandardOutput=journal ExecStart=freetube-sync-client -s http://ip.of.the.server:1323 watch +Restart=on-failure +RestartSec=1s [Install] WantedBy=default.target From 632e0253f956847349941f529508773700428964 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 19:53:44 +0200 Subject: [PATCH 16/33] update readme --- Makefile | 2 +- README.md | 30 +++++++++++++++++------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 1821d94..48783e6 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ GO_ARCH_AMD = amd64 GO_ARCH_ARM = arm64 GO_OS_LINUX = linux -EXECUTABLE_PREFIX = freetube-sync +EXECUTABLE_PREFIX = ftsync BIN_LINUX_SERVER_AMD64 = $(DIR)/$(EXECUTABLE_PREFIX)-server-$(GO_ARCH_AMD) BIN_LINUX_SERVER_ARM64 = $(DIR)/$(EXECUTABLE_PREFIX)-server-$(GO_ARCH_ARM) diff --git a/README.md b/README.md index 307aae1..6e126e7 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,18 @@ -![](https://deblan.gitnet.page/freetube-sync/logo.svg) +![](https://deblan.gitnet.page/ft-sync/logo.svg) + +![](https://img.shields.io/badge/Licence-GNU_AGPLv3-blue) ![](https://img.shields.io/badge/GO-1.23-orange) [FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. It does not require an account, all datas are on your local storage. In case of you use FreeTube on several computers, you can't synchronize them easily. FreeTube stores datas on plain text files, loaded in memory and rewrite them on each updates. -**FreeTube Sync** tries to solve this problem. +**FT-Sync tries to solve this problem. + +**⚠️ FT-Sync is not a project maintained by FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** ## ⚙️ What are requirements? -**FreeTube Sync** requires a server accessible by all machines running FreeTube (on a local network, through a VPN or on the web). +**FT-Sync** requires a server accessible by all machines running FreeTube (on a local network, through a VPN or on the web). ## 🧬 How does it work? @@ -46,15 +50,15 @@ Go to [releases](https://gitnet.fr/deblan/freetube-sync/releases) and download t On the server: ```bash -chmod +x freetube-sync-server-xxx -sudo mv freetube-sync-server-xxx /usr/local/bin/freetube-sync-server +chmod +x ftsync-server-xxx +sudo mv ftsync-server-xxx /usr/local/bin/ftsync-server ``` On clients: ``` -chmod +x freetube-sync-client-xxx -sudo mv freetube-sync-client-xxx /usr/local/bin/freetube-sync-client +chmod +x ftsync-client-xxx +sudo mv ftsync-client-xxx /usr/local/bin/ftsync-client ``` ### Server @@ -62,7 +66,7 @@ sudo mv freetube-sync-client-xxx /usr/local/bin/freetube-sync-client To start the server, simply run: ``` -freetube-sync-server +ftsync-server ``` By default, it listens on all interfaces, port 1323. @@ -74,7 +78,7 @@ By default, it listens on all interfaces, port 1323. First, sync your local datas to the server: ``` -freetube-sync-client -s http://ip.of.the.server:1323 init +ftsync-client -s http://ip.of.the.server:1323 init ``` Create `~/.bin/freetube-wrapper` and fill it with: @@ -82,7 +86,7 @@ Create `~/.bin/freetube-wrapper` and fill it with: ``` #!/bin/sh -freetube-sync-client -s http://ip.of.the.server:1323 pull +ftsync-client -s http://ip.of.the.server:1323 pull exec freetube $@ ``` @@ -99,11 +103,11 @@ Exec=/home/foo/.bin/freetube-wrapper Name=FreeTube (synced) ``` -Create `~/.config/systemd/user/freetubesync-watcher.service` and fill it with: +Create `~/.config/systemd/user/ftsync-watcher.service` and fill it with: ``` [Unit] -Description=FreeTube Sync Watcher +Description=FTSync Watcher [Service] Type=simple @@ -120,7 +124,7 @@ Then run: ``` systemctl --user daemon-reload -systemctl --user start freetubesync-watcher.service +systemctl --user start ftsync-watcher.service ``` Choose `FreeTube (synced)` to open FreeTube. From 332e14343a1fdb5fe29dfc4e2c03b16cfe0ceec6 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 19:53:52 +0200 Subject: [PATCH 17/33] add licence --- LICENCE | 661 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 661 insertions(+) create mode 100644 LICENCE diff --git a/LICENCE b/LICENCE new file mode 100644 index 0000000..be3f7b2 --- /dev/null +++ b/LICENCE @@ -0,0 +1,661 @@ + GNU AFFERO GENERAL PUBLIC LICENSE + Version 3, 19 November 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU Affero General Public License is a free, copyleft license for +software and other kinds of works, specifically designed to ensure +cooperation with the community in the case of network server software. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +our General Public Licenses are intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + Developers that use our General Public Licenses protect your rights +with two steps: (1) assert copyright on the software, and (2) offer +you this License which gives you legal permission to copy, distribute +and/or modify the software. + + A secondary benefit of defending all users' freedom is that +improvements made in alternate versions of the program, if they +receive widespread use, become available for other developers to +incorporate. Many developers of free software are heartened and +encouraged by the resulting cooperation. However, in the case of +software used on network servers, this result may fail to come about. +The GNU General Public License permits making a modified version and +letting the public access it on a server without ever releasing its +source code to the public. + + The GNU Affero General Public License is designed specifically to +ensure that, in such cases, the modified source code becomes available +to the community. It requires the operator of a network server to +provide the source code of the modified version running there to the +users of that server. Therefore, public use of a modified version, on +a publicly accessible server, gives the public access to the source +code of the modified version. + + An older license, called the Affero General Public License and +published by Affero, was designed to accomplish similar goals. This is +a different license, not a version of the Affero GPL, but Affero has +released a new version of the Affero GPL which permits relicensing under +this license. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU Affero General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Remote Network Interaction; Use with the GNU General Public License. + + Notwithstanding any other provision of this License, if you modify the +Program, your modified version must prominently offer all users +interacting with it remotely through a computer network (if your version +supports such interaction) an opportunity to receive the Corresponding +Source of your version by providing access to the Corresponding Source +from a network server at no charge, through some standard or customary +means of facilitating copying of software. This Corresponding Source +shall include the Corresponding Source for any work covered by version 3 +of the GNU General Public License that is incorporated pursuant to the +following paragraph. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the work with which it is combined will remain governed by version +3 of the GNU General Public License. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU Affero General Public License from time to time. Such new versions +will be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU Affero General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU Affero General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU Affero General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If your software can interact with users remotely through a computer +network, you should also make sure that it provides a way for users to +get its source. For example, if your program is a web application, its +interface could display a "Source" link that leads users to an archive +of the code. There are many ways you could offer source, and different +solutions will be better for different programs; see section 13 for the +specific requirements. + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU AGPL, see +. From f6c95eefc5130b5eb1f8eb3ff7e26d1bfa8429d4 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:05:19 +0200 Subject: [PATCH 18/33] update logo --- logo.svg | 104 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 60 insertions(+), 44 deletions(-) diff --git a/logo.svg b/logo.svg index 93515dd..f1a094a 100644 --- a/logo.svg +++ b/logo.svg @@ -6,10 +6,10 @@ id="Layer_1" x="0px" y="0px" - viewBox="0 0 640 200" + viewBox="0 0 601.49817 200" xml:space="preserve" sodipodi:docname="logo.svg" - width="640" + width="601.49817" height="200" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" @@ -26,10 +26,10 @@ inkscape:pagecheckerboard="0" inkscape:deskcolor="#d1d1d1" showgrid="false" - showguides="true" - inkscape:zoom="1.4226563" - inkscape:cx="472.7073" - inkscape:cy="188.38001" + showguides="false" + inkscape:zoom="1.0059699" + inkscape:cx="612.84139" + inkscape:cy="259.4511" inkscape:window-width="1898" inkscape:window-height="1019" inkscape:window-x="10" @@ -46,49 +46,65 @@ inkscape:locked="false" /> + id="path2279" />SYNC From e918f56c3e50363926dc58de7c4b174fba4ca1df Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:07:57 +0200 Subject: [PATCH 19/33] update logo --- logo.svg | 72 ++++++++++++++++++++++++++++++-------------------------- 1 file changed, 38 insertions(+), 34 deletions(-) diff --git a/logo.svg b/logo.svg index f1a094a..9970c1a 100644 --- a/logo.svg +++ b/logo.svg @@ -74,37 +74,41 @@ id="path2277" />SYNC + id="path2279" />SYNC From 472e524f3db3a91f2df943d2aedc115305e25289 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:08:53 +0200 Subject: [PATCH 20/33] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6e126e7..5972388 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![](https://deblan.gitnet.page/ft-sync/logo.svg) -![](https://img.shields.io/badge/Licence-GNU_AGPLv3-blue) ![](https://img.shields.io/badge/GO-1.23-orange) +![](https://img.shields.io/badge/Licence-GNU_AGPLv3-blue) ![](https://img.shields.io/badge/GO-1.23-green) [FreeTube](https://freetubeapp.io/) is an open source desktop YouTube player built with privacy in mind. Use YouTube without advertisements and prevent Google from tracking you with their cookies and JavaScript. From cf1d3fad7357d2310a350d7becf40a807c3f76fc Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:10:20 +0200 Subject: [PATCH 21/33] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5972388..77f81cf 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ It does not require an account, all datas are on your local storage. In case of **FT-Sync tries to solve this problem. -**⚠️ FT-Sync is not a project maintained by FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** +**⚠️ FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem. ## ⚙️ What are requirements? From 543516ef01361550e272c2a51030308f0dc208b5 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:11:17 +0200 Subject: [PATCH 22/33] update readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 77f81cf..15b57cc 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ It does not require an account, all datas are on your local storage. In case of you use FreeTube on several computers, you can't synchronize them easily. FreeTube stores datas on plain text files, loaded in memory and rewrite them on each updates. -**FT-Sync tries to solve this problem. +**FT-Sync** tries to solve this problem. -**⚠️ FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem. +**⚠️ FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem.** ## ⚙️ What are requirements? From e220060baec5f5722d34ec2f434faacb136fcf77 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:12:03 +0200 Subject: [PATCH 23/33] update readme --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 15b57cc..a50a2f4 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,9 @@ It does not require an account, all datas are on your local storage. In case of **FT-Sync** tries to solve this problem. -**⚠️ FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem.** +## ⚠️ Disclaimer + +**FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem.** ## ⚙️ What are requirements? From 91c58aaffd29515cc1d1154fdebcf078a9c3ccad Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:17:13 +0200 Subject: [PATCH 24/33] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a50a2f4..e67a428 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ It does not require an account, all datas are on your local storage. In case of ## ⚠️ Disclaimer -**FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem.** +**FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem. ## ⚙️ What are requirements? From 00a730d378487b412ba31811dd68ab070baee216 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 20:18:26 +0200 Subject: [PATCH 25/33] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e67a428..665b7c2 100644 --- a/README.md +++ b/README.md @@ -114,7 +114,7 @@ Description=FTSync Watcher [Service] Type=simple StandardOutput=journal -ExecStart=freetube-sync-client -s http://ip.of.the.server:1323 watch +ExecStart=ftsync-client -s http://ip.of.the.server:1323 watch Restart=on-failure RestartSec=1s From 3fd4f1900970d4b109561730887fd0060d79cf60 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 23:49:08 +0200 Subject: [PATCH 26/33] server: add verbosity level server: remove filename from log (fix #1) --- config/server/config.go | 22 ++++++- logger/logger.go | 114 +++++++++++++++++++++++++++++++++++++ store/database/database.go | 17 +++++- 3 files changed, 150 insertions(+), 3 deletions(-) create mode 100644 logger/logger.go diff --git a/config/server/config.go b/config/server/config.go index fee892f..27cbece 100644 --- a/config/server/config.go +++ b/config/server/config.go @@ -3,11 +3,14 @@ package server import ( "flag" "os" + + "gitnet.fr/deblan/freetube-sync/logger" ) type Config struct { BindAddress string DbPath string + LogLevel int } var config *Config @@ -20,15 +23,30 @@ func GetConfig() *Config { return config } -func (c *Config) Define(bindAddress, dbPath string) { +func (c *Config) Define(bindAddress, dbPath string, logErrorLevel, logWarnLevel, logInfoLevel bool) { c.BindAddress = bindAddress c.DbPath = dbPath + + if logInfoLevel { + c.LogLevel = int(logger.Info) + } else if logErrorLevel { + c.LogLevel = int(logger.Error) + } else if logWarnLevel { + c.LogLevel = int(logger.Warn) + } else if logInfoLevel { + c.LogLevel = int(logger.Info) + } else { + c.LogLevel = int(logger.Silent) + } } func InitConfig() { dbPath := flag.String("d", os.Getenv("HOME")+"/freetube.sqlite", "Path to SQlite database") bindAddress := flag.String("b", ":1323", "Bind address") + logErrorLevel := flag.Bool("v", false, "Log errors") + logWarnLevel := flag.Bool("vv", false, "Log warns") + logInfoLevel := flag.Bool("vvv", false, "Log infos") flag.Parse() - GetConfig().Define(*bindAddress, *dbPath) + GetConfig().Define(*bindAddress, *dbPath, *logErrorLevel, *logWarnLevel, *logInfoLevel) } diff --git a/logger/logger.go b/logger/logger.go new file mode 100644 index 0000000..269c5ec --- /dev/null +++ b/logger/logger.go @@ -0,0 +1,114 @@ +package logger + +import ( + "context" + "errors" + "fmt" + "time" + + lg "gorm.io/gorm/logger" +) + +type LogLevel int + +const ( + Silent LogLevel = iota + 1 + Error + Warn + Info +) + +type logger struct { + lg.Writer + lg.Config + lg.Interface + infoStr, warnStr, errStr string + traceStr, traceErrStr, traceWarnStr string +} + +func New(writer lg.Writer, config lg.Config) lg.Interface { + var ( + infoStr = "%s\n[info] " + warnStr = "%s\n[warn] " + errStr = "%s\n[error] " + traceStr = "[%.3fms] [rows:%v] %s" + traceWarnStr = "%s\n[%.3fms] [rows:%v] %s" + traceErrStr = "%s\n[%.3fms] [rows:%v] %s" + ) + + if config.Colorful { + infoStr = lg.Green + "%s\n" + lg.Reset + lg.Green + "[info] " + lg.Reset + warnStr = lg.BlueBold + "%s\n" + lg.Reset + lg.Magenta + "[warn] " + lg.Reset + errStr = lg.Magenta + "%s\n" + lg.Reset + lg.Red + "[error] " + lg.Reset + traceStr = lg.Yellow + "[%.3fms] " + lg.BlueBold + "[rows:%v]" + lg.Reset + " %s" + traceWarnStr = lg.Green + "%s " + lg.Reset + lg.RedBold + "[%.3fms] " + lg.Yellow + "[rows:%v]" + lg.Magenta + " %s" + lg.Reset + traceErrStr = lg.RedBold + "%s " + lg.Reset + lg.Yellow + "[%.3fms] " + lg.BlueBold + "[rows:%v]" + lg.Reset + " %s" + } + + return &logger{ + Writer: writer, + Config: config, + infoStr: infoStr, + warnStr: warnStr, + errStr: errStr, + traceStr: traceStr, + traceWarnStr: traceWarnStr, + traceErrStr: traceErrStr, + } +} + +func (l *logger) LogMode(level lg.LogLevel) lg.Interface { + newlogger := *l + newlogger.LogLevel = level + return &newlogger +} + +func (l *logger) Info(ctx context.Context, msg string, data ...interface{}) { + if l.LogLevel >= lg.Info { + l.Printf(l.infoStr+msg, data...) + } +} + +func (l *logger) Warn(ctx context.Context, msg string, data ...interface{}) { + if l.LogLevel >= lg.Warn { + l.Printf(l.warnStr+msg, data...) + } +} + +func (l *logger) Error(ctx context.Context, msg string, data ...interface{}) { + if l.LogLevel >= lg.Error { + l.Printf(l.errStr+msg, data...) + } +} + +func (l *logger) Trace(ctx context.Context, begin time.Time, fc func() (string, int64), err error) { + if l.LogLevel <= lg.Silent { + return + } + + elapsed := time.Since(begin) + switch { + case err != nil && l.LogLevel >= lg.Error && (!errors.Is(err, lg.ErrRecordNotFound) || !l.IgnoreRecordNotFoundError): + sql, rows := fc() + if rows == -1 { + l.Printf(l.traceErrStr, err, float64(elapsed.Nanoseconds())/1e6, "-", sql) + } else { + l.Printf(l.traceErrStr, err, float64(elapsed.Nanoseconds())/1e6, rows, sql) + } + case elapsed > l.SlowThreshold && l.SlowThreshold != 0 && l.LogLevel >= lg.Warn: + sql, rows := fc() + slowLog := fmt.Sprintf("SLOW SQL >= %v", l.SlowThreshold) + if rows == -1 { + l.Printf(l.traceWarnStr, slowLog, float64(elapsed.Nanoseconds())/1e6, "-", sql) + } else { + l.Printf(l.traceWarnStr, slowLog, float64(elapsed.Nanoseconds())/1e6, rows, sql) + } + case l.LogLevel == lg.Info: + sql, rows := fc() + if rows == -1 { + l.Printf(l.traceStr, float64(elapsed.Nanoseconds())/1e6, "-", sql) + } else { + l.Printf(l.traceStr, float64(elapsed.Nanoseconds())/1e6, rows, sql) + } + } +} diff --git a/store/database/database.go b/store/database/database.go index 31d953c..8050aed 100644 --- a/store/database/database.go +++ b/store/database/database.go @@ -2,11 +2,15 @@ package database import ( "log" + "os" + "time" config "gitnet.fr/deblan/freetube-sync/config/server" + "gitnet.fr/deblan/freetube-sync/logger" "gitnet.fr/deblan/freetube-sync/model" "gorm.io/driver/sqlite" "gorm.io/gorm" + lg "gorm.io/gorm/logger" ) type Manager struct { @@ -18,7 +22,18 @@ var manager *Manager func GetManager() *Manager { if manager == nil { manager = &Manager{} - db, err := gorm.Open(sqlite.Open(config.GetConfig().DbPath), &gorm.Config{}) + db, err := gorm.Open(sqlite.Open(config.GetConfig().DbPath), &gorm.Config{ + Logger: logger.New( + log.New(os.Stdout, "\r\n", log.LstdFlags), + lg.Config{ + SlowThreshold: time.Second, + LogLevel: lg.LogLevel(config.GetConfig().LogLevel), + IgnoreRecordNotFoundError: true, + ParameterizedQueries: true, + Colorful: true, + }, + ), + }) if err != nil { log.Fatal(err) From 4e17b26970bd21814cf7d38765c31a5888f6a8ed Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 23:51:57 +0200 Subject: [PATCH 27/33] update readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 665b7c2..8f52bdf 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ systemctl --user start ftsync-watcher.service Choose `FreeTube (synced)` to open FreeTube. -## 🧪 Compilation sources +## 🧪 Compile the sources - [GO 1.23](https://go.dev/dl/) - `build-essential` From 4f0b8a5f0460b567cda9c6653fa918ad10f88df3 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 1 Sep 2024 23:55:52 +0200 Subject: [PATCH 28/33] update readme --- README.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f52bdf..e8b41d4 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,16 @@ It does not require an account, all datas are on your local storage. In case of **FT-Sync** tries to solve this problem. -## ⚠️ Disclaimer +## ⚠️ Disclaimer **FT-Sync is not a project maintained by the FreeTube Team. This project is still experimental and problems may occur. I cannot be held responsible for any possible loss of data.** Feel free to [open an issue here](https://gitnet.fr/deblan/ft-sync/issues) in case of problem. +Before using FT-Sync, backup your datas: + +- `~/.config/FreeTube/history.db` +- `~/.config/FreeTube/profiles.db` +- `~/.config/FreeTube/playlists.db` + ## ⚙️ What are requirements? **FT-Sync** requires a server accessible by all machines running FreeTube (on a local network, through a VPN or on the web). From 9ebe012928f9955a641be2e0411d56de7db26080 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 2 Sep 2024 00:00:59 +0200 Subject: [PATCH 29/33] update readme --- README.md | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e8b41d4..c5021a6 100644 --- a/README.md +++ b/README.md @@ -31,21 +31,22 @@ At each time you want to use FreeTube, you have to pull datas from the server be When FreeTube is restarted, history, playlists and profiles will be updated. ```mermaid + sequenceDiagram participant Client participant Server Note over Client, Server: Only once - Client->>+Server: Send initial history, playlists, profiles + Client->>+Server: Send initial history, playlists, profiles
ftsync-client init Server-->>-Client: Response OK/KO Note over Client, Server: Before launching FreeTube - Client->>+Server: Pull update to date history, playlists, profiles + Client->>+Server: Pull update to date history, playlists, profiles
ftsync-client pull Server-->>-Client: Response datas Client->>+Client: Update databases Note over Client, Server: While FreeTube is running - loop Watch local db updates + loop Watch local db updates
ftsync-client watch Client->>+Server: Send updated history, playlists, profiles Server-->>-Client: Response OK/KO end From 21deabd8c052a02f2dddced635dc5c130acef7db Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 2 Sep 2024 00:07:10 +0200 Subject: [PATCH 30/33] update logo --- logo.svg | 76 +++++++++++++++----------------- logo_small.png | Bin 6296 -> 11554 bytes logo_small.svg | 115 +++++++++++++++++++++++++++---------------------- 3 files changed, 98 insertions(+), 93 deletions(-) diff --git a/logo.svg b/logo.svg index 9970c1a..6afb74a 100644 --- a/logo.svg +++ b/logo.svg @@ -27,9 +27,9 @@ inkscape:deskcolor="#d1d1d1" showgrid="false" showguides="false" - inkscape:zoom="1.0059699" - inkscape:cx="612.84139" - inkscape:cy="259.4511" + inkscape:zoom="1.4226563" + inkscape:cx="504.33827" + inkscape:cy="202.43822" inkscape:window-width="1898" inkscape:window-height="1019" inkscape:window-x="10" @@ -74,41 +74,35 @@ id="path2277" />SYNC + id="path2279" /> diff --git a/logo_small.png b/logo_small.png index 7bcf7828dda8ee0fd146846c9a1d3fc2b46cfc9a..dab4daf60063a4e5e9746c040acdf8b0d38fd585 100644 GIT binary patch literal 11554 zcmcI~byQWs*Y*Vjq)WPyl131aR6#%*k&DJjwd(p?v%F5N99a0zLUz9607 z@LTV@zJK5K#UFRUnX_lkoS8k(v-h)4gqn&R9yS#=1OmZ(BQNt70zuIQKb?mdpyi@G z#t;0#a+23|0rxBJe<-h7H#tBf<;T}LA2l2;Kf0SZTR`01-Fd7XY+cMuoGf@8ovqUL z#i<|=2FM$km+w5j?=5(G=vyoZBM(xz<5T+0jZ%fI$DeU8xU+Y^(rq->ePCW)$kmd) z%f$4Eh!EY7%o9TDk&D{#c;GRtrb+8PSzztxEA78jvmf82`hxDY|8Du;DcZ+Bf4-S< z^*!Zav(algPvqau+M3wr{NRDsJ59}(GBU4b%*kKKd>f&F$;hDcn@5B{Fzq8I!s?1; zVImG^RFq*RluitnX9(pYihF^p%fuA;e_-g`$Md3YI4$s}ZD6x^U@&H&hyJ{G!$LqW z+S(cb>3k?#&2#TvqFIQKTva%O^4dPY7%gpEM@U2!M|O+&DMh7u#4blTM90K6uo(3V8Ncz9=ZZ;Bjr-pX z(ZkLbl60QGm`v)CUHao~q5blhbORr;@32(ipJ0Hl+a0fpniUH=w{*-iULiXpNYQ0{ zt!>c^eKp-kW$xNR<31e5$xz~PX5hyd|0G4&{Bc}YIZd{?&w17^c6jta6C>O#Y!|yv z;dC$F0A)-aSh(+fH9*nD%Jk~X9ioPDbA$ez%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I(21SOvINs#(?8^6C3Wyy| z2lL~I1z~qXaYyG*>CeNwaQ;_>&PNw7{amaV)P_4Z@SXPi?eCeAW9^q!&@Tz-!*#TE z6deBNjK#4SX`L}TYJ9l=1sAgaeA@x94%(E9dI)`4u z(<^UXPtVH0Zw-zq&`MSf9i4-&eKh+g`CrGVu=iqC$ouj!0mLt1jpCT|KZj_qkJwgI zTCOlC-sew^IHc#|1U>3C71ZKzEx<3p0dFhtT%zRqFd?~HezxF$NZoN7NuO8a_5?VN zmWZ&B=jF1c;|SW`xy!Vty>DgO64T#*6q4|!{BdGK2Zby}ClgOc#rSRFrjNCUi9w@EIf*Um55`jH~OO&eNNsKkW8vkMP=}T3Z>^ z{I*h==cFGH&Ed}6uorEhKc0;F+H`Ok?5rd+WvHpIr}x1iwP40AkJ-#y-JZHk5htB2 z9gQ{zBD^R4NP{}JwtPY3z&nYdZN6iC%B-LM|F+KmbyEMg34f&^Ty~%+Z>BFz_^Uvq Mp`xQ)rDz@cKa@O4761SM diff --git a/logo_small.svg b/logo_small.svg index 0029e46..3a7d169 100644 --- a/logo_small.svg +++ b/logo_small.svg @@ -6,11 +6,11 @@ id="Layer_1" x="0px" y="0px" - viewBox="0 0 244.31506 245.65654" + viewBox="0 0 372.44323 370.6958" xml:space="preserve" sodipodi:docname="logo_small.svg" - width="244.31506" - height="245.65654" + width="372.44324" + height="370.6958" inkscape:version="1.2.2 (b0a8486541, 2022-12-01)" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" @@ -27,75 +27,86 @@ inkscape:deskcolor="#d1d1d1" showgrid="false" showguides="true" - inkscape:zoom="1.0059699" - inkscape:cx="583.01942" - inkscape:cy="137.67807" + inkscape:zoom="0.71132814" + inkscape:cx="775.31025" + inkscape:cy="65.370674" inkscape:window-width="1898" inkscape:window-height="1000" inkscape:window-x="10" inkscape:window-y="48" inkscape:window-maximized="1" inkscape:current-layer="Layer_1"> + id="path2279" /> From ff0384a46ccef089b753c937fb47f09189a0950e Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 2 Sep 2024 09:08:29 +0200 Subject: [PATCH 31/33] update readme --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index c5021a6..06d67d6 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,6 @@ At each time you want to use FreeTube, you have to pull datas from the server be When FreeTube is restarted, history, playlists and profiles will be updated. ```mermaid - sequenceDiagram participant Client participant Server From 2a9b78992cf7ac3242d9b265df9f79bdcb96b707 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 2 Sep 2024 14:06:47 +0200 Subject: [PATCH 32/33] update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f36e6b0..bba67ca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ [Unreleased] +# v1.1.0 +## Added +- Add custom logger (fix #1) +## Changed +- The project is renamed + # v1.0.0 ## Added - First release! 😍 From 794be3f7b16ad3ea4abd717404305cad4dd53e69 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Mon, 2 Sep 2024 14:09:03 +0200 Subject: [PATCH 33/33] update changelog --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bba67ca..ddfbd86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,8 @@ # v1.1.0 ## Added -- Add custom logger (fix #1) +- Server: add custom logger (fix #1) +- Server: add verbose options ## Changed - The project is renamed