util

package
v0.0.0-...-7bdb5c7 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2020 License: MPL-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthUpload

func AuthUpload(r *http.Request) bool

AuthUpload uses Hash function to validate upload password.

func FailWithCode

func FailWithCode(
	w http.ResponseWriter,
	r *http.Request,
	status int,
	logr *log.Logger,
)

FailWithCode is used to appropriately respond to user in an event of failure. It uses status parameter to figure out what exactly to send back.

func Hash

func Hash(password, salt string) string

Hash returns base64 encoded SHA512 salted hash of password as a string.

func PathNotExists

func PathNotExists(apath string) bool

PathNotExists returns a boolean flag.

func RandName

func RandName(length uint) string

RandName returns random string of letters that we use as filename generator.

func SaveAlbumCover

func SaveAlbumCover(albumid int, meta *AlbumMeta, folderPath string) error

SaveAlbumCover moves album cover from newly extracted album into its proper location within the config.AlbumsFolder.

func SaveSongs

func SaveSongs(
	firstSongID int,
	meta *AlbumMeta,
	folderPath string,
) (err error)

SaveSongs moves songs from newly extracted album into their proper location within the config.SongsFolder.

func Unzip

func Unzip(r *zip.ReadCloser, dest string) (filenames []string, err error)

Unzip will decompress a zip archive, moving all files and folders within the r zip.ReadCloser to an output directory dist.

Types

type AlbumMeta

type AlbumMeta struct {
	Album    string   `json:"album"`
	Artist   string   `json:"artist"`
	CoverExt string   `json:"coverext"`
	Genres   []string `json:"genres"`
	Songs    []struct {
		Feat     []string `json:"feat"`
		Song     string   `json:"song"`
		AudioExt string   `json:"audioext"`
	} `json:"songs"`
}

AlbumMeta contains album metadata.

func ReadAlbumMeta

func ReadAlbumMeta(apath string) (data *AlbumMeta, err error)

ReadAlbumMeta returns album metadata read from "meta.json" file. It expects a string path to the folder that contains album files.

func (*AlbumMeta) Fix

func (meta *AlbumMeta) Fix()

Fix is a clever function that allows admins to save time by ommitting common defaults like '.mp3' audioext in the 'meta.json' files.

Jump to

Keyboard shortcuts

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