golift.io/starr@v1.0.0/readarr/metadataprofile.go (about)

     1  package readarr
     2  
     3  import (
     4  	"context"
     5  	"fmt"
     6  
     7  	"golift.io/starr"
     8  )
     9  
    10  const bpMetadataProfile = APIver + "/metadataprofile"
    11  
    12  // MetadataProfile is the /api/v1/metadataProfile endpoint.
    13  type MetadataProfile struct {
    14  	ID                  int64   `json:"id"`
    15  	Name                string  `json:"name"`
    16  	MinPopularity       float64 `json:"minPopularity"`
    17  	SkipMissingDate     bool    `json:"skipMissingDate"`
    18  	SkipMissingIsbn     bool    `json:"skipMissingIsbn"`
    19  	SkipPartsAndSets    bool    `json:"skipPartsAndSets"`
    20  	SkipSeriesSecondary bool    `json:"skipSeriesSecondary"`
    21  	AllowedLanguages    string  `json:"allowedLanguages,omitempty"`
    22  }
    23  
    24  // GetMetadataProfiles returns the metadata profiles.
    25  func (r *Readarr) GetMetadataProfiles() ([]*MetadataProfile, error) {
    26  	return r.GetMetadataProfilesContext(context.Background())
    27  }
    28  
    29  // GetMetadataProfilesContext returns the metadata profiles.
    30  func (r *Readarr) GetMetadataProfilesContext(ctx context.Context) ([]*MetadataProfile, error) {
    31  	var output []*MetadataProfile
    32  
    33  	req := starr.Request{URI: bpMetadataProfile}
    34  	if err := r.GetInto(ctx, req, &output); err != nil {
    35  		return nil, fmt.Errorf("api.Get(%s): %w", &req, err)
    36  	}
    37  
    38  	return output, nil
    39  }