pudl

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2022 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	PUDELEK_BASE_URL = "https://pudelek.pl"
	PUDL_CONFIG_FILE = ".pudl.yaml"
)
View Source
const (
	SELECTOR_BASE       = "[data-st-area=main-stream-%d]"
	MEDIA_STREAMS_COUNT = 21
)
View Source
const (
	REFRESH_THROTTLE = 10
)
View Source
const (
	TIMEOUT = 2
)
View Source
const (
	VERSION = "v0.0.2"
)

Variables

View Source
var (
	ErrNothingCached = errors.New("Nothing is cached yet")
)
View Source
var (
	ErrNothingFound = errors.New("Did not found anything on the page. Maybe structure has changed! Please update pudl")
)
View Source
var (
	ErrOutOfCacheBounds = errors.New("index provided by user is out of usable bounds")
)
View Source
var (
	SHOW_LOG = false
)

Functions

func Cache

func Cache() error

func Display

func Display(pudlsToShow *[]Pudl, oldPudls *[]Pudl, maxCount int)
Example
package main

func pudlsForTesting() (*[]Pudl, *[]Pudl) {
	oldPudls := &[]Pudl{
		{
			Title: "A",
			Url:   "https://lol.com/A",
		},
		{
			Title: "B",
			Url:   "https://lol.com/B",
		},
		{
			Title: "C",
			Url:   "https://lol.com/C",
		},
		{
			Title: "D",
			Url:   "https://lol.com/D",
		},
	}

	pudlsToShow := &[]Pudl{
		{
			Title: "A",
			Url:   "https://lol.com/A",
		},
		{
			Title: "J",
			Url:   "https://lol.com/J",
		},
		{
			Title: "O",
			Url:   "https://lol.com/O",
		},
	}
	return oldPudls, pudlsToShow
}

func main() {

	oldPudls, pudlsToShow := pudlsForTesting()

	Display(pudlsToShow, oldPudls, -1)
}
Output:

⭐⭐⭐ 😹 Lista tematow z pudla 🐩 😹 ⭐⭐⭐
1: A
2:⭐ J
3:⭐ O

func EnableLogs

func EnableLogs()

func List

func List() error

func ScrapePudelekFrontPage

func ScrapePudelekFrontPage() (*[]Pudl, error)

func Show

func Show(puldId int) error

func Top

func Top() error

Types

type Pudl

type Pudl struct {
	Title string
	Url   string
}

type PudlData

type PudlData struct {
	Config struct {
		TopCount int
	} `yaml:"config"`
	LastFetchTime time.Time
	Data          []Pudl `yaml:"db"`
}

func LoadConfigFromFile

func LoadConfigFromFile() (*PudlData, error)

func LoadDataFromYaml

func LoadDataFromYaml(rawYamlData []byte) (*PudlData, error)

func (*PudlData) SaveToFile

func (pd *PudlData) SaveToFile() error

func (*PudlData) ToYaml

func (pd *PudlData) ToYaml() ([]byte, error)

Jump to

Keyboard shortcuts

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