apiexternal

package
v0.0.0-...-4973d3c Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2024 License: AGPL-3.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ParserPool = pool.NewPool(100, 0, func(b *FileParser) {}, func(b *FileParser) {
		clear(b.M.Languages)
		*b = FileParser{}
	})
)

Functions

func CheckDigitLetter

func CheckDigitLetter(runev rune) bool

CheckDigitLetter returns true if the given rune is a digit or letter.

func ChecknzbtitleB

func ChecknzbtitleB(movietitle string, movietitleslug string, nzbtitle string, allowpm1 bool, yeari int) bool

ChecknzbtitleB checks if the nzbtitle matches the movietitle and year. It compares the movietitle and nzbtitle directly, and also tries appending/removing the year, converting to slugs, etc. It is used to fuzzy match nzb titles to movie info during parsing.

func DoJSONType

func DoJSONType[S any](c *rlHTTPClient, urlv string, headers ...keyval) (S, error)

DoJSONType makes a request to the url and unmarshals the JSON response into the given type S. It handles rate limiting and retries.

func DoJSONTypeG

func DoJSONTypeG[T any](c *rlHTTPClient, urlv string, headers ...keyval) ([]T, error)

DoJSONTypeG makes a request to the url and unmarshals the JSON response into the given generic slice type T. It handles rate limiting and retries.

func FindTmdbImdb

func FindTmdbImdb(imdbid string) ([]theMovieDBFindMovieresults, error)

FindTmdbImdb searches TheMovieDB API to find a movie based on its IMDb ID. It takes an IMDb ID string as input and returns a TheMovieDBFind struct containing the lookup result. Returns an ErrNotFound error if the IMDb ID is empty.

func FindTmdbTvdb

func FindTmdbTvdb(thetvdbid int) ([]theMovieDBFindTvresults, error)

FindTmdbTvdb searches TheMovieDB API to find a TV show based on its TheTVDB ID. It takes a TheTVDB ID int as input and returns a TheMovieDBFind struct containing the lookup result. Returns an ErrNotFound error if the TheTVDB ID is 0.

func GenerateIdentifierString

func GenerateIdentifierString(m *database.ParseInfo) string

GenerateIdentifierString generates an identifier string for a movie or episode in the format "S{season}E{episode}", where {season} and {episode} are the season and episode numbers formatted as strings.

func GenerateIdentifierStringFromInt

func GenerateIdentifierStringFromInt(season int, episode int) string

GenerateIdentifierStringFromInt generates a season/episode identifier string from the given season and episode integers. It pads each number with leading zeros to ensure a consistent format like "S01E02". This is intended to generate identifiers for public display/logging.

func GetOmdbMovie

func GetOmdbMovie(imdbid string) (omDBMovie, error)

GetOmdbMovie retrieves movie details from the OMDb API by imdbid. It returns a pointer to an OmDBMovie struct and an error. The imdbid parameter specifies the imdbid to look up. It returns logger.ErrNotFound if the imdbid is empty.

func GetPushOverKey

func GetPushOverKey() string

GetPushOverKey returns the API key for the pushover client. It returns an empty string if the client has not been initialized.

func GetTVExternal

func GetTVExternal(id int) (theMovieDBTVExternal, error)

GetTVExternal retrieves the external IDs for a TV show from TheMovieDB. It takes the ID of the TV show and returns a pointer to a TheMovieDBTVExternal struct containing the external IDs. Returns an error if the ID is invalid or the API call fails.

func GetTmdbMovie

func GetTmdbMovie(id int) (theMovieDBMovie, error)

GetTmdbMovie retrieves movie details from TheMovieDB API by movie ID. It takes an integer movie ID as input and returns a TheMovieDBMovie struct containing the movie details. Returns an error if the ID is invalid or the API call fails.

func GetTmdbMovieExternal

func GetTmdbMovieExternal(id int) (theMovieDBTVExternal, error)

GetTmdbMovieExternal retrieves the external IDs for a TMDb movie by ID. It returns a TheMovieDBTVExternal struct containing the external IDs, or an error if the ID is invalid or the lookup fails.

func GetTmdbMovieTitles

func GetTmdbMovieTitles(id int) ([]theMovieDBMovieTitlesList, error)

GetTmdbMovieTitles retrieves the alternative titles for a TMDb movie by ID. It returns a TheMovieDBMovieTitles struct containing the titles, or an error if the ID is invalid or the lookup fails.

func GetTraktAuthToken

func GetTraktAuthToken(clientcode string) *oauth2.Token

GetTraktAuthToken exchanges the authorization code for an OAuth 2.0 token for the Trakt API. It takes the client code and returns the token, or nil and an error if there was an issue exchanging the code.

func GetTraktAuthURL

func GetTraktAuthURL() string

GetTraktAuthURL generates an authorization URL that redirects the user to the Trakt consent page to request permission for the configured scopes. It returns the generated authorization URL.

func GetTraktMovie

func GetTraktMovie(movieid string) (traktMovieExtend, error)

GetTraktMovie retrieves extended data for a Trakt movie by ID. It takes a movie ID string as input. Returns a TraktMovieExtend struct containing the movie data, or nil and an error if the movie is not found or there is an error fetching data.

func GetTraktMovieAliases

func GetTraktMovieAliases(movieid string) []traktAlias

GetTraktMovieAliases retrieves alias data from the Trakt API for the given movie ID. It takes a Trakt movie ID string as a parameter. Returns a slice of TraktAlias structs containing the alias data, or nil if there is an error or no aliases found.

func GetTraktSerie

func GetTraktSerie(showid string) (traktSerieData, error)

GetTraktSerie retrieves extended data for a Trakt TV show by its Trakt ID. It takes the Trakt show ID as a string parameter. It returns a TraktSerieData struct containing the show data, or nil and an error if the show ID is invalid or there was an error retrieving data.

func GetTraktSerieAliases

func GetTraktSerieAliases(dbserie *database.Dbserie) []traktAlias

GetTraktSerieAliases retrieves alias data from the Trakt API for the given Dbserie. It first checks if there is a Trakt ID available and uses that to retrieve aliases. If no Trakt ID, it falls back to using the IMDb ID if available. Returns a slice of TraktAlias structs or nil if no aliases found.

func GetTraktSerieSeasonEpisodes

func GetTraktSerieSeasonEpisodes(showid string, season string) []traktSerieSeasonEpisodes

GetTraktSerieSeasonEpisodes retrieves all episodes for the given show ID and season from the Trakt API. It takes the show ID and season number as parameters. Returns a slice of TraktSerieSeasonEpisodes structs containing the episode data, or nil if there is an error.

func GetTraktSerieSeasons

func GetTraktSerieSeasons(showid string) []string

GetTraktSerieSeasons retrieves a list of season numbers for a Trakt TV show by ID. It returns a slice of season numbers as strings, or nil if there is an error.

func GetTraktToken

func GetTraktToken() *oauth2.Token

GetTraktToken returns the token used to authenticate with Trakt. This is a wrapper around the traktAPI

func GetTvdbSeries

func GetTvdbSeries(id int, language string) (theTVDBSeries, error)

GetTvdbSeries retrieves TV series data from the TheTVDB API for the given series ID. If a non-empty language is provided, it will be set in the API request headers. Returns the TV series data, or an error if one occurs.

func Getnewznabclient

func Getnewznabclient(row *config.IndexersConfig) *client

Getnewznabclient returns a Client for the given IndexersConfig. It checks if a client already exists for the given URL, and returns it if found. Otherwise creates a new client and caches it.

func GetnewznabclientRlClient

func GetnewznabclientRlClient(row *config.IndexersConfig) *rlHTTPClient

func NewClient

func NewClient(clientname string, skiptlsverify bool, disablecompression bool, rl slidingwindow.Limiter, usedaily bool, rldaily slidingwindow.Limiter, timeoutseconds int) rlHTTPClient

NewClient creates a new HTTP client for making external API requests. It configures rate limiting, TLS verification, compression, timeouts etc. based on the provided parameters.

func NewOmdbClient

func NewOmdbClient(apikey string, seconds int, calls int, disabletls bool, timeoutseconds int)

NewOmdbClient creates a new omdbClient instance for making requests to the OMDb API. It takes the API key, rate limit seconds, rate limit calls per second, whether to disable TLS, and request timeout in seconds. It sets sane defaults for the rate limiting if 0 values are passed.

func NewPushOverClient

func NewPushOverClient(apikey string)

NewPushOverClient initializes a new pushOverClient instance. apikey is the Pushover API key to use for sending messages. It initializes a rate limiter to limit messages to 3 per 10 seconds. If pushoverAPI is already initialized, it does nothing.

func NewQBittorrentClient

func NewQBittorrentClient(urlv string) *qbtClient

NewClient creates a new client connection to qbittorrent

func NewTmdbClient

func NewTmdbClient(apikey string, seconds int, calls int, disabletls bool, timeoutseconds int)

NewTmdbClient creates a new TMDb client for making API requests. It takes the TMDb API key, rate limiting settings, TLS setting, and timeout. Returns a tmdbClient instance configured with the provided settings.

func NewTraktClient

func NewTraktClient(clientid string, clientsecret string, seconds int, calls int, disabletls bool, timeoutseconds int)

NewTraktClient initializes a new traktClient instance for making requests to the Trakt API. It takes in credentials and rate limiting settings and sets up the OAuth2 configuration.

func NewTvdbClient

func NewTvdbClient(seconds int, calls int, disabletls bool, timeoutseconds int)

NewTvdbClient creates a new tvdbClient instance for making requests to the TheTVDB API. It configures rate limiting and TLS based on the provided parameters.

func NewznabCheckLimiter

func NewznabCheckLimiter(cfgindexer *config.IndexersConfig) (bool, error)

NewznabCheckLimiter checks if the rate limiter is triggered for the given indexer config. It loops through the newznabClients slice to find the matching client by URL, and calls checkLimiter on it to check if the rate limit has been hit. Returns true if under limit, false if over limit, and error if there was a problem.

func SearchOmdbMovie

func SearchOmdbMovie(title string, year string) ([]omDBMovieSearch, error)

SearchOmdbMovie searches the OMDb API for movies matching the given title and release year. The title parameter specifies the movie title to search for. The year parameter optionally specifies a release year to filter by. It returns a pointer to an OmDBMovieSearchGlobal struct containing search results, and an error.

func SearchTmdbMovie

func SearchTmdbMovie(name string) ([]theMovieDBFindMovieresults, error)

SearchTmdbMovie searches for movies on TheMovieDB API by movie name. It takes a movie name string as input and returns a pointer to a TheMovieDBSearch struct containing the search results, or an error if the name is empty or the API call fails.

func SearchTmdbTV

func SearchTmdbTV(name string) ([]theMovieDBFindTvresults, error)

SearchTmdbTV searches for TV shows on TheMovieDB API. It takes a search query string and returns a TheMovieDBSearchTV struct containing the search results. Returns ErrNotFound error if the search query is empty.

func SendPushoverMessage

func SendPushoverMessage(messagetext string, title string, recipientkey string) error

SendPushoverMessage sends a pushover message to the specified recipient. It handles rate limiting and retries before returning an error. messagetext is the message text, title is the message title, and recipientkey is the recipient's pushover key.

func SendToDeluge

func SendToDeluge(host string, port int, username string, password string, urlv string, dlpath string, moveafter bool, moveafterpath string, addpaused bool) error

SendToDeluge connects to a Deluge server, authenticates, and adds a torrent from a magnet URI or URL. It configures options like download location, moving completed downloads, pausing on add, etc. Returns any error from the connection or add torrent operations.

func SendToQBittorrent

func SendToQBittorrent(host string, port string, username string, password string, urlv string, dlpath string, addpaused string) error

func SendToRtorrent

func SendToRtorrent(hostname string, insecure bool, urlv string, dlpath string, name string) error

SendToRtorrent sends a torrent file URL to an rTorrent instance for downloading. hostname and insecure specify the rTorrent server. urlv is the torrent file URL. dlpath is the download location path. name is the name to save the torrent as in rTorrent. Returns any error.

func SendToSabnzbd

func SendToSabnzbd(server string, apikey string, urlv string, category string, nzbname string, priority int) error

SendToSabnzbd sends a download URL to a Sabnzbd server. It takes the Sabnzbd server address, API key, download URL, category, NZB name, and priority as parameters. It returns any error from creating the Sabnzbd client, authenticating, validating the authentication method, or adding the NZB.

func SendToTransmission

func SendToTransmission(server string, username string, password string, urlv string, dlpath string, addpaused bool) error

SendToTransmission configures a Transmission client with the provided credentials and settings, adds the torrent from the given URL to the client, specifying the download path and whether to start paused, and returns any error from the add operation.

func SetTraktToken

func SetTraktToken(tk *oauth2.Token)

SetTraktToken sets the OAuth 2.0 token used to authenticate with the Trakt API.

func UpdateTraktSerieSeasonsAndEpisodes

func UpdateTraktSerieSeasonsAndEpisodes(showid string, id *uint)

GetTraktSerieSeasonsAndEpisodes retrieves all seasons and episodes for the given Trakt show ID from the Trakt API. It takes the show ID and database series ID as parameters. It queries the local database for existing episodes to avoid duplicates. For each season, it calls addtraktdbepisodes to insert any missing episodes into the database. Returns nothing.

func UpdateTvdbSeriesEpisodes

func UpdateTvdbSeriesEpisodes(id int, language string, dbid uint)

GetTvdbSeriesEpisodes retrieves all episodes for the given TV series ID from TheTVDB API. It accepts the series ID, preferred language, and database series ID. It retrieves the episode data, checks for existing episodes to avoid duplicates, and inserts any missing episodes into the database. If there are multiple pages of results, it fetches additional pages.

func WebGet

func WebGet(url string) (*http.Response, error)

WebGetByte performs a GET request to the provided URL and returns the response body as a byte slice using a customized HTTP client with timeouts and other options set.

Types

type FileParser

type FileParser struct {
	Str              string                  // the file name string
	M                database.ParseInfo      // the parsed info
	Cfgp             *config.MediaTypeConfig // pointer to the media type config
	Allowsearchtitle bool                    // whether to allow search by title
	Filled           bool                    // whether the struct is filled
}

FileParser is a struct for parsing file names It contains fields for the file name string, parsed info, config pointer, whether to allow search by title, and if it is filled

func (*FileParser) Clear

func (s *FileParser) Clear()

func (*FileParser) Parsegroup

func (s *FileParser) Parsegroup(name string, group []string)

Parsegroup parses the given name and group strings from s.Str, setting the corresponding fields on s.M when matches are found. It searches s.Str for each string in group, checks for valid surrounding characters, and extracts the matched substring if found.

func (*FileParser) ParsegroupEntry

func (s *FileParser) ParsegroupEntry(name string, group string)

ParsegroupEntry parses a single group string from s.Str, setting the corresponding field on s.M when a match is found. It checks for valid surrounding characters before extracting the matched substring.

type Nzbwithprio

type Nzbwithprio struct {
	Info             FileParser                         // The parsed file name information
	NZB              nzb                                // The NZB details
	NzbmovieID       uint                               // The associated movie ID if this is a movie
	NzbepisodeID     uint                               // The associated episode ID if this is a TV episode
	Dbid             uint                               // The DBMovie or DBEpisode ID
	WantedTitle      string                             // The wanted title for this download
	WantedAlternates []database.DbstaticTwoStringOneInt // Alternate wanted titles
	Quality          string                             // The quality of this NZB
	Listname         string                             // The name of the list this NZB is from
	MinimumPriority  int                                // The minimum priority level
	Reason           string                             // The reason for denying this NZB
	AdditionalReason string                             // Any additional reason details
	DontSearch       bool                               // Whether to avoid searching for this
	DontUpgrade      bool                               // Whether to avoid upgrading this
}

Nzbwithprio is a struct containing information about an NZB found on the index It includes the parsed file name info, the NZB details, IDs, title, alternate titles, quality, list name, priority, reasons, and search flags

func (*Nzbwithprio) Close

func (s *Nzbwithprio) Close()

Close closes the Nzbwithprio by closing the Info field, setting the WantedAlternates field to nil if it has a capacity >= 1, and clearing the Nzbwithprio with the logger.

type TraktMovie

type TraktMovie struct {
	Title string `json:"title"`
	Year  int    `json:"year"`
	Ids   ids    `json:"ids"`
}

func GetTraktMoviePopular

func GetTraktMoviePopular(limit string) []TraktMovie

GetTraktMoviePopular retrieves a list of popular movies from the Trakt API. The limit parameter allows specifying the maximum number of movies to return. It returns a slice of TraktMovie structs containing the movie data, or nil if there was an error.

type TraktMovieAnticipated

type TraktMovieAnticipated struct {
	//ListCount int        `json:"list_count"`
	Movie TraktMovie `json:"movie"`
}

func GetTraktMovieAnticipated

func GetTraktMovieAnticipated(limit string) []TraktMovieAnticipated

GetTraktMovieAnticipated retrieves a list of anticipated movies from the Trakt API. The limit parameter allows specifying the maximum number of movies to return. It returns a slice of TraktMovieAnticipated structs containing the movie data, or nil if there was an error.

type TraktMovieTrending

type TraktMovieTrending struct {
	//Watchers int        `json:"watchers"`
	Movie TraktMovie `json:"movie"`
}

func GetTraktMovieTrending

func GetTraktMovieTrending(limit string) []TraktMovieTrending

GetTraktMovieTrending retrieves a list of trending movies from the Trakt API. The limit parameter allows specifying the maximum number of movies to return. It returns a slice of TraktMovieTrending structs containing the movie data, or nil if there was an error.

type TraktSerie

type TraktSerie struct {
	Title string `json:"title"`
	Year  int    `json:"year"`
	Ids   ids    `json:"ids"`
}

func GetTraktSeriePopular

func GetTraktSeriePopular(limit string) []TraktSerie

GetTraktSeriePopular retrieves popular TV shows from Trakt based on the number of watches and list additions. It takes an optional limit parameter to limit the number of results returned. Returns a slice of TraktSerie structs containing the popular show data.

type TraktSerieAnticipated

type TraktSerieAnticipated struct {
	//ListCount int        `json:"list_count"`
	Serie TraktSerie `json:"show"`
}

func GetTraktSerieAnticipated

func GetTraktSerieAnticipated(limit string) []TraktSerieAnticipated

GetTraktSerieAnticipated retrieves the most anticipated TV shows from Trakt based on the number of list adds. It takes an optional limit parameter to limit the number of results returned. Returns a slice of TraktSerieAnticipated structs containing the anticipated show data.

type TraktSerieTrending

type TraktSerieTrending struct {
	//Watchers int        `json:"watchers"`
	Serie TraktSerie `json:"show"`
}

func GetTraktSerieTrending

func GetTraktSerieTrending(limit string) []TraktSerieTrending

GetTraktSerieTrending retrieves the trending TV shows from Trakt based on the limit parameter. It returns a slice of TraktSerieTrending structs containing the trending show data.

type TraktUserList

type TraktUserList struct {
	//Rank      int        `json:"rank"`
	//ID        int        `json:"id"`
	//Notes     string     `json:"notes"`
	TraktType string     `json:"type"`
	Movie     TraktMovie `json:"movie"`
	Serie     TraktSerie `json:"show"`
}

func GetTraktUserList

func GetTraktUserList(username string, listname string, listtype string, limit string) ([]TraktUserList, error)

GetTraktUserList retrieves a Trakt user list by username, list name, list type, and optional limit. It returns a slice of TraktUserList structs containing the list data, and an error.

func GetTraktUserListAuth

func GetTraktUserListAuth(username string, listname string, listtype string, limit string) ([]TraktUserList, error)

GetTraktUserListAuth retrieves a Trakt user list with authentication. It takes the username, list name, list type, and optional limit parameters and returns the user list items as an array of TraktUserList structs and an error. Returns ErrNotFound if username, listname or listtype are empty.

type XMLResponse

type XMLResponse struct {
	Err       error
	FirstID   string
	BrokeLoop bool
}

XMLResponse represents the response from an XML API request. It contains fields for: - Err: Any error from the request - FirstID: The ID of the first result - BrokeLoop: Whether parsing broke out of the result loop early

func QueryNewznabMovieImdb

func QueryNewznabMovieImdb(cfgind *config.IndexersConfig, qual *config.QualityConfig, imdbid string, categories *config.QualityIndexerConfig, mu *sync.Mutex, results *[]Nzbwithprio) XMLResponse

QueryNewznabMovieImdb queries the Newznab indexer for movies matching the given IMDB ID. It builds the query URL based on the config, quality, and other parameters, executes the query, and stores the results in the given slice. Returns an error if one occurs.

func QueryNewznabQuery

func QueryNewznabQuery(cfgind *config.IndexersConfig, qual *config.QualityConfig, query string, categories *config.QualityIndexerConfig, mu *sync.Mutex, results *[]Nzbwithprio) XMLResponse

QueryNewznabQuery queries the Newznab API for the given search query, indexer configuration, quality config, categories, mutex, and result slice. It handles escaping the search query, adding quotes if configured, and limiting results. It returns any error that occurs.

func QueryNewznabRSS

func QueryNewznabRSS(ind *config.IndexersConfig, qual *config.QualityConfig, maxitems int, categories *config.QualityIndexerConfig, mu *sync.Mutex, results *[]Nzbwithprio) XMLResponse

QueryNewznabRSS queries the Newznab RSS feed for the given indexer configuration, quality config, max items, categories, mutex, and result slice. It returns a bool indicating if the results were truncated, and an error if one occurred.

func QueryNewznabRSSLast

func QueryNewznabRSSLast(cfgind *config.IndexersConfig, qual *config.QualityConfig, tillid string, categories *config.QualityIndexerConfig, mu *sync.Mutex, results *[]Nzbwithprio) XMLResponse

QueryNewznabRSSLast queries the Newznab RSS feed for the latest items matching the given configuration and quality parameters. It returns the latest item ID and any error.

func QueryNewznabRSSLastCustom

func QueryNewznabRSSLastCustom(ind *config.IndexersConfig, qual *config.QualityConfig, tillid string, categories *config.QualityIndexerConfig, mu *sync.Mutex, results *[]Nzbwithprio) XMLResponse

QueryNewznabRSSLastCustom queries the Newznab RSS feed for the latest items matching the given configuration and quality parameters. It handles pagination to retrieve multiple pages of results if needed. It returns the ID of the first result and any error.

func QueryNewznabTvTvdb

func QueryNewznabTvTvdb(cfgind *config.IndexersConfig, qual *config.QualityConfig, tvdbid int, categories *config.QualityIndexerConfig, season string, episode string, useseason bool, useepisode bool, mu *sync.Mutex, results *[]Nzbwithprio) XMLResponse

QueryNewznabTvTvdb queries the Newznab indexer for TV episodes matching the given TVDB ID, season, and episode. It builds the query URL based on the config, quality, and other parameters, executes the query, and stores the results in the given slice. Returns an error if one occurs.

Jump to

Keyboard shortcuts

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