Merge branch 'subtitle' into 'master'
Add subtitles See merge request !66
This commit is contained in:
commit
63e9d5b4e2
@ -31,20 +31,36 @@ func (m *Movie) MarshalJSON() ([]byte, error) {
|
|||||||
type Alias Movie
|
type Alias Movie
|
||||||
|
|
||||||
var downloadURL string
|
var downloadURL string
|
||||||
|
type Subtitle struct {
|
||||||
|
Language string `json:"language"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
var subtitles []Subtitle
|
||||||
// If the episode is present, fill the downloadURL
|
// If the episode is present, fill the downloadURL
|
||||||
if m.pMovie != nil {
|
if m.pMovie != nil {
|
||||||
|
// Get the DownloadURL
|
||||||
downloadURL, _ = m.client.DownloadURL(m.pMovie)
|
downloadURL, _ = m.client.DownloadURL(m.pMovie)
|
||||||
|
// Append the Subtitles
|
||||||
|
for _, l := range m.pMovie.Subtitles {
|
||||||
|
subtitleURL, _ := m.client.SubtitleURL(m.pMovie, l)
|
||||||
|
subtitles = append(subtitles, Subtitle{
|
||||||
|
Language: l,
|
||||||
|
URL: subtitleURL,
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal the movie with its polochon_url
|
// Marshal the movie with its polochon_url
|
||||||
movieToMarshal := &struct {
|
movieToMarshal := &struct {
|
||||||
*Alias
|
*Alias
|
||||||
PolochonURL string `json:"polochon_url"`
|
PolochonURL string `json:"polochon_url"`
|
||||||
PosterURL string `json:"poster_url"`
|
PosterURL string `json:"poster_url"`
|
||||||
|
Subtitles []Subtitle `json:"subtitles"`
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(m),
|
Alias: (*Alias)(m),
|
||||||
PolochonURL: downloadURL,
|
PolochonURL: downloadURL,
|
||||||
PosterURL: m.PosterURL(),
|
PosterURL: m.PosterURL(),
|
||||||
|
Subtitles: subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(movieToMarshal)
|
return json.Marshal(movieToMarshal)
|
||||||
|
@ -23,24 +23,43 @@ func (e *Episode) MarshalJSON() ([]byte, error) {
|
|||||||
type alias Episode
|
type alias Episode
|
||||||
|
|
||||||
var downloadURL string
|
var downloadURL string
|
||||||
|
type Subtitle struct {
|
||||||
|
Language string `json:"language"`
|
||||||
|
URL string `json:"url"`
|
||||||
|
}
|
||||||
|
var subtitles []Subtitle
|
||||||
// If the episode is present, fill the downloadURL
|
// If the episode is present, fill the downloadURL
|
||||||
if e.pShow != nil && e.pShow.HasEpisode(e.Season, e.Episode) {
|
if e.pShow != nil {
|
||||||
downloadURL, _ = e.client.DownloadURL(
|
pEpisode := e.pShow.GetEpisode(e.Season, e.Episode)
|
||||||
&papi.Episode{
|
if pEpisode != nil {
|
||||||
ShowImdbID: e.ShowImdbID,
|
// Get the DownloadURL
|
||||||
Episode: e.Episode,
|
downloadURL, _ = e.client.DownloadURL(
|
||||||
Season: e.Season,
|
&papi.Episode{
|
||||||
},
|
ShowImdbID: e.ShowImdbID,
|
||||||
)
|
Episode: e.Episode,
|
||||||
|
Season: e.Season,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
// Append the Subtitles
|
||||||
|
for _, l := range pEpisode.Subtitles {
|
||||||
|
subtitleURL, _ := e.client.SubtitleURL(pEpisode, l)
|
||||||
|
subtitles = append(subtitles, Subtitle{
|
||||||
|
Language: l,
|
||||||
|
URL: subtitleURL,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Marshal the episode with its polochon_url
|
// Marshal the episode with its polochon_url
|
||||||
episodeToMarshal := &struct {
|
episodeToMarshal := &struct {
|
||||||
*alias
|
*alias
|
||||||
PolochonURL string `json:"polochon_url"`
|
PolochonURL string `json:"polochon_url"`
|
||||||
|
Subtitles []Subtitle `json:"subtitles"`
|
||||||
}{
|
}{
|
||||||
alias: (*alias)(e),
|
alias: (*alias)(e),
|
||||||
PolochonURL: downloadURL,
|
PolochonURL: downloadURL,
|
||||||
|
Subtitles: subtitles,
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(episodeToMarshal)
|
return json.Marshal(episodeToMarshal)
|
||||||
|
@ -48,7 +48,7 @@ export function request(eventPrefix, promise, callbackEvents = null) {
|
|||||||
})
|
})
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
// Unauthorized
|
// Unauthorized
|
||||||
if (error.response.status == 401) {
|
if (error.response && error.response.status == 401) {
|
||||||
dispatch({
|
dispatch({
|
||||||
type: 'USER_LOGOUT',
|
type: 'USER_LOGOUT',
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user