photosync

package module
v0.0.0-...-a6a6f26 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2015 License: Apache-2.0 Imports: 21 Imported by: 0

README

PhotoSync

Test bed for me to play with go. This will watch a folder and uploading anything new to Flickr, including videos.

photosync

-- import "github.com/Reisender/photosync"

Usage

func LoadConfig
func LoadConfig(configPath *string) error

Load the consumer key and secret in from the config file

func Sync
func Sync(api *FlickrAPI, photos *PhotosMap, dryrun bool) (int, int, error)
type Error
type Error struct {
}

API Error type

func (Error) Error
func (e Error) Error() string
type FlickrAPI
type FlickrAPI struct {
	FlickrUserId string `json:"flickr_user_id"`
}
func NewFlickrAPI
func NewFlickrAPI() *FlickrAPI
func (*FlickrAPI) Download
func (this *FlickrAPI) Download(info *PhotoInfo, p *Photo)
func (*FlickrAPI) GetExtention
func (this *FlickrAPI) GetExtention(info *PhotoInfo) (string, error)
func (*FlickrAPI) GetInfo
func (this *FlickrAPI) GetInfo(p *Photo) (*PhotoInfo, error)
func (*FlickrAPI) GetLogin
func (this *FlickrAPI) GetLogin() (*FlickrUser, error)
func (*FlickrAPI) GetPhotos
func (this *FlickrAPI) GetPhotos(user *FlickrUser) (*PhotosMap, error)
func (*FlickrAPI) GetSizes
func (this *FlickrAPI) GetSizes(p *Photo) (*[]PhotoSize, error)
func (*FlickrAPI) SetTitle
func (this *FlickrAPI) SetTitle(p *Photo, title string) error
func (*FlickrAPI) Upload
func (this *FlickrAPI) Upload(path string, file os.FileInfo) (*FlickrUploadResponse, error)
type FlickrApiResponse
type FlickrApiResponse struct {
	Stat string
	Data struct {
		Page    int
		Pages   int
		Perpage int
		Total   string
		Photos  []Photo `json:"photo"`
	} `json:"photos"`
	User         FlickrUser `json:"user"`
	PhotoDetails PhotoInfo  `json:"photo"`
	SizeData     struct {
		Sizes []PhotoSize `json:"size"`
	} `json:"sizes"`
}
type FlickrUploadResponse
type FlickrUploadResponse struct {
	XMLName xml.Name `xml:"rsp"`
	Status  string   `xml:"stat,attr"`
	PhotoId string   `xml:"photoid"`
}
type FlickrUser
type FlickrUser struct {
	Id       string
	Username struct {
		Content string `json:"_content"`
	} `json:"username"`
}
type OauthConfig
type OauthConfig struct {
	Consumer oauth.Credentials
	Access   oauth.Credentials
}
type Photo
type Photo struct {
	Id       string
	Owner    string
	Secret   string
	Title    string
	Ispublic int `json:"string"`
	Isfriend int `json:"string"`
	Isfamily int `json:"string"`
}
type PhotoInfo
type PhotoInfo struct {
	Rotation       int
	Originalformat string
	Media          string
}
type PhotoSize
type PhotoSize struct {
	Label  string
	Source string
}
type PhotosMap
type PhotosMap map[string]Photo
type PhotosyncConfig
type PhotosyncConfig struct {
	OauthConfig
	WatchDir string `json:"watch_dir"`
}

Documentation

Index

Constants

View Source
const ExifTimeLayout = "2006:01:02 15:04:05"
View Source
const FilenameTimeLayout = "20060102_150405"

time formats

View Source
const FlickrTimeLayout = "2006-01-02 15:04:05"

Variables

This section is empty.

Functions

func FixExif

func FixExif(title string, path string, f os.FileInfo) (string, func(api *FlickrAPI, photoId string), error)

Checks the EXIF data for JPGs and returns the path to either the original or the fixed JPG file. The 2nd return value should be called when use of the JPG is complete. workingFile, done, err := FixExif(...) defer done()

func GetAllExifData

func GetAllExifData(path string) (*[]ExifToolOutput, error)

func LoadConfig

func LoadConfig(configPath *string, config *PhotosyncConfig) error

Load the consumer key and secret in from the config file

func Sync

func Sync(api *FlickrAPI, photos *PhotosMap, videos *PhotosMap, albums *AlbumsMap, opt *Options) (int, int, int, int, error)

Types

type Album

type Album struct {
	Id    string
	Title struct {
		Content string `json:"_content"`
	} `json:"title"`
	PhotoIds []string
	Dirty    bool
}

func (*Album) Append

func (this *Album) Append(photoId string)

func (Album) GetTitle

func (this Album) GetTitle() string

func (*Album) Prepend

func (this *Album) Prepend(photoId string)

func (*Album) Reverse

func (this *Album) Reverse()

type AlbumsMap

type AlbumsMap map[string]*Album

type DynamicValueContext

type DynamicValueContext struct {
	// contains filtered or unexported fields
}

Context for dynamic values in the config

func (*DynamicValueContext) ExifDate

func (this *DynamicValueContext) ExifDate() (string, error)

func (*DynamicValueContext) Folders

func (this *DynamicValueContext) Folders() (string, error)

type Error

type Error struct {
	// contains filtered or unexported fields
}

API Error type

func (Error) Error

func (e Error) Error() string

type ExifToolOutput

type ExifToolOutput struct {
	SourceFile string
	ExifTool   struct {
		Warning string
	}
	Ifd struct {
		Orientation string
		Make        string
		Model       string
		ModifyDate  string
	} `json:"IFD0"`
}

func GetExifData

func GetExifData(path string) (*ExifToolOutput, error)

type FilenameConfig

type FilenameConfig struct {
	Match string `json:"match"`

	Append  string
	Prepend string
	// contains filtered or unexported fields
}

func (*FilenameConfig) GetNewPath

func (this *FilenameConfig) GetNewPath(path string, dirCfg *WatchDirConfig, exif *ExifToolOutput) (string, string, bool)

func (*FilenameConfig) Load

func (this *FilenameConfig) Load() error

type FilenameTimeFormat

type FilenameTimeFormat struct {
	Format  string
	Prefix  []string
	Postfix []string
}

type FlexInt

type FlexInt int

Be more flexible when un-marshaling from json. Unmarshal from int or string.

func (*FlexInt) UnmarshalJSON

func (this *FlexInt) UnmarshalJSON(b []byte) (err error)

type FlickrAPI

type FlickrAPI struct {
	FlickrUserId string `json:"flickr_user_id"`
	// contains filtered or unexported fields
}

func NewFlickrAPI

func NewFlickrAPI(config *PhotosyncConfig) *FlickrAPI

func (*FlickrAPI) AddTags

func (this *FlickrAPI) AddTags(photoId, tags string) error

func (*FlickrAPI) AddToAlbum

func (this *FlickrAPI) AddToAlbum(photoId string, album *Album) error

func (*FlickrAPI) Download

func (this *FlickrAPI) Download(info *PhotoInfo, p *Photo) error

func (*FlickrAPI) GetAlbums

func (this *FlickrAPI) GetAlbums(user *FlickrUser) (*AlbumsMap, error)

func (*FlickrAPI) GetExtention

func (this *FlickrAPI) GetExtention(info *PhotoInfo) (string, error)

func (*FlickrAPI) GetFilenamesConfig

func (this *FlickrAPI) GetFilenamesConfig() []FilenameConfig

func (*FlickrAPI) GetInfo

func (this *FlickrAPI) GetInfo(p *Photo) (*PhotoInfo, error)

func (*FlickrAPI) GetLogin

func (this *FlickrAPI) GetLogin() (*FlickrUser, error)

func (*FlickrAPI) GetPhotos

func (this *FlickrAPI) GetPhotos(user *FlickrUser) (*PhotosMap, error)

func (*FlickrAPI) GetSizes

func (this *FlickrAPI) GetSizes(p *Photo) (*[]PhotoSize, error)

func (*FlickrAPI) GetVideos

func (this *FlickrAPI) GetVideos(user *FlickrUser) (*PhotosMap, error)

func (*FlickrAPI) LoadAlbumPhotos

func (this *FlickrAPI) LoadAlbumPhotos(album *Album) error

func (*FlickrAPI) Search

func (this *FlickrAPI) Search(form *url.Values) (*PhotosMap, error)

func (*FlickrAPI) SetAlbumOrder

func (this *FlickrAPI) SetAlbumOrder(photoSetId string, photoIds []string) error

func (*FlickrAPI) SetAlbumPhoto

func (this *FlickrAPI) SetAlbumPhoto(photoId, photoSetId string) error

func (*FlickrAPI) SetDate

func (this *FlickrAPI) SetDate(photoId, date string) error

func (*FlickrAPI) SetTitle

func (this *FlickrAPI) SetTitle(photo_id, title string) error

func (*FlickrAPI) Upload

func (this *FlickrAPI) Upload(path string, file os.FileInfo) (*FlickrUploadResponse, error)

type FlickrAlbumPhotosResponse

type FlickrAlbumPhotosResponse struct {
	FlickrBaseApiResponse
	Data struct {
		Photos []Photo `json:"photo"`
		// contains filtered or unexported fields
	} `json:"photoset"`
}

func (FlickrAlbumPhotosResponse) Page

func (this FlickrAlbumPhotosResponse) Page() int

func (FlickrAlbumPhotosResponse) Pages

func (this FlickrAlbumPhotosResponse) Pages() int

func (FlickrAlbumPhotosResponse) PerPage

func (this FlickrAlbumPhotosResponse) PerPage() int

func (*FlickrAlbumPhotosResponse) Reset

func (this *FlickrAlbumPhotosResponse) Reset()

func (FlickrAlbumPhotosResponse) Total

func (this FlickrAlbumPhotosResponse) Total() int

type FlickrAlbumsResponse

type FlickrAlbumsResponse struct {
	FlickrBaseApiResponse
	Data struct {
		Albums []Album `json:"photoset"`
		// contains filtered or unexported fields
	} `json:"photosets"`
}

func (FlickrAlbumsResponse) Page

func (this FlickrAlbumsResponse) Page() int

func (FlickrAlbumsResponse) Pages

func (this FlickrAlbumsResponse) Pages() int

func (FlickrAlbumsResponse) PerPage

func (this FlickrAlbumsResponse) PerPage() int

func (*FlickrAlbumsResponse) Reset

func (this *FlickrAlbumsResponse) Reset()

func (FlickrAlbumsResponse) Total

func (this FlickrAlbumsResponse) Total() int

type FlickrApiResponse

type FlickrApiResponse struct {
	FlickrBaseApiResponse
	Data struct {
		Photos []Photo `json:"photo"`
		// contains filtered or unexported fields
	} `json:"photos"`
	User         FlickrUser `json:"user"`
	PhotoDetails PhotoInfo  `json:"photo"`
	SizeData     struct {
		Sizes []PhotoSize `json:"size"`
	} `json:"sizes"`
}

func (FlickrApiResponse) Page

func (this FlickrApiResponse) Page() int

func (FlickrApiResponse) Pages

func (this FlickrApiResponse) Pages() int

func (FlickrApiResponse) PerPage

func (this FlickrApiResponse) PerPage() int

func (*FlickrApiResponse) Reset

func (this *FlickrApiResponse) Reset()

func (FlickrApiResponse) Total

func (this FlickrApiResponse) Total() int

type FlickrBaseApiResponse

type FlickrBaseApiResponse struct {
	Stat string
}

func (FlickrBaseApiResponse) Success

func (this FlickrBaseApiResponse) Success() bool

type FlickrPagedResponse

type FlickrPagedResponse interface {
	Page() int
	Pages() int
	PerPage() int
	Total() int
	Reset()
	Success() bool
}

type FlickrResponse

type FlickrResponse interface {
	Success() bool
}

type FlickrUploadResponse

type FlickrUploadResponse struct {
	XMLName xml.Name `xml:"rsp"`
	Status  string   `xml:"stat,attr"`
	PhotoId string   `xml:"photoid"`
}

type FlickrUser

type FlickrUser struct {
	Id       string
	Username struct {
		Content string `json:"_content"`
	} `json:"username"`
}

type OauthConfig

type OauthConfig struct {
	Consumer oauth.Credentials
	Access   oauth.Credentials
}

type Options

type Options struct {
	ConfigPath  string
	Dryrun      bool
	NoUpload    bool
	Daemon      bool
	RetroTags   bool
	RetroAlbums bool
}

type Photo

type Photo struct {
	Id       string
	Owner    string
	Secret   string
	Title    string
	Ispublic int `json:"string"`
	Isfriend int `json:"string"`
	Isfamily int `json:"string"`
}

type PhotoInfo

type PhotoInfo struct {
	Rotation       int
	Originalformat string
	Media          string
}

type PhotoSet

type PhotoSet struct {
	Id    string
	Title string `json:"title[_content]"`
}

type PhotoSize

type PhotoSize struct {
	Label  string
	Source string
}

type PhotosMap

type PhotosMap map[string]Photo

type PhotosyncConfig

type PhotosyncConfig struct {
	OauthConfig
	Filenames           []FilenameConfig     `json:"filenames"`
	WatchDir            []WatchDirConfig     `json:"directories"`
	FilenameTimeFormats []FilenameTimeFormat `json:"filename_time_formats"`
}

type WatchDirConfig

type WatchDirConfig struct {
	Dir  string
	Tags string

	Albums []string
	// contains filtered or unexported fields
}

func (*WatchDirConfig) CreateTemplates

func (this *WatchDirConfig) CreateTemplates()

func (*WatchDirConfig) GetAlbums

func (this *WatchDirConfig) GetAlbums(context *DynamicValueContext) []string

func (*WatchDirConfig) GetTags

func (this *WatchDirConfig) GetTags(context *DynamicValueContext) (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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