Add polochon metadata in movies and shows
This commit is contained in:
parent
1a30447ab1
commit
178375eb8d
@ -6,13 +6,14 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/users"
|
"git.quimbo.fr/odwrtw/canape/backend/users"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
"github.com/odwrtw/papi"
|
"github.com/odwrtw/papi"
|
||||||
"github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -30,34 +31,43 @@ type Movie struct {
|
|||||||
func (m *Movie) MarshalJSON() ([]byte, error) {
|
func (m *Movie) MarshalJSON() ([]byte, error) {
|
||||||
type Alias Movie
|
type Alias Movie
|
||||||
|
|
||||||
var downloadURL string
|
|
||||||
var subs []subtitles.Subtitle
|
|
||||||
// If the episode is present, fill the downloadURL
|
|
||||||
if m.pMovie != nil {
|
|
||||||
// Get the DownloadURL
|
|
||||||
downloadURL, _ = m.client.DownloadURL(m.pMovie)
|
|
||||||
// Append the Subtitles
|
|
||||||
for _, l := range m.pMovie.Subtitles {
|
|
||||||
subtitleURL, _ := m.client.SubtitleURL(m.pMovie, l)
|
|
||||||
subs = append(subs, subtitles.Subtitle{
|
|
||||||
Language: l,
|
|
||||||
URL: subtitleURL,
|
|
||||||
VVTFile: fmt.Sprintf("/movies/%s/subtitles/%s", m.ImdbID, l),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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 []subtitles.Subtitle `json:"subtitles"`
|
Subtitles []subtitles.Subtitle `json:"subtitles"`
|
||||||
|
DateAdded time.Time `json:"date_added"`
|
||||||
|
Quality string `json:"quality"`
|
||||||
|
AudioCodec string `json:"audio_codec"`
|
||||||
|
VideoCodec string `json:"video_codec"`
|
||||||
|
Container string `json:"container"`
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(m),
|
Alias: (*Alias)(m),
|
||||||
PolochonURL: downloadURL,
|
|
||||||
PosterURL: m.PosterURL(),
|
PosterURL: m.PosterURL(),
|
||||||
Subtitles: subs,
|
Subtitles: []subtitles.Subtitle{},
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.pMovie != nil {
|
||||||
|
// Get the DownloadURL
|
||||||
|
movieToMarshal.PolochonURL, _ = m.client.DownloadURL(m.pMovie)
|
||||||
|
|
||||||
|
// Get the metadata
|
||||||
|
movieToMarshal.DateAdded = m.pMovie.DateAdded
|
||||||
|
movieToMarshal.Quality = m.pMovie.Quality
|
||||||
|
movieToMarshal.AudioCodec = m.pMovie.AudioCodec
|
||||||
|
movieToMarshal.VideoCodec = m.pMovie.VideoCodec
|
||||||
|
movieToMarshal.Container = m.pMovie.Container
|
||||||
|
|
||||||
|
// Append the Subtitles
|
||||||
|
for _, l := range m.pMovie.Subtitles {
|
||||||
|
subtitleURL, _ := m.client.SubtitleURL(m.pMovie, l)
|
||||||
|
movieToMarshal.Subtitles = append(movieToMarshal.Subtitles, subtitles.Subtitle{
|
||||||
|
Language: l,
|
||||||
|
URL: subtitleURL,
|
||||||
|
VVTFile: fmt.Sprintf("/movies/%s/subtitles/%s", m.ImdbID, l),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(movieToMarshal)
|
return json.Marshal(movieToMarshal)
|
||||||
|
@ -3,13 +3,14 @@ package shows
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
"git.quimbo.fr/odwrtw/canape/backend/backend"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
"git.quimbo.fr/odwrtw/canape/backend/subtitles"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
|
"github.com/odwrtw/papi"
|
||||||
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Episode represents an episode
|
// Episode represents an episode
|
||||||
@ -25,6 +26,12 @@ func (e *Episode) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
var downloadURL string
|
var downloadURL string
|
||||||
var subs []subtitles.Subtitle
|
var subs []subtitles.Subtitle
|
||||||
|
var dateAdded time.Time
|
||||||
|
var quality string
|
||||||
|
var audioCodec string
|
||||||
|
var videoCodec string
|
||||||
|
var container string
|
||||||
|
|
||||||
// If the episode is present, fill the downloadURL
|
// If the episode is present, fill the downloadURL
|
||||||
if e.pShow != nil {
|
if e.pShow != nil {
|
||||||
pEpisode := e.pShow.GetEpisode(e.Season, e.Episode)
|
pEpisode := e.pShow.GetEpisode(e.Season, e.Episode)
|
||||||
@ -37,6 +44,12 @@ func (e *Episode) MarshalJSON() ([]byte, error) {
|
|||||||
Season: e.Season,
|
Season: e.Season,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
dateAdded = pEpisode.DateAdded
|
||||||
|
quality = pEpisode.Quality
|
||||||
|
audioCodec = pEpisode.AudioCodec
|
||||||
|
videoCodec = pEpisode.VideoCodec
|
||||||
|
container = pEpisode.Container
|
||||||
|
|
||||||
// Append the Subtitles
|
// Append the Subtitles
|
||||||
for _, l := range pEpisode.Subtitles {
|
for _, l := range pEpisode.Subtitles {
|
||||||
subtitleURL, _ := e.client.SubtitleURL(pEpisode, l)
|
subtitleURL, _ := e.client.SubtitleURL(pEpisode, l)
|
||||||
@ -54,10 +67,20 @@ func (e *Episode) MarshalJSON() ([]byte, error) {
|
|||||||
*alias
|
*alias
|
||||||
PolochonURL string `json:"polochon_url"`
|
PolochonURL string `json:"polochon_url"`
|
||||||
Subtitles []subtitles.Subtitle `json:"subtitles"`
|
Subtitles []subtitles.Subtitle `json:"subtitles"`
|
||||||
|
DateAdded time.Time `json:"date_added"`
|
||||||
|
Quality string `json:"quality"`
|
||||||
|
AudioCodec string `json:"audio_codec"`
|
||||||
|
VideoCodec string `json:"video_codec"`
|
||||||
|
Container string `json:"container"`
|
||||||
}{
|
}{
|
||||||
alias: (*alias)(e),
|
alias: (*alias)(e),
|
||||||
PolochonURL: downloadURL,
|
PolochonURL: downloadURL,
|
||||||
Subtitles: subs,
|
Subtitles: subs,
|
||||||
|
DateAdded: dateAdded,
|
||||||
|
Quality: quality,
|
||||||
|
AudioCodec: audioCodec,
|
||||||
|
VideoCodec: videoCodec,
|
||||||
|
Container: container,
|
||||||
}
|
}
|
||||||
|
|
||||||
return json.Marshal(episodeToMarshal)
|
return json.Marshal(episodeToMarshal)
|
||||||
|
@ -18,6 +18,13 @@ export default function ListDetails(props) {
|
|||||||
rating={props.data.get("rating")}
|
rating={props.data.get("rating")}
|
||||||
votes={props.data.get("votes")}
|
votes={props.data.get("votes")}
|
||||||
/>
|
/>
|
||||||
|
<PolochonMetadata
|
||||||
|
quality={props.data.get("quality")}
|
||||||
|
releaseGroup={props.data.get("release_group")}
|
||||||
|
container={props.data.get("container")}
|
||||||
|
audioCodec={props.data.get("audio_codec")}
|
||||||
|
videoCodec={props.data.get("video_codec")}
|
||||||
|
/>
|
||||||
<p className="plot">{props.data.get("plot")}</p>
|
<p className="plot">{props.data.get("plot")}</p>
|
||||||
</div>
|
</div>
|
||||||
{props.children}
|
{props.children}
|
||||||
@ -77,6 +84,22 @@ function TrackingLabel(props) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PolochonMetadata(props) {
|
||||||
|
if (!props.quality || props.quality === "") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<p className="spaced-icons">
|
||||||
|
<span className="label label-default">{props.quality}</span>
|
||||||
|
<span className="label label-default">{props.container} </span>
|
||||||
|
<span className="label label-default">{props.videoCodec}</span>
|
||||||
|
<span className="label label-default">{props.audioCodec}</span>
|
||||||
|
<span className="label label-default">{props.releaseGroup}</span>
|
||||||
|
</p>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Genres(props) {
|
function Genres(props) {
|
||||||
if (props.genres === undefined) {
|
if (props.genres === undefined) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -179,6 +179,22 @@ class Season extends React.Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function PolochonMetadata(props) {
|
||||||
|
if (!props.quality || props.quality === "") {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<span>
|
||||||
|
<span className="badge badge-pill badge-secondary">{props.quality}</span>
|
||||||
|
<span className="badge badge-pill badge-secondary">{props.container} </span>
|
||||||
|
<span className="badge badge-pill badge-secondary">{props.videoCodec}</span>
|
||||||
|
<span className="badge badge-pill badge-secondary">{props.audioCodec}</span>
|
||||||
|
<span className="badge badge-pill badge-secondary">{props.releaseGroup}</span>
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
function Episode(props) {
|
function Episode(props) {
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
@ -191,7 +207,13 @@ function Episode(props) {
|
|||||||
</th>
|
</th>
|
||||||
<td className="col-xs-12">
|
<td className="col-xs-12">
|
||||||
{props.data.get("title")}
|
{props.data.get("title")}
|
||||||
|
<PolochonMetadata
|
||||||
|
quality={props.data.get("quality")}
|
||||||
|
releaseGroup={props.data.get("release_group")}
|
||||||
|
container={props.data.get("container")}
|
||||||
|
audioCodec={props.data.get("audio_codec")}
|
||||||
|
videoCodec={props.data.get("video_codec")}
|
||||||
|
/>
|
||||||
<span className="pull-right episode-buttons">
|
<span className="pull-right episode-buttons">
|
||||||
{props.data.get("polochon_url") !== "" &&
|
{props.data.get("polochon_url") !== "" &&
|
||||||
<SubtitlesButton
|
<SubtitlesButton
|
||||||
|
Loading…
x
Reference in New Issue
Block a user