aboutsummaryrefslogtreecommitdiff
path: root/pkg/database/repository/media.go
blob: 6f5b39b5326491e889cca59690c8a1fe00ff4fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package repository

import (
	"context"
	"strings"
	"time"
)

type (
	Media struct {
		ID       uint
		Name     string
		Path     string
		PathHash string
		MIMEType string
	}

	MediaEXIF struct {
		Width           *float64
		Height          *float64
		Description     *string
		Camera          *string
		Maker           *string
		Lens            *string
		DateShot        *time.Time
		Exposure        *float64
		Aperture        *float64
		Iso             *int64
		FocalLength     *float64
		Flash           *int64
		Orientation     *int64
		ExposureProgram *int64
		GPSLatitude     *float64
		GPSLongitude    *float64
	}

	MediaThumbnail struct {
		Path string
	}

	Pagination struct {
		Page int
		Size int
		Path string
	}

	CreateMedia struct {
		Name     string
		Path     string
		PathHash string
		MIMEType string
	}

	MediaRepository interface {
		Create(context.Context, *CreateMedia) error
		Exists(context.Context, string) (bool, error)
		List(context.Context, *Pagination) ([]*Media, error)
		Get(context.Context, string) (*Media, error)
		GetPath(context.Context, string) (string, error)
		GetThumbnailPath(context.Context, string) (string, error)

		ListEmptyEXIF(context.Context, *Pagination) ([]*Media, error)
		GetEXIF(context.Context, uint) (*MediaEXIF, error)
		CreateEXIF(context.Context, uint, *MediaEXIF) error

		ListEmptyThumbnail(context.Context, *Pagination) ([]*Media, error)
		GetThumbnail(context.Context, uint) (*MediaThumbnail, error)
		CreateThumbnail(context.Context, uint, *MediaThumbnail) error
	}
)

func (m *Media) IsVideo() bool {
	return strings.HasPrefix(m.MIMEType, "video")
}