Skip to content

Commit

Permalink
Merge branch 'master' into danzi-message-box
Browse files Browse the repository at this point in the history
  • Loading branch information
Danzibob committed Apr 5, 2018
2 parents 4c350b8 + 9110249 commit aeb1196
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 0 deletions.
43 changes: 43 additions & 0 deletions podcast.go
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

}
19 changes: 19 additions & 0 deletions timeslot.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,25 @@ func (s *Session) GetCurrentAndNext() (can *CurrentAndNext, err error) {
return
}

// GetPreviousTimeslots gets the previous shows at the time of the call.
// This consumes one API request.
func (s *Session) GetPreviousTimeslots(numOfTimeslots int) (timeslots []Timeslot, err error) {
rq := api.NewRequest("/timeslot/previoustimeslots")
rq.Params["n"] = []string{strconv.Itoa(numOfTimeslots)}
rs := s.do(rq)

if err = rs.Into(&timeslots); err != nil {
return
}
for k := range timeslots {
err = timeslots[k].populateTimeslotTimes()
if err != nil {
return
}
}
return
}

// GetWeekSchedule gets the weekly schedule for ISO 8601 week week of year year.
// If such a schedule exists, it returns the result as an map from ISO 8601 weekdays to timeslot slices.
// Thus, 1 maps to Monday's timeslots; 2 to Tuesday; and so on.
Expand Down

0 comments on commit aeb1196

Please sign in to comment.