media_items

package
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// NullMediaItem is a zero value MediaItem.
	NullMediaItem = MediaItem{}

	ErrMediaItemNotFound = errors.New("media item not found")
)

Functions

This section is empty.

Types

type HttpMediaItemsService

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

HttpMediaItemsService implements a media items Google Photos client.

func NewHttpMediaItemsService

func NewHttpMediaItemsService(authenticatedClient *http.Client) (*HttpMediaItemsService, error)

NewHttpMediaItemsService returns a media items Google Photos client. The authenticatedClient should have all oAuth credentials in place.

func (HttpMediaItemsService) Create

func (ms HttpMediaItemsService) Create(ctx context.Context, mediaItem SimpleMediaItem) (MediaItem, error)

Create creates a media item in the repository. By default the media item will be added to the end of the library.

func (HttpMediaItemsService) CreateMany

func (ms HttpMediaItemsService) CreateMany(ctx context.Context, mediaItems []SimpleMediaItem) ([]MediaItem, error)

CreateMany creates one or more media items in the repository. By default the media item(s) will be added to the end of the library.

func (HttpMediaItemsService) CreateManyToAlbum

func (ms HttpMediaItemsService) CreateManyToAlbum(ctx context.Context, albumId string, mediaItems []SimpleMediaItem) ([]MediaItem, error)

CreateManyToAlbum creates one or more media item(s) in the repository. If an album id is specified, the media item(s) are also added to the album. By default the media item(s) will be added to the end of the library or album.

func (HttpMediaItemsService) CreateToAlbum

func (ms HttpMediaItemsService) CreateToAlbum(ctx context.Context, albumId string, mediaItem SimpleMediaItem) (MediaItem, error)

CreateToAlbum creates a media item in the repository. If an album id is specified, the media item is also added to the album. By default the media item will be added to the end of the library or album.

func (HttpMediaItemsService) Get

func (ms HttpMediaItemsService) Get(ctx context.Context, mediaItemId string) (*MediaItem, error)

Get returns the media item specified based on a given media item id. It will return ErrMediaItemNotFound if the media item id does not exist.

func (HttpMediaItemsService) ListByAlbum

func (ms HttpMediaItemsService) ListByAlbum(ctx context.Context, albumId string) ([]MediaItem, error)

ListByAlbum list all media items in the specified album.

type MediaItem

type MediaItem struct {
	ID            string
	Description   string
	ProductURL    string
	BaseURL       string
	MimeType      string
	MediaMetadata MediaMetadata
	Filename      string
}

MediaItem represents of a media item (such as a photo or video) in Google Photos. See: https://developers.google.com/photos/library/reference/rest/v1/mediaItems

type MediaMetadata

type MediaMetadata struct {
	CreationTime string
	Width        string
	Height       string
}

MediaMetadata represents metadata for a media item. See: https://developers.google.com/photos/library/reference/rest/v1/mediaItems

type PhotosLibraryClient

type PhotosLibraryClient interface {
	BatchCreate(batchcreatemediaitemsrequest *photoslibrary.BatchCreateMediaItemsRequest) *photoslibrary.MediaItemsBatchCreateCall
	Get(mediaItemId string) *photoslibrary.MediaItemsGetCall
	Search(searchmediaitemsrequest *photoslibrary.SearchMediaItemsRequest) *photoslibrary.MediaItemsSearchCall
}

PhotosLibraryClient represents a media items service using `gphotosuploader/googlemirror/api/photoslibrary`.

type PhotosLibraryMediaItemsRepository added in v2.1.0

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

PhotosLibraryMediaItemsRepository represents a media items Google Photos repository.

func NewPhotosLibraryClient

func NewPhotosLibraryClient(authenticatedClient *http.Client) (*PhotosLibraryMediaItemsRepository, error)

NewPhotosLibraryClient returns a Repository using PhotosLibrary service.

func NewPhotosLibraryClientWithURL added in v2.1.0

func NewPhotosLibraryClientWithURL(authenticatedClient *http.Client, url string) (*PhotosLibraryMediaItemsRepository, error)

NewPhotosLibraryClientWithURL returns a Repository using PhotosLibrary service with a custom URL.

func (PhotosLibraryMediaItemsRepository) CreateMany added in v2.1.0

func (r PhotosLibraryMediaItemsRepository) CreateMany(ctx context.Context, mediaItems []SimpleMediaItem) ([]MediaItem, error)

CreateMany creates one or more media items in the repository. By default the media item(s) will be added to the end of the library.

func (PhotosLibraryMediaItemsRepository) CreateManyToAlbum added in v2.1.0

func (r PhotosLibraryMediaItemsRepository) CreateManyToAlbum(ctx context.Context, albumId string, mediaItems []SimpleMediaItem) ([]MediaItem, error)

CreateManyToAlbum creates one or more media item(s) in the repository. If an album id is specified, the media item(s) are also added to the album. By default the media item(s) will be added to the end of the library or album.

func (PhotosLibraryMediaItemsRepository) Get added in v2.1.0

Get returns the media item specified based on a given media item id.

func (PhotosLibraryMediaItemsRepository) ListByAlbum added in v2.1.0

func (r PhotosLibraryMediaItemsRepository) ListByAlbum(ctx context.Context, albumId string) ([]MediaItem, error)

ListByAlbum list all media items in the specified album.

func (PhotosLibraryMediaItemsRepository) URL added in v2.1.0

URL returns the media items repository url.

type Repository

type Repository interface {
	CreateMany(ctx context.Context, mediaItems []SimpleMediaItem) ([]MediaItem, error)
	CreateManyToAlbum(ctx context.Context, albumId string, mediaItems []SimpleMediaItem) ([]MediaItem, error)
	Get(ctx context.Context, itemId string) (*MediaItem, error)
	ListByAlbum(ctx context.Context, albumId string) ([]MediaItem, error)
}

Repository represents a media items repository.

type SimpleMediaItem

type SimpleMediaItem struct {
	UploadToken string
	FileName    string
}

SimpleMediaItem represents a simple media item to be created in Google Photos via an upload token. See: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/batchCreate

Jump to

Keyboard shortcuts

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