started implementation / ideas

This commit is contained in:
Philipp Häfelfinger 2019-02-23 00:58:32 +01:00
parent 914e07bf05
commit aacb7377d9
4 changed files with 112 additions and 0 deletions

60
main.go Normal file
View File

@ -0,0 +1,60 @@
package main
import (
"flag"
"haefelfinger.net/piwigo/DirectoriesToAlbums/pkg/localFileStructure"
"log"
"os"
)
func main() {
flag.Parse()
root := flag.Arg(0)
InitializeLog()
AuthenticateToPiwigo()
ScanLocalDirectories(root)
GetAllCategoriesFromServer()
FindMissingAlbums()
CreateMissingAlbums()
FindMissingImages()
UploadImages()
}
func InitializeLog() {
//TODO: make log configurable to file instead of console
log.SetOutput(os.Stdout)
log.Println("Starting Piwigo directories to albums...")
}
func AuthenticateToPiwigo() {
log.Println("Authenticating to piwigo server (NotImplemented)")
}
func ScanLocalDirectories(root string) {
fileNodes := localFileStructure.ScanLocalFileStructure(root)
log.Printf("filepath.Walk() returned %v\n", fileNodes)
}
func GetAllCategoriesFromServer() {
// get all categories from server and flatten structure to match directory names
// 2018/2018 album blah
log.Println("Loading all categories from the server (NotImplemented)")
}
func FindMissingAlbums() {
log.Println("Looking up missing albums (NotImplemented)")
}
func CreateMissingAlbums() {
log.Println("Creating missing albums (NotImplemented)")
}
func FindMissingImages() {
log.Println("Finding missing images (NotImplemented)")
}
func UploadImages() {
log.Println("Uploading missing images (NotImplemented)")
}

View File

@ -0,0 +1,31 @@
package localFileStructure
import (
"os"
"path/filepath"
)
func ScanLocalFileStructure(path string) map[string]FileNode {
fileMap := make(map[string]FileNode)
err := filepath.Walk(path, func(p string, info os.FileInfo, err error) error {
if path == p {
return nil
}
//TODO: Only allow jpg and png files here
fileMap[p] = FileNode{
key:p,
name:info.Name(),
isDir:info.IsDir(),
}
return nil;
})
if err != nil {
panic(err)
}
return fileMap
}

View File

@ -0,0 +1,8 @@
package localFileStructure
type FileNode struct {
key string
name string
isDir bool
}

13
pkg/piwigo/types.go Normal file
View File

@ -0,0 +1,13 @@
package piwigo
type PiwigoConfig struct {
url string
username string
password string
}
type PiwigoCategory struct {
id int
name string
key string
}