-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into danzi-message-box
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package myradio | ||
|
||
import ( | ||
"strconv" | ||
|
||
"github.com/UniversityRadioYork/myradio-go/api" | ||
) | ||
|
||
// Podcast represents a podcast media item. | ||
type Podcast struct { | ||
PodcastID int `json:"podcast_id"` | ||
Title string | ||
Description string | ||
Status string | ||
Time Time | ||
Photo string | ||
File string `json:"uri"` | ||
EditLink Link `json:"editlink"` | ||
MicrositeLink Link `json:"micrositelink"` | ||
} | ||
|
||
// Get retrieves the data for a single podcast from MyRadio given it's ID. | ||
// This consumes one API request. | ||
func (s *Session) Get(id int) (podcast *Podcast, err error) { | ||
err = s.getf("/podcast/%d", id).Into(&podcast) | ||
return | ||
} | ||
|
||
// GetAllPodcasts retrieves the latest podcasts from MyRadio. | ||
// This consumes one API request. | ||
func (s *Session) GetAllPodcasts(numResults int, page int) (podcasts []Podcast, err error) { | ||
|
||
rq := api.NewRequest("/podcast/allpodcasts") | ||
rq.Params["num_results"] = []string{strconv.Itoa(numResults)} | ||
rq.Params["page"] = []string{strconv.Itoa(page)} | ||
rs := s.do(rq) | ||
|
||
if err := rs.Into(&podcasts); err != nil { | ||
return nil, err | ||
} | ||
return | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters