data

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SubscriptionDiff

func SubscriptionDiff(subs []Subscription) (Add []string, Remove []string)

SubscriptionDiff takes in a slice of Subscription and returns a separated string slice of podcasts that are to be added or removed. https://github.com/gpodder/mygpo/blob/e20f107009bd07e8baf226a48131fc1b1e0383ff/mygpo/subscriptions/__init__.py#L149-L167

Types

type CustomTimestamp

type CustomTimestamp struct {
	time.Time
}

CustomTimestamp is to handle ISO 8601 timestamp for unmarshalling

func (CustomTimestamp) MarshalJSON

func (c CustomTimestamp) MarshalJSON() ([]byte, error)

func (*CustomTimestamp) UnmarshalJSON

func (c *CustomTimestamp) UnmarshalJSON(b []byte) error

type DataInterface

type DataInterface interface {
	AddUser(string, string, string, string) error
	CheckUserPassword(string, string) bool
	AddSubscriptionHistory(Subscription) error
	RetrieveSubscriptionHistory(string, string, time.Time) ([]Subscription, error)
	AddEpisodeActionHistory(username string, e EpisodeAction) error
	RetrieveEpisodeActionHistory(username string, deviceId string, since time.Time) ([]EpisodeAction, error)

	// Devices
	RetrieveDevices(username string) ([]Device, error)
	AddDevice(username string, deviceName string, caption string, deviceType string) (int, error)
	UpdateOrCreateDevice(username string, deviceName string, caption string, deviceType string) (int, error)
	RetrieveAllDeviceSubscriptions(username string) (string, error)
	RetrieveDeviceSubscriptions(username string, deviceNme string) (string, error)
	GetDeviceIdFromName(deviceName string, username string) (int, error)

	// sync
	AddSyncGroup(deviceIds []string, username string) error
	StopDeviceSync(deviceName string, username string) error
	GetDeviceSyncGroupIds(username string) ([]int, error)
	GetDevicesInSyncGroupFromDeviceId(deviceId int) ([]int, error)
	GetDeviceNameFromDeviceSyncGroupId(deviceId int) ([]string, error)
	GetNotSyncedDevices(username string) ([]string, error)
}

type Device

type Device struct {
	User    *User  `json:"user"`
	Id      int    `json:"id"`
	Name    string `json:"name"`
	Type    string `json:"type"`
	Caption string `json:"caption"` // To be deprecated
}

type EpisodeAction

type EpisodeAction struct {
	Podcast   string          `json:"podcast"`
	Episode   string          `json:"episode"`
	Device    string          `json:"device"`
	Devices   []int           `json:"devices"`
	Action    string          `json:"action"`
	Position  int             `json:"position"`
	Started   int             `json:"started"`
	Total     int             `json:"total"`
	Timestamp CustomTimestamp `json:"timestamp"`
}

type SQLite

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

func NewSQLite

func NewSQLite(file string) *SQLite

func (*SQLite) AddDevice

func (s *SQLite) AddDevice(username string, deviceName string, caption string, deviceType string) (int, error)

AddDevice creates a new Device and returns the id of the device and any error

func (*SQLite) AddEpisodeActionHistory

func (l *SQLite) AddEpisodeActionHistory(username string, e EpisodeAction) error

func (*SQLite) AddSubscriptionHistory

func (s *SQLite) AddSubscriptionHistory(sub Subscription) error

AddSubscriptionHistory adds and updates subscription

func (*SQLite) AddSyncGroup added in v0.2.0

func (s *SQLite) AddSyncGroup(device_names []string, username string) error

AddSyncGroup takes in a slice of device_ids and add them to a SyncGroup if they do not exist. Returns error if it already existed.

Each device can only have one sync group at a time. Sync group's purpose is to link devices together so that any new podcast subscriptions will always be setup and installed on each device

func (*SQLite) AddUser

func (s *SQLite) AddUser(username, password, email, name string) error

func (*SQLite) CheckUserPassword

func (s *SQLite) CheckUserPassword(username, password string) bool

func (*SQLite) GetDB added in v0.2.0

func (s *SQLite) GetDB() *sql.DB

func (*SQLite) GetDeviceIdFromName

func (s *SQLite) GetDeviceIdFromName(deviceName string, username string) (int, error)

func (*SQLite) GetDeviceNameFromDeviceSyncGroupId added in v0.2.0

func (s *SQLite) GetDeviceNameFromDeviceSyncGroupId(id int) ([]string, error)

GetDeviceNameFromDeviceSyncGroupId takes in a device_sync_group_id and returns a string slice of device names that belongs to the group

func (*SQLite) GetDeviceSyncGroupIds added in v0.2.0

func (s *SQLite) GetDeviceSyncGroupIds(username string) ([]int, error)

GetDeviceSyncGroupIds takes in a username and returns a SyncStatus and error

func (*SQLite) GetDevicesFromUsername

func (s *SQLite) GetDevicesFromUsername(username string) ([]string, error)

GetDevicesFromUsername returns a list of device names that belongs to username

func (*SQLite) GetDevicesInSyncGroupFromDeviceId added in v0.2.0

func (s *SQLite) GetDevicesInSyncGroupFromDeviceId(deviceId int) ([]int, error)

GetDevicesInSyncGroupFromDeviceId takes in a deviceId and returns a list of deviceIds that belongs to the same syncgroup including itself

func (*SQLite) GetNotSyncedDevices added in v0.2.0

func (s *SQLite) GetNotSyncedDevices(username string) ([]string, error)

func (*SQLite) GetUserIdFromName

func (s *SQLite) GetUserIdFromName(username string) (int, error)

func (*SQLite) RetrieveAllDeviceSubscriptions

func (s *SQLite) RetrieveAllDeviceSubscriptions(username string) (string, error)

RetrieveAllDeviceSubscriptions takes in a username and returns an OPML file of all the RSS feeds that the user was subscribed to on the platform

func (*SQLite) RetrieveDeviceSubscriptions

func (s *SQLite) RetrieveDeviceSubscriptions(username string, deviceName string) (string, error)

RetrieveDeviceSubscriptions takes in a username and devicename and returns the OPML of its subscriptions

func (*SQLite) RetrieveDevices

func (s *SQLite) RetrieveDevices(username string) ([]Device, error)

func (*SQLite) RetrieveEpisodeActionHistory

func (l *SQLite) RetrieveEpisodeActionHistory(username string, deviceId string, since time.Time) ([]EpisodeAction, error)

func (*SQLite) RetrieveSubscriptionHistory

func (s *SQLite) RetrieveSubscriptionHistory(username string, deviceName string, since time.Time) ([]Subscription, error)

func (*SQLite) StopDeviceSync added in v0.2.0

func (s *SQLite) StopDeviceSync(deviceName string, username string) error

StopDeviceSync takes in a device name and username to stop device sync

func (*SQLite) UpdateOrCreateDevice added in v0.2.0

func (s *SQLite) UpdateOrCreateDevice(username string, deviceName string, caption string, deviceType string) (int, error)

type Subscription

type Subscription struct {
	User      string          `json:"user"`
	Device    string          `json:"device"`
	Devices   []int           `json:"devices"`
	Podcast   string          `json:"podcast"`
	Action    string          `json:"action"`
	Timestamp CustomTimestamp `json:"timestamp"`
}

type User

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

Jump to

Keyboard shortcuts

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