Skip to content

Commit

Permalink
draft
Browse files Browse the repository at this point in the history
  • Loading branch information
tommyblue committed Nov 25, 2024
1 parent de25c15 commit d60041d
Show file tree
Hide file tree
Showing 7 changed files with 18,102 additions and 6 deletions.
21 changes: 21 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,27 @@ func (w *Worker) albumImages(firstURI string, albumPath string) ([]albumImage, e
// Loop over response in inject the albumPath and then append to the images
for _, i := range a.Response.AlbumImage {
i.AlbumPath = albumPath
log.Debugf("Component => `%s`", i.Uris.Components.Uri)
if w.cfg.DownloadRaw && i.Uris.Components.Uri != "" {
var c imageComponent
if err := w.req.get(i.Uris.Components.Uri, &c); err != nil {
log.Errorf("error getting image components from %s. Error: %v", i.Uris.Components.Uri, err)
continue
}

for _, comp := range c.Response.Component {
if comp.ComponentType == componentTypeRaw {
log.Debugf("Found raw image for %s: %s", i.FileName, comp.DownloadUrl)
i.ArchivedUri = comp.DownloadUrl
i.ArchivedSize = comp.FileSize
i.FileName = comp.FileName
i.ArchivedMD5 = comp.MD5
break

}
}
}

if err := i.buildFilename(w.filenameTmpl); err != nil {
return nil, fmt.Errorf("cannot build image filename: %v", err)
}
Expand Down
67 changes: 67 additions & 0 deletions cmd/component/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package main

import (
"encoding/json"
"fmt"
"log"
"os"
)

func main() {
fmt.Printf("Reading %s", os.Args[1])
f, err := os.ReadFile(os.Args[1])
if err != nil {
log.Fatal("cannot read file: %v", err)

Check failure on line 14 in cmd/component/main.go

View workflow job for this annotation

GitHub Actions / Build

log.Fatal call has possible Printf formatting directive %v
}

var c albumImagesResponse

if err := json.Unmarshal(f, &c); err != nil {
log.Fatalf("cannot unmarshal: %v", err)
}

log.Printf("%+v", c)
}

type albumImagesResponse struct {
Response struct {
URI string `json:"Uri"`
AlbumImage []albumImage `json:"AlbumImage"`
Pages struct {
NextPage string `json:"NextPage"`
} `json:"Pages"`
} `json:"Response"`
}

type albumImage struct {
AlbumPath string // From album.URLPath
FileName string `json:"FileName"`
ImageKey string `json:"ImageKey"` // Use as unique ID if FileName is empty
ArchivedMD5 string `json:"ArchivedMD5"`
ArchivedSize int64 `json:"ArchivedSize"`
ArchivedUri string `json:"ArchivedUri"`
IsVideo bool `json:"IsVideo"`
Processing bool `json:"Processing"`
UploadKey string `json:"UploadKey"`
DateTimeOriginal string `json:"DateTimeOriginal"`
Caption string `json:"Caption"`
DateTimeUploaded string `json:"DateTimeUploaded"`
Keywords string `json:"Keywords"`
Latitude string `json:"Latitude"`
Longitude string `json:"Longitude"`
Status string `json:"Status"`
SubStatus string `json:"SubStatus"`
Uris struct {
ImageMetadata struct {
Uri string `json:"Uri"`
} `json:"ImageMetadata"`
LargestVideo struct {
Uri string `json:"Uri"`
} `json:"LargestVideo"`
Components struct {
Uri string `json:"Uri"`
} `json:"Components"`
} `json:"Uris"`

builtFilename string // The final filename, after template replacements
}
Loading

0 comments on commit d60041d

Please sign in to comment.