started implementation / ideas
This commit is contained in:
parent
914e07bf05
commit
aacb7377d9
60
main.go
Normal file
60
main.go
Normal 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)")
|
||||||
|
}
|
31
pkg/localFileStructure/nodeBuilder.go
Normal file
31
pkg/localFileStructure/nodeBuilder.go
Normal 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
|
||||||
|
}
|
8
pkg/localFileStructure/types.go
Normal file
8
pkg/localFileStructure/types.go
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
package localFileStructure
|
||||||
|
|
||||||
|
type FileNode struct {
|
||||||
|
key string
|
||||||
|
name string
|
||||||
|
isDir bool
|
||||||
|
}
|
||||||
|
|
13
pkg/piwigo/types.go
Normal file
13
pkg/piwigo/types.go
Normal 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
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user