metadata

package
v0.1.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 9, 2026 License: GPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package metadata defines Go types matching the Google Photos Takeout JSON schema.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FailedEntry

type FailedEntry struct {
	MissingEntry
	Error string `json:"error"`
}

FailedEntry is a recovery entry annotated with an error reason.

type GeoData

type GeoData struct {
	Latitude      float64 `json:"latitude"`
	Longitude     float64 `json:"longitude"`
	Altitude      float64 `json:"altitude"`
	LatitudeSpan  float64 `json:"latitudeSpan"`
	LongitudeSpan float64 `json:"longitudeSpan"`
}

GeoData holds GPS coordinates and altitude as they appear in Takeout JSON.

func (GeoData) IsZero

func (g GeoData) IsZero() bool

IsZero returns true if the coordinates are both exactly 0.0 (no GPS data).

type MissingEntry

type MissingEntry struct {
	Title          string `json:"title"`
	URL            string `json:"url"`
	PhotoTakenDate string `json:"photoTakenDate"`
	SourceFolder   string `json:"sourceFolder"`
}

MissingEntry represents one record in the missing-files.json report.

type Person

type Person struct {
	Name string `json:"name"`
}

Person represents a tagged face in the photo.

type Photo

type Photo struct {
	Title              string    `json:"title"`
	Description        string    `json:"description"`
	ImageViews         string    `json:"imageViews"`
	CreationTime       Timestamp `json:"creationTime"`
	PhotoTakenTime     Timestamp `json:"photoTakenTime"`
	GeoData            GeoData   `json:"geoData"`
	GeoDataExif        GeoData   `json:"geoDataExif"`
	People             []Person  `json:"people"`
	URL                string    `json:"url"`
	GooglePhotosOrigin *struct {
		MobileUpload *struct {
			DeviceFolder *struct {
				LocalFolderName string `json:"localFolderName"`
			} `json:"deviceFolder"`
			DeviceType string `json:"deviceType"`
		} `json:"mobileUpload"`
	} `json:"googlePhotosOrigin"`
}

Photo is the top-level structure of a Google Photos .json metadata file.

func ParseFile

func ParseFile(path string) (*Photo, error)

ParseFile reads and parses a Takeout JSON metadata file.

func (*Photo) BestGeo

func (p *Photo) BestGeo() GeoData

BestGeo returns GeoDataExif if it has data, otherwise falls back to GeoData.

func (*Photo) Keywords

func (p *Photo) Keywords() []string

Keywords returns a deduplicated list of people names suitable for EXIF keyword tags.

type Timestamp

type Timestamp struct {
	Timestamp string `json:"timestamp"`
	Formatted string `json:"formatted"`
}

Timestamp is a Google Photos timestamp with a Unix epoch value stored as a string.

func (Timestamp) Unix

func (t Timestamp) Unix() int64

Unix returns the Unix timestamp as int64. Returns 0 on parse error.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL