upload

package
v0.1.50 Latest Latest
Warning

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

Go to latest
Published: May 22, 2025 License: MIT Imports: 43 Imported by: 0

Documentation

Index

Constants

View Source
const SPREADSHEET_ID = "1e2gK0GgWN4PxeZcazUvxtlhYGzg2lZsZEkphqu9Jplc"

Variables

View Source
var Funcs = template.FuncMap{

	"upper": func(s string) string { return strings.ToUpper(s) },
	"lower": func(s string) string { return strings.ToLower(s) },

	"commas": func(v int) string {
		sign := ""

		if v == math.MinInt64 {
			return "-9,223,372,036,854,775,808"
		}

		if v < 0 {
			sign = "-"
			v = 0 - v
		}

		parts := []string{"", "", "", "", "", "", ""}
		j := len(parts) - 1

		for v > 999 {
			parts[j] = strconv.FormatInt(int64(v%1000), 10)
			switch len(parts[j]) {
			case 2:
				parts[j] = "0" + parts[j]
			case 1:
				parts[j] = "00" + parts[j]
			}
			v = v / 1000
			j--
		}
		parts[j] = strconv.Itoa(int(v))
		return sign + strings.Join(parts[j:], ",")
	},

	"add": func(a, b int) int { return a + b },
	"sub": func(a, b int) int { return a - b },

	"date": func(t time.Time) string {
		day := t.Day()
		suffix := "th"
		switch day % 10 {
		case 1:
			if day != 11 {
				suffix = "st"
			}
		case 2:
			if day != 12 {
				suffix = "nd"
			}
		case 3:
			if day != 13 {
				suffix = "rd"
			}
		}
		return fmt.Sprintf("%s %d%s", t.Format("January"), day, suffix)
	},

	"dict": func(values ...interface{}) (map[string]interface{}, error) {
		if len(values)%2 != 0 {
			return nil, errors.New("invalid dict call")
		}
		dict := make(map[string]interface{}, len(values)/2)
		for i := 0; i < len(values); i += 2 {
			key, ok := values[i].(string)
			if !ok {
				return nil, errors.New("dict keys must be strings")
			}
			dict[key] = values[i+1]
		}
		return dict, nil
	},
}
View Source
var MetaRegex = regexp.MustCompile(`\n{(.*)}$`)

Functions

This section is empty.

Types

type Cell added in v0.1.29

type Cell struct{ Value any }

func (Cell) Bool added in v0.1.29

func (c Cell) Bool() bool

func (Cell) Empty added in v0.1.29

func (c Cell) Empty() bool

func (Cell) Float added in v0.1.29

func (c Cell) Float() float64

func (Cell) Int added in v0.1.29

func (c Cell) Int() int

func (Cell) Nil added in v0.1.29

func (c Cell) Nil() bool

func (Cell) String added in v0.1.29

func (c Cell) String() string

func (Cell) Time added in v0.1.29

func (c Cell) Time() time.Time

func (Cell) Zero added in v0.1.29

func (c Cell) Zero() bool

type Change

type Change struct {
	Before, After string
}

type Changes

type Changes struct {
	Changed                                      bool
	PrivacyStatus, PublishAt, Description, Title Change
}

func Apply

func Apply(item *Item, video *youtube.Video) (changes Changes, err error)

type DropboxKeys added in v0.1.36

type DropboxKeys int
const (
	DropboxClientID     DropboxKeys = 1
	DropboxClientSecret DropboxKeys = 2
	DropboxRefreshToken DropboxKeys = 3
)

type Expedition

type Expedition struct {
	RowId              int
	Ref                string
	Name               string
	Process            bool
	VideosFolder       string
	ThumbnailsFolder   string
	VideosDropbox      string
	ThumbnailsDropbox  string
	ExpeditionPlaylist bool
	SectionPlaylists   bool
	Data               map[string]Cell
	SectionsByRef      map[string]*Section
	Sections           []*Section
	Items              []*Item
	Templates          *template.Template
	PlaylistId         string
	Playlist           *youtube.Playlist
	ItemSheet          *Sheet
}

func (*Expedition) GetExpedition

func (e *Expedition) GetExpedition() *Expedition

func (*Expedition) GetItems

func (e *Expedition) GetItems() []*Item

func (*Expedition) GetMetadata

func (e *Expedition) GetMetadata() (string, error)

func (*Expedition) GetPlaylist

func (e *Expedition) GetPlaylist() *youtube.Playlist

func (*Expedition) GetPlaylistId

func (e *Expedition) GetPlaylistId() string

func (*Expedition) HasThumbnails added in v0.1.45

func (e *Expedition) HasThumbnails() bool

func (*Expedition) String added in v0.1.29

func (e *Expedition) String() string

type GeminiRequest added in v0.1.48

type GeminiRequest struct {
	Name        string              `json:"title"`       // expedition.name
	Description string              `json:"description"` // expedition.description
	Items       []GeminiRequestItem `json:"items"`
}

type GeminiRequestItem added in v0.1.48

type GeminiRequestItem struct {
	Type        string `json:"type"`
	Section     string `json:"section"`
	Key         int    `json:"key"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Thumbnail   string `json:"thumbnail"`
	Landmarks   string `json:"landmarks"`
	Transcript  string `json:"transcript"`
}

type GeminiResponseItem added in v0.1.48

type GeminiResponseItem struct {
	Type        string `json:"type"`
	Section     string `json:"section"`
	Key         int    `json:"key"`
	Title       string `json:"title"`
	Description string `json:"description"`
	Thumbnail   string `json:"thumbnail"`
}

type Global

type Global struct {
	Preview                  bool
	Production               bool
	Thumbnails               bool
	Titles                   bool
	PreviewThumbnailsFolder  string
	PreviewThumbnailsDropbox string
	Data                     map[string]Cell
}

type HasPlaylist

type HasPlaylist interface {
	GetPlaylistId() string
	GetPlaylist() *youtube.Playlist
	GetExpedition() *Expedition
	GetItems() []*Item
	GetMetadata() (string, error)
	String() string
}

type Item

type Item struct {
	RowId                int
	Type                 string
	Key                  int
	Video                bool
	Template             string
	Ready                bool
	DoThumbnail          bool
	Release              time.Time
	From, To             Location
	Via                  []Location
	Section              *Section
	SectionRef           string
	Expedition           *Expedition
	Data                 map[string]Cell
	VideoGoogleDrive     *drive.File
	ThumbnailGoogleDrive *drive.File
	VideoDropbox         *files.FileMetadata
	ThumbnailDropbox     *files.FileMetadata
	YoutubeId            string
	YoutubeVideo         *youtube.Video
	YoutubeTranscript    string
}

func (*Item) Metadata

func (item *Item) Metadata() (string, error)

func (*Item) Set added in v0.1.46

func (item *Item) Set(s *Service, column string, value any, force bool) error

func (*Item) String

func (item *Item) String() string

type Location

type Location struct {
	Name      string
	Elevation int
}

type P added in v0.1.43

type P struct {
	XMLName xml.Name `xml:"p"`
	Content string   `xml:",chardata"`
}

type PlaylistMeta

type PlaylistMeta struct {
	Version    int    `json:"v"`
	Expedition string `json:"e"`
	Section    string `json:"s"`
}

type Section

type Section struct {
	RowId      int
	Expedition *Expedition
	Items      []*Item
	Ref        string
	Name       string
	Data       map[string]Cell
	PlaylistId string
	Playlist   *youtube.Playlist
}

func (*Section) GetExpedition

func (s *Section) GetExpedition() *Expedition

func (*Section) GetItems

func (s *Section) GetItems() []*Item

func (*Section) GetMetadata

func (s *Section) GetMetadata() (string, error)

func (*Section) GetPlaylist

func (s *Section) GetPlaylist() *youtube.Playlist

func (*Section) GetPlaylistId

func (s *Section) GetPlaylistId() string

func (*Section) String added in v0.1.29

func (s *Section) String() string

type Service

type Service struct {
	Global               *Global
	StorageService       StorageServices
	ChannelId            string
	SheetsService        *sheets.Service
	YoutubeService       *youtube.Service
	YoutubeAccessToken   string
	ServiceAccountClient *http.Client
	DriveService         *drive.Service
	DropboxConfig        *dropbox.Config
	Spreadsheet          *sheets.Spreadsheet
	Sheets               map[string]*Sheet
	Expeditions          map[string]*Expedition
	YoutubePlaylists     map[string]*youtube.Playlist
	VideoPreviewData     map[*Item]map[string]any
	PlaylistPreviewData  map[HasPlaylist]map[string]any
}

func New

func New(channelId string) *Service

func (*Service) ClearDropboxPreviewFolder added in v0.1.34

func (s *Service) ClearDropboxPreviewFolder() error

func (*Service) ClearGoogleDrivePreviewFolder added in v0.1.35

func (s *Service) ClearGoogleDrivePreviewFolder() error

func (*Service) ClearPreviewSheets added in v0.1.48

func (s *Service) ClearPreviewSheets() error

func (*Service) CreateOrUpdatePlaylists

func (s *Service) CreateOrUpdatePlaylists() error

func (*Service) CreateOrUpdateVideos

func (s *Service) CreateOrUpdateVideos(ctx context.Context) error

func (*Service) FindDropboxFiles added in v0.1.34

func (s *Service) FindDropboxFiles() error

func (*Service) FindGoogleDriveFiles added in v0.1.35

func (s *Service) FindGoogleDriveFiles() error

func (*Service) GenerateAiTitles added in v0.1.48

func (s *Service) GenerateAiTitles(ctx context.Context) error

func (*Service) GetAllSheetsData

func (s *Service) GetAllSheetsData() error

func (*Service) GetPlaylistsData

func (s *Service) GetPlaylistsData() error

func (*Service) GetSheetData

func (s *Service) GetSheetData(titles ...string) error

func (*Service) GetVideosCaptions added in v0.1.43

func (s *Service) GetVideosCaptions() error

func (*Service) GetVideosData

func (s *Service) GetVideosData() error

func (*Service) InitDropboxService added in v0.1.34

func (s *Service) InitDropboxService(ctx context.Context) error

func (*Service) InitGoogleDriveService added in v0.1.35

func (s *Service) InitGoogleDriveService() error

func (*Service) InitSheetsService

func (s *Service) InitSheetsService() error

func (*Service) InitialiseServiceAccount

func (s *Service) InitialiseServiceAccount(ctx context.Context) error

func (*Service) InitialiseYoutubeAuthentication

func (s *Service) InitialiseYoutubeAuthentication(ctx context.Context) error

func (*Service) ParseExpeditions

func (s *Service) ParseExpeditions() error

func (*Service) ParseGlobal

func (s *Service) ParseGlobal() error

func (*Service) ParseItems

func (s *Service) ParseItems() error

func (*Service) ParseLinkedData

func (s *Service) ParseLinkedData() error

func (*Service) ParseSections

func (s *Service) ParseSections() error

func (*Service) ParseTemplates

func (s *Service) ParseTemplates() error

func (*Service) ResumePartialUpload

func (s *Service) ResumePartialUpload(ctx context.Context) error

func (*Service) Start

func (s *Service) Start(ctx context.Context) error

func (*Service) StorePlaylistPreview

func (s *Service) StorePlaylistPreview(parent HasPlaylist, name, before, after string)

func (*Service) StorePlaylistPreviewDeleted

func (s *Service) StorePlaylistPreviewDeleted(parent HasPlaylist)

func (*Service) StorePlaylistPreviewOps

func (s *Service) StorePlaylistPreviewOps(parent HasPlaylist, name string, ops []string)

func (*Service) StoreVideoPreview

func (s *Service) StoreVideoPreview(item *Item, name, before, after string)

func (*Service) UpdateThumbnails

func (s *Service) UpdateThumbnails() error

func (*Service) WritePlaylistsPreview

func (s *Service) WritePlaylistsPreview() error

func (*Service) WriteVideosPreview

func (s *Service) WriteVideosPreview() error

type Sheet

type Sheet struct {
	Spreadsheet *sheets.Spreadsheet
	Name        string
	Expedition  *Expedition
	Headers     []string
	Data        []map[string]Cell
	DataByRef   map[string]map[string]Cell
}

func (*Sheet) Clear added in v0.1.46

func (s *Sheet) Clear(service *sheets.Service, rowId int, column string) error

func (*Sheet) FullName

func (s *Sheet) FullName() string

func (*Sheet) Set added in v0.1.46

func (s *Sheet) Set(service *sheets.Service, rowId int, column string, value any, force bool) error

type StorageServices added in v0.1.34

type StorageServices int
const (
	GoogleDriveStorage StorageServices = 1
	DropboxStorage     StorageServices = 2
)

type VideoMeta

type VideoMeta struct {
	Version    int    `json:"v"`
	Expedition string `json:"e"`
	Type       string `json:"t"`
	Key        int    `json:"k"`
}

type YoutubeFields

type YoutubeFields struct {
	PrivacyStatus        string    // privacy status before PublishAt time. After this time, it is always public.
	PublishAt            time.Time // no default
	CategoryId           string
	ChannelId            string
	DefaultAudioLanguage string
	DefaultLanguage      string
	LiveBroadcastContent string
	Description          string // no default
	Title                string // no default
}

func DefaultYoutubeFields

func DefaultYoutubeFields() YoutubeFields

func (*YoutubeFields) Apply

func (y *YoutubeFields) Apply(video *youtube.Video) Changes

Jump to

Keyboard shortcuts

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