Skip to content

Commit

Permalink
Merge 2b93bfd into cd89d9c
Browse files Browse the repository at this point in the history
  • Loading branch information
darthShadow committed Jan 22, 2020
2 parents cd89d9c + 2b93bfd commit eabd363
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ results, _ := client.SearchWithTVMaze(categories, 80, 3, 1)

### Search using a name and set of categories:
```
results, _ := client.SearchWithQueries(categories, "Oldboy", "movie")
results, _ := client.SearchWithQuery(categories, "Oldboy", "movie")
```

### Get latest releases for set of categories:
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ require (
github.com/stretchr/testify v1.3.0
golang.org/x/sys v0.0.0-20190405154228-4b34438f7a67 // indirect
)

go 1.13
10 changes: 9 additions & 1 deletion newznab/newznab.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type Client struct {
apiBaseURL string
apiUserID int
client *http.Client

ExtendedAttrs bool
}

// New returns a new instance of Client
Expand Down Expand Up @@ -227,6 +229,7 @@ func (c Client) process(vals url.Values, path string) ([]NZB, error) {
DownloadURL: gotNZB.Enclosure.URL,
SourceEndpoint: c.apiBaseURL,
SourceAPIKey: c.apikey,
UnmatchedAttrs: make(map[string]string),
}
for _, attr := range gotNZB.Attributes {
switch attr.Name {
Expand Down Expand Up @@ -303,7 +306,8 @@ func (c Client) process(vals url.Values, path string) ([]NZB, error) {
log.WithFields(log.Fields{
"name": attr.Name,
"value": attr.Value,
}).Debug("encontered unknown attribute")
}).Debug("encountered unknown attribute")
nzb.UnmatchedAttrs[attr.Name] = attr.Value
}
}
if nzb.Size == 0 {
Expand Down Expand Up @@ -383,6 +387,10 @@ func (c Client) buildURL(vals url.Values, path string) (string, error) {
return "", errors.Wrap(err, "failed to parse base API url")
}

if c.ExtendedAttrs {
vals["extended"] = []string{"1"}
}

parsedURL.RawQuery = vals.Encode()
return parsedURL.String(), nil
}
Expand Down
3 changes: 3 additions & 0 deletions newznab/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ type NZB struct {
InfoHash string `json:"infohash,omitempty"`
DownloadURL string `json:"download_url,omitempty"`
IsTorrent bool `json:"is_torrent,omitempty"`

// All the unmatched attributes from the response
UnmatchedAttrs map[string]string
}

// Comment represents a user comment left on an NZB record
Expand Down

0 comments on commit eabd363

Please sign in to comment.