Documentation
¶
Index ¶
- Constants
- Variables
- func CachePath() string
- func CheckMastodonCredentialsFile(key, secret, token, instance string, dryRun bool, ...) (*madon.Client, error)
- func DataPath() string
- func FormatDuration(d time.Duration) string
- func GetHTTPClient() *http.Client
- func InstanceName(inst string) string
- func Levenshtein(s1, s2 []rune) int
- func LoadCredentials() (map[string]any, error)
- func LoadLinks(c LoadLinksConfig) error
- func LoadLinksWithBandCamp(rel map[int]release) (map[int]release, error)
- func LoadLinksWithDDG(rel map[int]release, useCache bool) (map[int]release, error)
- func LoadReleases(loadFn func() (map[int]release, error)) (map[time.Time][]release, error)
- func LoadSources(c FetchConfig) error
- func MkDirIfNotExists(p string) error
- func NewStorage(dir string, logFn, errFn logFn) *repo
- func Post(c PostConfig) error
- func PostToStdout(groupped map[time.Time][]release) error
- func UpdateAPAccount(app *APClient, dryRun bool) error
- func UpdateMastodonAccount(app *madon.Client, dryRun bool) error
- func ValidMastodonApp(c *madon.Client) bool
- func ValidMastodonAuth(c *madon.Client) bool
- type APClient
- type AdditionalProperty
- type Author
- type BandCamp
- type ByArtist
- type Comment
- type DuckDuckGo
- type FetchConfig
- type FoundingLocation
- type Item
- type ItemElement
- type LoadLinksConfig
- type MetalArchives
- type MusicAlbum
- type MusicBrainz
- type MusicRelease
- type Offers
- type PostConfig
- type PosterFn
- type PriceSpec
- type Publisher
- type RecordLabel
- type Search
- type SoundCloud
- type Source
- type SourceFn
- type Sponsor
- type Spotify
- type StorageSaveFn
- type SubjectOf
- type TrackInfo
- type Wikipedia
- type Youtube
Constants ¶
View Source
const ( ResolutionDay = 24 * time.Hour ResolutionWeek = 7 * ResolutionDay ResolutionMonthish = 31 * ResolutionDay ResolutionYearish = 365 * ResolutionDay )
View Source
const ( TypeMastodon = "mastodon" TypeFedBOX = "fedbox" TypeONI = "oni" )
View Source
const ExecOpenCmd = "xdg-open"
View Source
const SourceMetalArchives = "metal-archives"
View Source
const SourceMusicBrainz = "musicbrainz"
View Source
const SourceWikipedia = "wikipedia"
Variables ¶
View Source
var ( Info logFn = emptyLogFn Error logFn = emptyLogFn AppVersion = "HEAD" AppName = "rattlehead" AppWebsite = "https://git.sr.ht/~mariusor/rattlehead" // NOTE(marius): instead of using separate values for each scope value, // we mash them together, because the API client doesn't encode them properly AppScopes = []string{"read+write+follow"} DefaultInstance = "metalhead.club" )
View Source
var AccountDetails embed.FS
View Source
var Sources = []string{
"https://en.wikipedia.org/wiki/2022_in_heavy_metal_music",
"https://www.metal-archives.com/release/upcoming",
"https://time-for-metal.eu/metal-releases-kalender/",
"https://www.metalunderground.com/upcoming_metal_releases/",
}
View Source
var (
UserAgent = fmt.Sprintf("%s/%s (%s)", AppName, AppVersion, AppWebsite)
)
View Source
var ValidMonths = []time.Month{ time.January, time.February, time.March, time.April, time.May, time.June, time.July, time.August, time.September, time.October, time.November, time.December, }
View Source
var ValidSources = []string{SourceWikipedia, SourceMusicBrainz, SourceMetalArchives}
Functions ¶
func FormatDuration ¶
func GetHTTPClient ¶
func InstanceName ¶
func Levenshtein ¶
Levenshtein This implementation translated from the optimized C code at https://en.wikibooks.org/wiki/Algorithm_Implementation/Strings/Levenshtein_distance#C Original at https://github.com/dgryski/trifles/blob/master/leven/leven.go
func LoadCredentials ¶
func LoadLinks ¶
func LoadLinks(c LoadLinksConfig) error
func LoadLinksWithBandCamp ¶
func LoadLinksWithDDG ¶
func LoadReleases ¶
func LoadSources ¶
func LoadSources(c FetchConfig) error
func MkDirIfNotExists ¶
func NewStorage ¶
func NewStorage(dir string, logFn, errFn logFn) *repo
NewStorage returns a new repository
func Post ¶
func Post(c PostConfig) error
func PostToStdout ¶
func UpdateAPAccount ¶
func ValidMastodonApp ¶
func ValidMastodonAuth ¶
Types ¶
type APClient ¶
type AdditionalProperty ¶
type Author ¶
type Author struct { Type string `json:"-" jsonld:"@type"` URL string `json:"url"` Image string `json:"image"` Name string `json:"name"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type FetchConfig ¶
type FoundingLocation ¶
type Item ¶
type Item struct { ID string `json:"@id"` Type string `json:"-" jsonld:"@type"` Name string `json:"name"` Duration string `json:"duration"` CopyrightNotice string `json:"copyrightNotice"` MainEntityOfPage string `json:"mainEntityOfPage"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type ItemElement ¶
type LoadLinksConfig ¶
type MetalArchives ¶
type MetalArchives struct { Start time.Time `json:"start"` Duration time.Duration `json:"duration"` }
func (MetalArchives) Load ¶
func (m MetalArchives) Load(saveFn StorageSaveFn) error
func (MetalArchives) String ¶
func (m MetalArchives) String() string
type MusicAlbum ¶
type MusicAlbum struct { ID string `json:"@id"` Context string `json:"@context"` Type string `json:"-" jsonld:"@type"` AlbumReleaseType string `json:"albumReleaseType"` MainEntityOfPage string `json:"mainEntityOfPage"` Name string `json:"name"` DateModified string `json:"dateModified"` AlbumRelease []MusicRelease `json:"albumRelease"` ByArtist ByArtist `json:"byArtist"` Publisher Publisher `json:"publisher"` NumTracks int `json:"numTracks"` Track TrackInfo `json:"track"` Image string `json:"image"` Keywords []string `json:"keywords"` DatePublished string `json:"datePublished"` CopyrightNotice string `json:"copyrightNotice"` Comment []Comment `json:"comment"` Sponsor []Sponsor `json:"sponsor"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type MusicBrainz ¶
type MusicBrainz struct {
Search
}
func (MusicBrainz) Load ¶
func (m MusicBrainz) Load(saveFn StorageSaveFn) error
func (MusicBrainz) String ¶
func (m MusicBrainz) String() string
type MusicRelease ¶
type MusicRelease struct { Type string `json:"-" jsonld:"@type"` ID string `json:"@id"` Name string `json:"name,omitempty"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` Description string `json:"description,omitempty"` Identifier string `json:"identifier,omitempty"` Offers Offers `json:"offers,omitempty"` MusicReleaseFormat string `json:"musicReleaseFormat,omitempty"` Image []string `json:"image,omitempty"` RecordLabel RecordLabel `json:"recordLabel,omitempty"` }
type PostConfig ¶
type PosterFn ¶
func PostToActivityPub ¶
type Publisher ¶
type Publisher struct { ID string `json:"@id"` Type string `json:"-" jsonld:"@type"` Name string `json:"name"` Image string `json:"image"` Genre string `json:"genre"` SubjectOf []SubjectOf `json:"subjectOf"` FoundingLocation FoundingLocation `json:"foundingLocation"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type RecordLabel ¶
type RecordLabel struct { ID string `json:"@id"` Type string `json:"-" jsonld:"@type"` Name string `json:"name"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type SoundCloud ¶
type SoundCloud string
func (SoundCloud) String ¶
func (s SoundCloud) String() string
type Sponsor ¶
type Sponsor struct { Type string `json:"-" jsonld:"@type"` URL string `json:"url"` Image string `json:"image"` Name string `json:"name"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type StorageSaveFn ¶
type StorageSaveFn func(rel ...release) error
type SubjectOf ¶
type SubjectOf struct { Type string `json:"-" jsonld:"@type"` URL string `json:"url"` Name string `json:"name"` AdditionalProperty []AdditionalProperty `json:"additionalProperty,omitempty"` }
type TrackInfo ¶
type TrackInfo struct { Type string `json:"-" jsonld:"@type"` NumberOfItems int `json:"numberOfItems"` ItemListElement []ItemElement `json:"itemListElement"` }
Source Files
¶
Click to show internal directories.
Click to hide internal directories.