smal

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2020 License: ISC Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Version defines a version
	Version = "0.2.0"

	// SmalAuthor holds the copyright holder
	SmalAuthor = "(c) 2020 - present Birger J. Nordølum"

	// ConfigName defines the default filename for the configuration
	ConfigName = "smal.toml"

	// MaxConcurrentDownloads number of concurrent downloads
	MaxConcurrentDownloads = 3

	Banner = "\n" +
		"     _______.       .___  ___.           ___            __ \n" +
		"    /       |       |   \\/   |          /   \\          |  | \n" +
		"   |   (----` ______|  \\  /  |  ______ /  ^  \\   ______|  | \n " +
		"    \\   \\   |______|  |\\/|  | |______/  /_\\  \\ |______|  | \n" +
		".----)   |          |  |  |  |       /  _____  \\       |  `----. \n" +
		"|_______/           |__|  |__|      /__/     \\__\\      |_______| \n"
)

Variables

View Source
var ConfigLocations = []string{
	strings.Join([]string{GetEnv("XDG_CONFIG_HOME"), "smal"}, "/"),
	GetEnv("XDG_CONFIG_HOME"),
	".",
}

ConfigLocations to potential config locations to check

View Source
var VerboseOption bool

VerboseOption tells if we've enabled verbose via the cli

Functions

func CollectLectures added in v0.2.0

func CollectLectures(config *Config) (lectures [][]Lecture, err error)

CollectLectures get all the subjects given by the map.

func FindConfig added in v0.0.2

func FindConfig(paths []string) (path string, err error)

FindConfig checks to see if a path contains a file named ConfigName Takes a string slice of arrays Returns path/ConfigName if the file exist

func GetEnv added in v0.0.2

func GetEnv(variable string) string

GetEnv returns the contents of an environment variable Takes variable name as a string Returns the content of the variable if it is set,

otherwise returns an empty string

func ProgressBarConfig added in v0.2.0

func ProgressBarConfig(bar *pb.ProgressBar, prefix string)

ProgressBarConfig hold the ProgressBar configuration

func ReplaceSpaceWithChar added in v0.2.0

func ReplaceSpaceWithChar(str string, char string) string

ReplaceSpaceWithChar looks for a space and replaces it with a character of choice.

func StripTrailingSlash added in v0.0.2

func StripTrailingSlash(str string) string

StripTrailingSlash removes the trailing forward slash

Types

type Collector added in v0.0.2

type Collector struct {
	Lecturer string
	Subject  string
	Count    int
	// contains filtered or unexported fields
}

Collector defines a new collector for storting both the colly.Collector as well as other options.

func NewCollector added in v0.0.2

func NewCollector(lecturer string, subject string, count int) *Collector

NewCollector inilialize a new collector for each subject.

func (*Collector) GetLectures added in v0.0.2

func (c *Collector) GetLectures() ([]Lecture, error)

GetLectures retrieves lectures.

type CollyConfigs added in v0.2.0

type CollyConfigs struct{}

CollyConfigs is a collection of availableflags for colly Maybe implement as a function. Look at official docs.

type Config added in v0.0.2

type Config struct {
	Debug   bool
	OutDir  string `toml:"out_dir"`
	Queries []Query
}

Config contains variables used for configuration. Member data are set as private to avoid changing them at runtime.

func (*Config) GetDebug added in v0.0.2

func (c *Config) GetDebug() bool

GetDebug returns whether the config has enable debug support

func (*Config) ReadConfig added in v0.2.0

func (c *Config) ReadConfig(filePath string) (err error)

ReadConfig parses config files and overwrite existing data Takes path to a toml file and parses it's content Returns an error if anything fails.

type Download added in v0.2.0

type Download struct {
	Lecture      Lecture
	DownloadType string
}

Download holds the lecture with desired type

type Lecture

type Lecture struct {
	ID        string
	Tidspunkt time.Time
	Varighet  int
	Foreleser string
	Tittel    string
	Emne      string
	URL       map[string]string
	Info      string
}

Lecture inneholder all metadata om en forelesning.

func (*Lecture) CapturedToday added in v0.2.0

func (l *Lecture) CapturedToday() bool

CapturedToday return whether the lecture were captured today.

func (*Lecture) DeserializeElapsedTime added in v0.0.2

func (l *Lecture) DeserializeElapsedTime(str string)

DeserializeElapsedTime converts the string "number min" to number

func (*Lecture) Disp added in v0.0.2

func (l *Lecture) Disp()

Disp prints a human readable oupt

type LectureType

type LectureType int

LectureType is the generic type for lecture formats.

const (
	Audio    LectureType = iota // Audio only
	Camera   LectureType = iota // Camera only
	Combined LectureType = iota // Both camera & screen
	Screen   LectureType = iota // Only screen

	DateLayout = "2006-01-02 15:04" // Date format from site
)

Contains the enum types for possible lecture type

type LecturesService added in v0.0.2

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

LecturesService contains the collector.

type ProgressBar added in v0.2.0

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

ProgressBar wraps a github.com/cheggaaa/pb.Pool in order to display download progress for one or multiple downloads.

If two different instance of ProgressBar try to display a progress only one will be displayed. It is therefore recommended to use DefaultProgressBar

func (*ProgressBar) TrackProgress added in v0.2.0

func (cpb *ProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser

TrackProgress instantiates a new progress bar that will display the progress of stream until closed. total can be 0.

type Query added in v0.2.0

type Query struct {
	Lecturer string
	Subject  string
	Body     []Lecture
	Type     []string
	Count    int `default:"-2"`
}

Query hold the metadata for each query.

type Result added in v0.2.0

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

Result holds the given result about a download

func StartDownload added in v0.2.0

func StartDownload(config *Config, downloads []Download) []Result

StartDownload all files at urls passed as argument

Jump to

Keyboard shortcuts

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