database

package
v0.0.0-...-986a7cc Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const TableHistories = "histories"
View Source
const TablePlaylists = "playlists"
View Source
const TableUsers = "users"

Variables

View Source
var ColumnAdmin = column{"admin", boolean()}
View Source
var ColumnApikey = column{"api_key", text()}
View Source
var ColumnDate = column{"date", datetime()}
View Source
var ColumnId = column{"id", text()}
View Source
var ColumnIds = column{"ids", text()}
View Source
var ColumnName = column{"name", text()}
View Source
var ColumnPasswordHash = column{"password_hash", text()}
View Source
var ColumnPasswordSalt = column{"password_salt", text()}
View Source
var ColumnPublic = column{"public", boolean()}
View Source
var ColumnVerified = column{"verified", boolean()}
View Source
var ForeignKeyApikey = foreignKey{ColumnApikey.name, text(), TableUsers,
	ColumnApikey.name, true}

Functions

This section is empty.

Types

type Database

type Database struct {
	UsersDB     *UsersDB
	PlaylistsDB *PlaylistsDB
	HistoriesDB *HistoriesDB

	YoutubeDB YouTubeDB
	// contains filtered or unexported fields
}

func GetDatabase

func GetDatabase(key []byte, ytKey string) *Database

func GetDefaultDatabase

func GetDefaultDatabase() *Database

func (*Database) Close

func (database *Database) Close() error

type HistoriesDB

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

func (*HistoriesDB) AddHistory

func (historiesDB *HistoriesDB) AddHistory(apiKey, id string) error

func (*HistoriesDB) GetHistory

func (historiesDB *HistoriesDB) GetHistory(apiKey string) ([]string, error)

type History

type History struct {
	ApiKey string    `json:"apikey"`
	Id     string    `json:"id"`
	Date   time.Time `json:"-"`
}

func NewHistory

func NewHistory(data []byte) (History, error)

type Playlist

type Playlist struct {
	ApiKey string `json:"apikey,omitempty"`
	Name   string `json:"name"`
	Public bool   `json:"public"`
}

func NewPlaylist

func NewPlaylist(data []byte) (Playlist, error)

type PlaylistId

type PlaylistId struct {
	ApiKey string `json:"apikey,omitempty"`
	Name   string `json:"name"`
	Id     string `json:"id"`
}

func NewPlaylistId

func NewPlaylistId(data []byte) (PlaylistId, error)

type PlaylistIds

type PlaylistIds struct {
	ApiKey string   `json:"apikey,omitempty"`
	Name   string   `json:"name"`
	Ids    []string `json:"ids"`
}

func NewPlaylistIds

func NewPlaylistIds(data []byte) (PlaylistIds, error)

type PlaylistLinkPublic

type PlaylistLinkPublic struct {
	ApiKey   string `json:"apikey,omitempty"`
	Name     string `json:"name"`
	Playlist string `json:"playlist"`
}

func NewPlaylistPublic

func NewPlaylistPublic(data []byte) (PlaylistLinkPublic, error)

type PlaylistsDB

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

func (*PlaylistsDB) AddIdToPlaylist

func (playlistsDB *PlaylistsDB) AddIdToPlaylist(playlistId PlaylistId) error

func (*PlaylistsDB) CreatePlaylist

func (playlistsDB *PlaylistsDB) CreatePlaylist(playlist Playlist) error

func (*PlaylistsDB) DeleteIdFromPlaylist

func (playlistsDB *PlaylistsDB) DeleteIdFromPlaylist(playlistId PlaylistId) error

func (*PlaylistsDB) DeletePlaylist

func (playlistsDB *PlaylistsDB) DeletePlaylist(playlist Playlist) error

func (*PlaylistsDB) GetPlaylistIds

func (playlistsDB *PlaylistsDB) GetPlaylistIds(playlist Playlist) ([]string, error)

func (*PlaylistsDB) GetPlaylists

func (playlistsDB *PlaylistsDB) GetPlaylists(apiKey string, publicOnly bool) ([]Playlist, error)

func (*PlaylistsDB) IsPlaylistPublic

func (playlistsDB *PlaylistsDB) IsPlaylistPublic(playlist Playlist) bool

func (*PlaylistsDB) SetPlaylistIds

func (playlistsDB *PlaylistsDB) SetPlaylistIds(playlistIds PlaylistIds) error

func (*PlaylistsDB) SetPublic

func (playlistsDB *PlaylistsDB) SetPublic(playlist Playlist) error

type User

type User struct {
	ApiKey       string `json:"apikey,omitempty"`
	Name         string `json:"name,omitempty"`
	Password     string `json:"password,omitempty"`
	PasswordSalt string `json:"-"`
	PasswordHash string `json:"-"`
	Admin        *bool  `json:"admin,omitempty"`
	Verified     *bool  `json:"verified,omitempty"`
}

func NewUser

func NewUser(data []byte) (User, error)

func (User) ToJson

func (user User) ToJson() (string, error)

type UsersDB

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

func (*UsersDB) AddUser

func (usersDB *UsersDB) AddUser(user User) (User, int)

func (*UsersDB) DeleteAllNonVerifiedUsers

func (usersDB *UsersDB) DeleteAllNonVerifiedUsers(request User) error

func (*UsersDB) DeleteUser

func (usersDB *UsersDB) DeleteUser(request User) error

func (*UsersDB) FindUserByApiKey

func (usersDB *UsersDB) FindUserByApiKey(apiKey string) (User, error)

func (*UsersDB) FindUserByName

func (usersDB *UsersDB) FindUserByName(name string) (User, error)

func (*UsersDB) GetUserWithPassword

func (usersDB *UsersDB) GetUserWithPassword(name, password string) (User, int)

func (*UsersDB) ListUsers

func (usersDB *UsersDB) ListUsers(page int) ([]User, error)

func (*UsersDB) ResetPasswordUser

func (usersDB *UsersDB) ResetPasswordUser(request User) error

func (*UsersDB) SetVerificationUser

func (usersDB *UsersDB) SetVerificationUser(request User) error

type YouTubeDB

type YouTubeDB interface {
	GetYoutubeSong(id string) (*YoutubeSong, error)
	FetchYoutubeSong(id string) (string, string, error)
	GetYoutubeSearch(searchQuery string) ([]YoutubeSearchResult, error)
	GetYoutubeInfo(id string) (YoutubeSearchResult, error)
	GetYoutubeCharts() ([]YoutubeSearchResult, error)
}

type Youtube

type Youtube struct {
	ApiKey      string `json:"apikey"`
	SearchQuery string `json:"searchquery"`
	Id          string `json:"id"`
	AddHistory  bool   `json:"addhistory"`
}

func NewYoutube

func NewYoutube(data []byte) (Youtube, error)

type YoutubeChart

type YoutubeChart struct {
	Contents YoutubeChartContents `json:"contents"`
}

type YoutubeChartContents

type YoutubeChartContents struct {
	SectionListRenderer YoutubeChartSectionListRenderer `json:"sectionListRenderer"`
}

type YoutubeChartMusicAnalyticsSectionRenderer

type YoutubeChartMusicAnalyticsSectionRenderer struct {
	Content YoutubeChartMusicAnalyticsSectionRendererContent `json:"content"`
}

type YoutubeChartMusicAnalyticsSectionRendererContent

type YoutubeChartMusicAnalyticsSectionRendererContent struct {
	Videos []YoutubeChartVideo `json:"videos"`
}

type YoutubeChartSectionListRenderer

type YoutubeChartSectionListRenderer struct {
	Contents []YoutubeChartSectionListRendererContent `json:"contents"`
}

type YoutubeChartSectionListRendererContent

type YoutubeChartSectionListRendererContent struct {
	MusicAnalyticsSectionRenderer YoutubeChartMusicAnalyticsSectionRenderer `json:"musicAnalyticsSectionRenderer"`
}

type YoutubeChartThumbnail

type YoutubeChartThumbnail struct {
	Details []YoutubeChartThumbnailDetails `json:"thumbnails"`
}

type YoutubeChartThumbnailDetails

type YoutubeChartThumbnailDetails struct {
	Url string `json:"url"`
}

type YoutubeChartVideo

type YoutubeChartVideo struct {
	ListType   string                  `json:"listType"`
	VideoViews []YoutubeChartVideoView `json:"videoViews"`
}

type YoutubeChartVideoView

type YoutubeChartVideoView struct {
	Id        string                `json:"id"`
	Title     string                `json:"title"`
	Thumbnail YoutubeChartThumbnail `json:"thumbnail"`
	Duration  int                   `json:"videoDuration"`
}

type YoutubeContentDetails

type YoutubeContentDetails struct {
	Duration string `json:"duration"`
}

type YoutubeId

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

func (YoutubeId) GetCount

func (youtubeId YoutubeId) GetCount() int

func (YoutubeId) GetUniqueId

func (youtubeId YoutubeId) GetUniqueId() string

type YoutubeItem

type YoutubeItem struct {
	Snippet        YoutubeSnippet        `json:"snippet"`
	ContentDetails YoutubeContentDetails `json:"contentDetails"`
	Id             string                `json:"id"`
}

type YoutubeResponse

type YoutubeResponse struct {
	Items []YoutubeItem `json:"items"`
}

type YoutubeSearch

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

func (YoutubeSearch) GetCount

func (youtubeSearch YoutubeSearch) GetCount() int

func (YoutubeSearch) GetUniqueId

func (youtubeSearch YoutubeSearch) GetUniqueId() string

type YoutubeSearchResult

type YoutubeSearchResult struct {
	Title     string `json:"title"`
	Id        string `json:"id"`
	Thumbnail string `json:"thumbnail"`
	Duration  string `json:"duration"`
}

type YoutubeSnippet

type YoutubeSnippet struct {
	Title      string            `json:"title"`
	Thumbnails YoutubeThumbnails `json:"thumbnails"`
}

type YoutubeSong

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

func (YoutubeSong) GetCount

func (youtubeSong YoutubeSong) GetCount() int

func (YoutubeSong) GetUniqueId

func (youtubeSong YoutubeSong) GetUniqueId() string

func (*YoutubeSong) IsDownloading

func (youtubeSong *YoutubeSong) IsDownloading() bool

func (*YoutubeSong) Reader

func (youtubeSong *YoutubeSong) Reader() (*YoutubeSongReader, error)

type YoutubeSongReader

type YoutubeSongReader struct {
	io.ReaderAt
	io.Closer
	// contains filtered or unexported fields
}

func (*YoutubeSongReader) Close

func (youtubeSongReader *YoutubeSongReader) Close() error

func (*YoutubeSongReader) ReadAt

func (youtubeSongReader *YoutubeSongReader) ReadAt(p []byte, off int64) (n int, err error)

func (*YoutubeSongReader) Size

func (youtubeSongReader *YoutubeSongReader) Size() int64

type YoutubeThumbnail

type YoutubeThumbnail struct {
	Url string `json:"url"`
}

type YoutubeThumbnails

type YoutubeThumbnails struct {
	Medium YoutubeThumbnail `json:"medium"`
}

Jump to

Keyboard shortcuts

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