gazelle

package module
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2019 License: MIT Imports: 14 Imported by: 0

README

Go interface to Gazelle API

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bint

func Bint(b bool) int

Bint converts a boolean into an int. true = 1, false = 0

func FileSimilarity added in v0.3.0

func FileSimilarity(f1, f2 whatapi.FileStruct) float64

FileSimilarity measures how similar two files are, considring their names and lengths, with 0.0 being not similar at all, and 1.0 being identical

func NullableBInt

func NullableBInt(b *bool) *int

func NullableString

func NullableString(s *string) string

func Similarity added in v0.3.0

func Similarity(a, b string) float64

Similarity measures how similar two strings are from [0.0..1.0] where 0.0 is no similarity at all and 1.0 is equal strings

func SizeSimilarity added in v0.7.0

func SizeSimilarity(s1, s2 int64) float64

SizeSimilarity measures how similar two file sizes are with 0.0 being not similar at all, and 1.0 being identical Arbitrarily, if one file is 1/2 the size of the other, it's 0.1 similar

Types

type Artist

type Artist struct {
	ID   int    `db:"id"`
	Name string `db:"name"`
}

Artist is a single gazelle artist

func (Artist) Similarity added in v0.3.0

func (a Artist) Similarity(a2 Artist) float64

Similarity measures how similar two artists are with 0.0 being not at all and 1.0 being the same

func (Artist) Update

func (a Artist) Update(tx *sqlx.Tx, tracker Tracker) error

Update artist stores the artist in the db

type ArtistList added in v0.3.0

type ArtistList []Artist

ArtistList is just a list of Artist

func (ArtistList) DisplayName added in v0.3.0

func (a ArtistList) DisplayName(role string) string

DisplayName for an artist list is the human readable form of the list, or "Various <role>" if multiple

func (ArtistList) Names added in v0.3.0

func (a ArtistList) Names() []string

Names returns the names of all the artists in the list

func (ArtistList) Similarity added in v0.4.0

func (a ArtistList) Similarity(a2 ArtistList) float64

Similarity returns how similar two list of artists are with 0.0 being not at all similar and 1.0 being completely the same

type Artists

type Artists struct {
	Tracker
	Roles Roles
}

Artists is a tracker and a set of artists and their roles usually associated with a group

func NewExtendedArtistMap

func NewExtendedArtistMap(tracker Tracker, am whatapi.ExtendedArtistMap) Artists

NewExtendedArtistMap creates Artists from a tracker and a whatapi.ExtendedArtistMap

func NewMusicInfo

func NewMusicInfo(tracker Tracker, mi whatapi.MusicInfo) Artists

NewMusicInfo creates Artists from a tracker and whatapi.MusicInfo struct

func (Artists) DisplayName

func (a Artists) DisplayName() string

DisplayName for artists is the human readable string formatting of the artists, intended to replicate the internal gazelle logic for formatting artist names

func (Artists) Names

func (a Artists) Names() []string

Names returns a list of the main artists names from an artist list

func (Artists) Similarity added in v0.3.0

func (a Artists) Similarity(a2 Artists) float64

Similarity measures the similarities of two Artists structs, where 0.0 is not at all similar, and 1.0 is identical it is just the similarity of the roles

func (Artists) Update

func (a Artists) Update(tx *sqlx.Tx) error

Update artists just updates each artist in the aggregate

type Candidate added in v0.7.0

type Candidate struct {
	Torrent
	P float64
}

Candidate is a possible match for a torrent on another tracker P is the probability that it's a match

type Candidates added in v0.7.0

type Candidates []Candidate

Candidates is a list of candidate matches

func (Candidates) Len added in v0.7.0

func (c Candidates) Len() int

func (Candidates) Less added in v0.7.0

func (c Candidates) Less(i, j int) bool

func (Candidates) Swap added in v0.7.0

func (c Candidates) Swap(i, j int)

type Group

type Group struct {
	Artists
	ID              int        `db:"groupid"`
	Name            string     `db:"groupname"`
	Year            int        `db:"year"`
	RecordLabel     *string    `db:"recordlabel"`
	CatalogueNumber *string    `db:"cataloguenumber"`
	ReleaseTypeF    int        `db:"releasetype"`
	CategoryID      *int       `db:"categoryid"`
	CategoryName    *string    `db:"categoryname"`
	Time            *time.Time `db:"time"`
	VanityHouse     bool       `db:"vanityhouse"`
	WikiImage       *string    `db:"wikiimage"`
	WikiBody        *string    `db:"wikibody"`
	IsBookmarked    *bool      `db:"isbookmarked"`
	Tags            string     `db:"tags"`
}

func NewGroupSearchResult

func NewGroupSearchResult(tracker Tracker, srs whatapi.TorrentSearchResultStruct) (Group, error)

func NewGroupStruct

func NewGroupStruct(tracker Tracker, gs whatapi.GroupStruct) (g Group, err error)

func (Group) ReleaseType

func (g Group) ReleaseType() string

func (Group) Similarity added in v0.4.0

func (g Group) Similarity(g2 Group) float64

Similarity measures how similar two groups are with 0.0 for not at all similar, and 1.0 as the same

func (Group) Update

func (g Group) Update(tx *sqlx.Tx) error

func (Group) UpdateArtistsGroups

func (g Group) UpdateArtistsGroups(tx *sqlx.Tx) error

UpdateArtistsGroups updates the artists_groups table in the db for the artists in the group

type Role added in v0.4.0

type Role string

Role is the name of an artist's role on a release

func (Role) Importance added in v0.5.1

func (r Role) Importance() int

Importance maps a role name onto its integer encoding

type Roles added in v0.4.0

type Roles map[Role]ArtistList

Roles maps from roles onto lists of artists

func (Roles) Similarity added in v0.4.0

func (r Roles) Similarity(r2 Roles) float64

Similarity returns how similar two sets of roles are with 0.0 being not at all similar and 1.0 being completely the same

type Torrent

type Torrent struct {
	Group
	ID         int     `db:"id"`
	Hash       *string `db:"hash"`
	Media      string  `db:"media"`
	Format     string  `db:"format"`
	Encoding   string  `db:"encoding"`
	Remastered bool    `db:"remastered"`

	RemasterYear            int       `db:"remasteryear"`
	RemasterTitle           string    `db:"remastertitle"`
	RemasterRecordLabel     *string   `db:"remasterlabel"`
	RemasterCatalogueNumber *string   `db:"cataloguenumber"`
	Scene                   bool      `db:"scene"`
	HasLog                  bool      `db:"haslog"`
	HasCue                  bool      `db:"hascue"`
	LogScore                int       `db:"logscore"`
	LogChecksum             *bool     `db:"logchecksum"`
	FileCount               int       `db:"filecount"`
	Size                    int64     `db:"size"`
	Seeders                 int       `db:"seeders"`
	Leechers                int       `db:"leechers"`
	Snatched                int       `db:"snatched"`
	FreeTorrent             bool      `db:"freetorrent"`
	Reported                *bool     `db:"reported"`
	Time                    time.Time `db:"time"`
	Description             *string   `db:"description"`
	FilePath                *string   `db:"filepath"`
	UserID                  *int      `db:"userid"`
	Username                *string   `db:"username"`
	Files                   []whatapi.FileStruct
	CanUseToken             *bool `db:"canusetoken"`
}

func NewArtist

func NewArtist(tracker Tracker, a whatapi.Artist) (torrents []Torrent, err error)

func NewGetTorrentStruct

func NewGetTorrentStruct(tracker Tracker, tr whatapi.GetTorrentStruct) (Torrent, error)

func NewSearchTorrentStruct

func NewSearchTorrentStruct(g Group, rt whatapi.SearchTorrentStruct) (Torrent, error)

func NewTopTenTorrents

func NewTopTenTorrents(tracker Tracker, tt whatapi.TopTenTorrents) ([]Torrent, error)

func NewTorrentGroup

func NewTorrentGroup(tracker Tracker, tg whatapi.TorrentGroup) ([]Torrent, error)

func NewTorrentSearch

func NewTorrentSearch(
	tracker Tracker, ts whatapi.TorrentSearch) ([]Torrent, error)

func NewTorrentStruct

func NewTorrentStruct(g Group, t whatapi.TorrentStruct) (Torrent, error)

func (Torrent) FileSimilarity added in v0.4.0

func (t Torrent) FileSimilarity(t2 Torrent) float64

FileSimilarity measures how similar the files are between two torrents with 0.0 being not at all similar, and 1.0 being identical

func (*Torrent) Fill

func (t *Torrent) Fill(tx *sqlx.Tx) error

func (Torrent) Find added in v0.4.0

func (t Torrent) Find(db *sqlx.DB, disc discogs.DB, dst Tracker) (Candidates, error)

Find tries to find the equivalent of this torrent on another tracker it returns a candidate, a probability, and if there was an error

func (*Torrent) GetArtists

func (t *Torrent) GetArtists(db *sqlx.DB) error

GetArtists gets all of the artists for a torrent. Usually used when initially populating a torrent (and should probably just be part of get torrent)

func (*Torrent) GetFiles

func (t *Torrent) GetFiles(db *sqlx.DB) error

func (Torrent) ReleaseSimilarity added in v0.4.0

func (t Torrent) ReleaseSimilarity(t2 Torrent) float64

ReleaseSimilarity measures how similar two torrent releases are with 0.0 being not at all similar, and 1.0 being identical

func (*Torrent) Remaster added in v0.5.0

func (t *Torrent) Remaster() string

Remaster returns a printable form of the torrents remaster information or an empty string if not remastered

func (Torrent) ShortName

func (t Torrent) ShortName() string

func (Torrent) Similarity added in v0.7.0

func (t Torrent) Similarity(t2 Torrent) float64

Similarity measures the similarity between two torrents where 0.0 is not at all similar, and 1.0 is identical

func (*Torrent) String

func (t *Torrent) String() string

func (Torrent) Update

func (t Torrent) Update(tx *sqlx.Tx) error

func (Torrent) UpdateFiles

func (t Torrent) UpdateFiles(tx *sqlx.Tx) error

type Tracker

type Tracker struct {
	whatapi.Client
	Name         string `db:"tracker"`
	Other        string
	Path         string
	Host         string
	Conf         string
	ReleaseTypes map[int]string
	Categories   map[int]string
	TokenSize    int64 // torrents bigger than this, try to use a token
	// contains filtered or unexported fields
}

Tracker represents a gazelle tracker and implements the Client interface

func (Tracker) GetArtist

func (t Tracker) GetArtist(id int) ([]Torrent, error)

func (Tracker) GetArtistByName

func (t Tracker) GetArtistByName(n string) ([]Torrent, error)

func (Tracker) GetGroup

func (t Tracker) GetGroup(id int) ([]Torrent, error)

func (Tracker) GetGroupByHash

func (t Tracker) GetGroupByHash(h string) ([]Torrent, error)

func (Tracker) GetTorrent

func (t Tracker) GetTorrent(id int) (Torrent, error)

func (Tracker) GetTorrentByHash

func (t Tracker) GetTorrentByHash(h string) (Torrent, error)

func (Tracker) Search

func (t Tracker) Search(params url.Values) ([]Torrent, error)

func (Tracker) Top10

func (t Tracker) Top10(params url.Values) ([]Torrent, error)

type WeightedScore added in v0.3.0

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

WeightedScore lets you compute a single weighted score from a series of scores and weights. It uses the geometric mean (distance) as the Score

func (WeightedScore) Score added in v0.3.0

func (s WeightedScore) Score() float64

Score is the current value of the WeightedScore

func (*WeightedScore) Update added in v0.3.0

func (s *WeightedScore) Update(sc, w float64)

Update adds a score and weight to the WeightedScore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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