mpcstorage

package
v0.0.0-...-c36ecfd Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2023 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

MPC DB Storage Saves Videos Information in a boltdb database

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashPassword

func HashPassword(password string) string

HashPassword generates sha256 has of password

Types

type Storage

type Storage struct {
	Db         *bolt.DB
	Path       string
	Videos     map[string]Video
	Categories map[int]mpclibrary.Category
	Actors     map[int]mpclibrary.Actor
}

func (*Storage) GetActorByID

func (storage *Storage) GetActorByID(actorID int) (actor mpclibrary.Actor, err error)

GetActorByID gets an actor from the list by ID

func (*Storage) GetActorByName

func (storage *Storage) GetActorByName(actorName string) (actor mpclibrary.Actor, err error)

GetActorByName gets an actor from the list by name

func (*Storage) GetAllVideos

func (storage *Storage) GetAllVideos() error

GetAllVideos gets all the videos from the DB

func (*Storage) GetCategoryByID

func (storage *Storage) GetCategoryByID(categoryID int) (category mpclibrary.Category, err error)

GetCategoryByName gets category from the list by ID

func (*Storage) GetCategoryByName

func (storage *Storage) GetCategoryByName(categoryName string) (category mpclibrary.Category, err error)

GetCategoryByName gets category from the list by Name

func (*Storage) GetSettings

func (storage *Storage) GetSettings() (settings mpclibrary.Settings, err error)

GetSettings gets settings from the DB

func (*Storage) GetUsers

func (storage *Storage) GetUsers() (users []mpcusers.User, err error)

Get Users get user list from the DB

func (*Storage) GetVideoByFileName

func (storage *Storage) GetVideoByFileName(fileName string) (video mpclibrary.Video, err error)

GetVideoByFileName searchs a video in the DB, it Gets the video ID by using the MD5 sum of its name

func (*Storage) GetVideoByID

func (storage *Storage) GetVideoByID(videoMd5 string) (video mpclibrary.Video, err error)

GetVideoByID searchs a video in the DB using the video ID. The Video ID can be the MD5 sum of its name for normal videos or the MD5 sum of the video file for encrypted files

func (*Storage) GetVideoByOriginalName

func (storage *Storage) GetVideoByOriginalName(name string) (video mpclibrary.Video, err error)

GetVideoByOriginalName searchs a video in the DB using the file name when it was imported.

func (*Storage) GetVideos

func (storage *Storage) GetVideos(offset int, view int, sortBy string, filter VideoFilter, seed int64) VideoResults

Get Videos

Get videos that meets the search criteria

func (*Storage) InitDb

func (storage *Storage) InitDb() error

Initialize DB

Creates folder to save DB, Creates DB file and DB buckets, it also loads all the DB data

func (*Storage) InsertUser

func (storage *Storage) InsertUser(user mpcusers.User) (id string, err error)

InsertUser inserts new user in the DB.

func (*Storage) InsertVideos

func (storage *Storage) InsertVideos(videos []mpclibrary.Video) error

InsertVideos inserts new videos in the DB. A list of videos should be provided

func (*Storage) SaveSettings

func (storage *Storage) SaveSettings(settings mpclibrary.Settings) (err error)

Save Settings

type Video

type Video struct {
	ID           string    `json:"id"`
	Title        string    `json:"title"`
	ThumbURL     string    `json:"thumbURL"`
	ImgURL       string    `json:"imgURL"`
	VideoURL     string    `json:"videoURL"`
	Description  string    `json:"description"`
	PubDate      time.Time `json:"pubDate"`
	SubtitlesURL string    `json:"subtitlesURL"`
	Categories   []int     `json:"categories"`
	Actors       []int     `json:"actors"`
	Extension    string    `json:"extension"`
	Width        int       `json:"width"`
	Height       int       `json:"height"`
	Duration     int       `json:"duration"`
	Step         int       `json:"step"`
	File         string    `json:"file"`
	OrigFile     string    `json:"orig_file"`
	Path         string    `json:"path"`
	Md5Sum       string    `json:"md5sum"`
	Encrypted    bool      `json:"encrypted"`
}

type VideoFilter

type VideoFilter struct {
	Category string `json:"category"`
	Title    string `json:"title"`
	Actor    string `json:"actor"`
	Quality  string `json:"quality"`
	Duration [2]int `json:"duration"`
}

type VideoResults

type VideoResults struct {
	Videos []mpclibrary.Video `json:"videos"`
	Total  int                `json:"total"`
	Offset int                `json:"offset"`
	View   int                `json:"view"`
}

Jump to

Keyboard shortcuts

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