Compare commits
4 Commits
ae7c752e43
...
0797588e40
Author | SHA1 | Date | |
---|---|---|---|
0797588e40 | |||
7f91b145eb | |||
eff6b6e19f | |||
9494cf571f |
@ -7,7 +7,8 @@ import (
|
|||||||
|
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/models"
|
"git.quimbo.fr/odwrtw/canape/backend/models"
|
||||||
"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/odwrtw/polochon/lib/papi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TorrentEventer represents the Eventer for torrents
|
// TorrentEventer represents the Eventer for torrents
|
||||||
@ -16,7 +17,7 @@ type TorrentEventer struct {
|
|||||||
done chan struct{}
|
done chan struct{}
|
||||||
pClient *papi.Client
|
pClient *papi.Client
|
||||||
// previous keep the previous data
|
// previous keep the previous data
|
||||||
previous []*papi.Torrent
|
previous []*polochon.Torrent
|
||||||
// data holds the computed data
|
// data holds the computed data
|
||||||
data []*models.TorrentVideo
|
data []*models.TorrentVideo
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ func RefreshShows(env *web.Env) {
|
|||||||
|
|
||||||
// Iterate over the map of shows to refresh them
|
// Iterate over the map of shows to refresh them
|
||||||
for id := range showMap {
|
for id := range showMap {
|
||||||
show := shows.New(id, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
show := shows.New(id)
|
||||||
// Refresh the shows
|
// Refresh the shows
|
||||||
err := show.Refresh(env, env.Config.Show.Detailers)
|
err := show.Refresh(env, env.Config.Show.Detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -196,7 +196,7 @@ func RefreshMovies(env *web.Env) {
|
|||||||
|
|
||||||
// Iterate over the map of movies to refresh them
|
// Iterate over the map of movies to refresh them
|
||||||
for id := range movieMap {
|
for id := range movieMap {
|
||||||
movie := movies.New(env, id, nil, nil, false)
|
movie := movies.New(id, nil, nil, false)
|
||||||
// Refresh the movie
|
// Refresh the movie
|
||||||
err := movie.Refresh(env, env.Config.Movie.Detailers)
|
err := movie.Refresh(env, env.Config.Movie.Detailers)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -80,7 +80,7 @@ func GetMovies(env *web.Env, user *models.User, source string, category string)
|
|||||||
// Fill all the movies infos from the list of IDs
|
// Fill all the movies infos from the list of IDs
|
||||||
for _, id := range media.IDs {
|
for _, id := range media.IDs {
|
||||||
pMovie, _ := pMovies.Has(id)
|
pMovie, _ := pMovies.Has(id)
|
||||||
movie := movies.New(env, id, client, pMovie, moviesWishlist.IsMovieInWishlist(id))
|
movie := movies.New(id, client, pMovie, moviesWishlist.IsMovieInWishlist(id))
|
||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then with the default detailers
|
// Then with the default detailers
|
||||||
@ -141,7 +141,7 @@ func GetShows(env *web.Env, user *models.User, source string, category string, f
|
|||||||
for _, id := range media.IDs {
|
for _, id := range media.IDs {
|
||||||
pShow, _ := pShows.Has(id)
|
pShow, _ := pShows.Has(id)
|
||||||
wShow, _ := wShows.IsShowInWishlist(id)
|
wShow, _ := wShows.IsShowInWishlist(id)
|
||||||
show := shows.NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
show := shows.NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow)
|
||||||
|
|
||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/odwrtw/papi"
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -2,20 +2,19 @@ package models
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TorrentVideo reprensents a torrent embeding the video inforamtions
|
// TorrentVideo reprensents a torrent embeding the video inforamtions
|
||||||
type TorrentVideo struct {
|
type TorrentVideo struct {
|
||||||
*papi.Torrent
|
*polochon.Torrent
|
||||||
Img string `json:"img"`
|
Img string `json:"img"`
|
||||||
Video polochon.Video `json:"video,omitempty"`
|
Video polochon.Video `json:"video,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewTorrentVideo returns a new TorrentVideo
|
// NewTorrentVideo returns a new TorrentVideo
|
||||||
func NewTorrentVideo(t *papi.Torrent) *TorrentVideo {
|
func NewTorrentVideo(t *polochon.Torrent) *TorrentVideo {
|
||||||
torrent := &polochon.Torrent{
|
torrent := &polochon.Torrent{
|
||||||
ImdbID: t.ImdbID,
|
ImdbID: t.ImdbID,
|
||||||
Type: polochon.VideoType(t.Type),
|
Type: polochon.VideoType(t.Type),
|
||||||
@ -57,7 +56,7 @@ func (t *TorrentVideo) Update(detailer polochon.Detailer, db *sqlx.DB, log *logr
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewTorrentVideos returns a new slice of TorrentVideo from papi torrents
|
// NewTorrentVideos returns a new slice of TorrentVideo from papi torrents
|
||||||
func NewTorrentVideos(detailer polochon.Detailer, db *sqlx.DB, log *logrus.Entry, torrents []*papi.Torrent) []*TorrentVideo {
|
func NewTorrentVideos(detailer polochon.Detailer, db *sqlx.DB, log *logrus.Entry, torrents []*polochon.Torrent) []*TorrentVideo {
|
||||||
tv := make([]*TorrentVideo, len(torrents))
|
tv := make([]*TorrentVideo, len(torrents))
|
||||||
for i := range torrents {
|
for i := range torrents {
|
||||||
tv[i] = NewTorrentVideo(torrents[i])
|
tv[i] = NewTorrentVideo(torrents[i])
|
||||||
|
@ -4,10 +4,11 @@ import (
|
|||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/jmoiron/sqlx"
|
"github.com/jmoiron/sqlx"
|
||||||
"github.com/jmoiron/sqlx/types"
|
"github.com/jmoiron/sqlx/types"
|
||||||
"github.com/odwrtw/papi"
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -25,7 +26,15 @@ const (
|
|||||||
RETURNING *;`
|
RETURNING *;`
|
||||||
deleteUserQuery = `DELETE FROM users WHERE id=:id;`
|
deleteUserQuery = `DELETE FROM users WHERE id=:id;`
|
||||||
|
|
||||||
getAllUsersQuery = `SELECT * FROM users order by created_at;`
|
getAllUsersQuery = `
|
||||||
|
SELECT u.*, tok.last_seen
|
||||||
|
FROM users u
|
||||||
|
LEFT OUTER JOIN (
|
||||||
|
SELECT username, MAX(last_used) AS last_seen
|
||||||
|
FROM tokens GROUP BY username
|
||||||
|
) AS tok
|
||||||
|
ON u.name = tok.username;
|
||||||
|
`
|
||||||
getPolochonUsersQuery = `SELECT * FROM users WHERE polochon_id = $1;`
|
getPolochonUsersQuery = `SELECT * FROM users WHERE polochon_id = $1;`
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -51,6 +60,7 @@ type User struct {
|
|||||||
PolochonID sql.NullString `json:"polochon_id" db:"polochon_id"`
|
PolochonID sql.NullString `json:"polochon_id" db:"polochon_id"`
|
||||||
PolochonActivated bool `json:"polochon_activated" db:"polochon_activated"`
|
PolochonActivated bool `json:"polochon_activated" db:"polochon_activated"`
|
||||||
Polochon *Polochon `json:"polochon"`
|
Polochon *Polochon `json:"polochon"`
|
||||||
|
LastSeen *time.Time `json:"last_seen" db:"last_seen"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPapiClient creates a new papi client for the given user
|
// NewPapiClient creates a new papi client for the given user
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
_ "github.com/odwrtw/polochon/modules/mock"
|
_ "github.com/odwrtw/polochon/modules/mock"
|
||||||
_ "github.com/odwrtw/polochon/modules/openguessit"
|
_ "github.com/odwrtw/polochon/modules/openguessit"
|
||||||
_ "github.com/odwrtw/polochon/modules/opensubtitles"
|
_ "github.com/odwrtw/polochon/modules/opensubtitles"
|
||||||
_ "github.com/odwrtw/polochon/modules/pam"
|
|
||||||
_ "github.com/odwrtw/polochon/modules/pushover"
|
_ "github.com/odwrtw/polochon/modules/pushover"
|
||||||
_ "github.com/odwrtw/polochon/modules/tmdb"
|
_ "github.com/odwrtw/polochon/modules/tmdb"
|
||||||
_ "github.com/odwrtw/polochon/modules/tpb"
|
_ "github.com/odwrtw/polochon/modules/tpb"
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"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/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -76,7 +76,7 @@ func RefreshMovieHandler(env *web.Env, w http.ResponseWriter, r *http.Request) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create a new movie
|
// Create a new movie
|
||||||
m := New(env, id, client, pMovie, isWishlisted)
|
m := New(id, client, pMovie, isWishlisted)
|
||||||
|
|
||||||
// Refresh the movie's infos
|
// Refresh the movie's infos
|
||||||
if err := m.Refresh(env, env.Config.Movie.Detailers); err != nil {
|
if err := m.Refresh(env, env.Config.Movie.Detailers); err != nil {
|
||||||
@ -141,7 +141,6 @@ func SearchMovie(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
for _, m := range movies {
|
for _, m := range movies {
|
||||||
pMovie, _ := pMovies.Has(m.ImdbID)
|
pMovie, _ := pMovies.Has(m.ImdbID)
|
||||||
movie := New(
|
movie := New(
|
||||||
env,
|
|
||||||
m.ImdbID,
|
m.ImdbID,
|
||||||
client,
|
client,
|
||||||
pMovie,
|
pMovie,
|
||||||
@ -193,7 +192,7 @@ func PolochonDeleteHandler(env *web.Env, w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Delete the movie
|
// Delete the movie
|
||||||
return client.Delete(&papi.Movie{ImdbID: id})
|
return client.Delete(&papi.Movie{Movie: &polochon.Movie{ImdbID: id}})
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddToWishlist adds a movie to the user's wishlist
|
// AddToWishlist adds a movie to the user's wishlist
|
||||||
@ -251,7 +250,6 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
for _, imdbID := range moviesWishlist.List() {
|
for _, imdbID := range moviesWishlist.List() {
|
||||||
pMovie, _ := pMovies.Has(imdbID)
|
pMovie, _ := pMovies.Has(imdbID)
|
||||||
movie := New(
|
movie := New(
|
||||||
env,
|
|
||||||
imdbID,
|
imdbID,
|
||||||
client,
|
client,
|
||||||
pMovie,
|
pMovie,
|
||||||
@ -295,7 +293,7 @@ func RefreshMovieSubtitlesHandler(env *web.Env, w http.ResponseWriter, r *http.R
|
|||||||
return env.RenderError(w, err)
|
return env.RenderError(w, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
movie := &papi.Movie{ImdbID: id}
|
movie := &papi.Movie{Movie: &polochon.Movie{ImdbID: id}}
|
||||||
refreshSubs, err := client.UpdateSubtitles(movie)
|
refreshSubs, err := client.UpdateSubtitles(movie)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return env.RenderError(w, err)
|
return env.RenderError(w, err)
|
||||||
@ -329,7 +327,7 @@ func DownloadVVTSubtitle(env *web.Env, w http.ResponseWriter, r *http.Request) e
|
|||||||
return env.RenderError(w, err)
|
return env.RenderError(w, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
url, err := client.SubtitleURL(&papi.Movie{ImdbID: id}, lang)
|
url, err := client.SubtitleURL(&papi.Movie{Movie: &polochon.Movie{ImdbID: id}}, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return env.RenderError(w, err)
|
return env.RenderError(w, err)
|
||||||
}
|
}
|
||||||
|
@ -11,19 +11,17 @@ import (
|
|||||||
"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/errors"
|
"github.com/odwrtw/errors"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Movie represents a movie
|
// Movie represents a movie
|
||||||
type Movie struct {
|
type Movie struct {
|
||||||
*polochon.Movie
|
*polochon.Movie
|
||||||
client *papi.Client
|
client *papi.Client
|
||||||
pMovie *papi.Movie
|
pMovie *papi.Movie
|
||||||
publicDir string
|
Wishlisted bool `json:"wishlisted"`
|
||||||
imgURLPrefix string
|
|
||||||
Wishlisted bool `json:"wishlisted"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the Marshal interface
|
// MarshalJSON implements the Marshal interface
|
||||||
@ -54,7 +52,7 @@ func (m *Movie) MarshalJSON() ([]byte, error) {
|
|||||||
|
|
||||||
// Get the metadata
|
// Get the metadata
|
||||||
movieToMarshal.DateAdded = m.pMovie.DateAdded
|
movieToMarshal.DateAdded = m.pMovie.DateAdded
|
||||||
movieToMarshal.Quality = m.pMovie.Quality
|
movieToMarshal.Quality = string(m.pMovie.Quality)
|
||||||
movieToMarshal.AudioCodec = m.pMovie.AudioCodec
|
movieToMarshal.AudioCodec = m.pMovie.AudioCodec
|
||||||
movieToMarshal.VideoCodec = m.pMovie.VideoCodec
|
movieToMarshal.VideoCodec = m.pMovie.VideoCodec
|
||||||
movieToMarshal.Container = m.pMovie.Container
|
movieToMarshal.Container = m.pMovie.Container
|
||||||
@ -74,13 +72,11 @@ func (m *Movie) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new Movie with all the needed infos
|
// New returns a new Movie with all the needed infos
|
||||||
func New(env *web.Env, imdbID string, client *papi.Client, pMovie *papi.Movie, isWishlisted bool) *Movie {
|
func New(imdbID string, client *papi.Client, pMovie *papi.Movie, isWishlisted bool) *Movie {
|
||||||
return &Movie{
|
return &Movie{
|
||||||
client: client,
|
client: client,
|
||||||
pMovie: pMovie,
|
pMovie: pMovie,
|
||||||
publicDir: env.Config.PublicDir,
|
Wishlisted: isWishlisted,
|
||||||
imgURLPrefix: env.Config.ImgURLPrefix,
|
|
||||||
Wishlisted: isWishlisted,
|
|
||||||
Movie: &polochon.Movie{
|
Movie: &polochon.Movie{
|
||||||
ImdbID: imdbID,
|
ImdbID: imdbID,
|
||||||
},
|
},
|
||||||
@ -241,7 +237,7 @@ func (m *Movie) imgURL() string {
|
|||||||
|
|
||||||
// imgFile returns the image location on disk
|
// imgFile returns the image location on disk
|
||||||
func (m *Movie) imgFile() string {
|
func (m *Movie) imgFile() string {
|
||||||
return filepath.Join(m.publicDir, "img", m.imgURL())
|
return filepath.Join(models.PublicDir, "img", m.imgURL())
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPolochonMovies returns an array of the user's polochon movies
|
// getPolochonMovies returns an array of the user's polochon movies
|
||||||
@ -269,7 +265,6 @@ func getPolochonMovies(user *models.User, env *web.Env) ([]*Movie, error) {
|
|||||||
// Create Movies objects from the movies retrieved
|
// Create Movies objects from the movies retrieved
|
||||||
for _, pmovie := range pmovies.List() {
|
for _, pmovie := range pmovies.List() {
|
||||||
movie := New(
|
movie := New(
|
||||||
env,
|
|
||||||
pmovie.ImdbID,
|
pmovie.ImdbID,
|
||||||
client,
|
client,
|
||||||
pmovie,
|
pmovie,
|
||||||
|
@ -9,8 +9,8 @@ import (
|
|||||||
"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/errors"
|
"github.com/odwrtw/errors"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,13 +39,15 @@ func (e *Episode) MarshalJSON() ([]byte, error) {
|
|||||||
// Get the DownloadURL
|
// Get the DownloadURL
|
||||||
downloadURL, _ = e.show.client.DownloadURL(
|
downloadURL, _ = e.show.client.DownloadURL(
|
||||||
&papi.Episode{
|
&papi.Episode{
|
||||||
ShowImdbID: e.ShowImdbID,
|
ShowEpisode: &polochon.ShowEpisode{
|
||||||
Episode: e.Episode,
|
ShowImdbID: e.ShowImdbID,
|
||||||
Season: e.Season,
|
Episode: e.Episode,
|
||||||
|
Season: e.Season,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
dateAdded = pEpisode.DateAdded
|
dateAdded = pEpisode.DateAdded
|
||||||
quality = pEpisode.Quality
|
quality = string(pEpisode.Quality)
|
||||||
audioCodec = pEpisode.AudioCodec
|
audioCodec = pEpisode.AudioCodec
|
||||||
videoCodec = pEpisode.VideoCodec
|
videoCodec = pEpisode.VideoCodec
|
||||||
container = pEpisode.Container
|
container = pEpisode.Container
|
||||||
|
@ -14,8 +14,8 @@ import (
|
|||||||
"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/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ErrPolochonUnavailable is an error returned if the polochon server is not available
|
// ErrPolochonUnavailable is an error returned if the polochon server is not available
|
||||||
@ -43,7 +43,7 @@ func GetDetailsHandler(env *web.Env, w http.ResponseWriter, r *http.Request) err
|
|||||||
log.Println("Got error getting wishlisted show ", err)
|
log.Println("Got error getting wishlisted show ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s := NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
s := NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow)
|
||||||
// First try from the db
|
// First try from the db
|
||||||
first := []polochon.Detailer{env.Backend.Detailer}
|
first := []polochon.Detailer{env.Backend.Detailer}
|
||||||
// Then try from the polochon detailers
|
// Then try from the polochon detailers
|
||||||
@ -89,7 +89,7 @@ func RefreshShowHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
log.Println("Got error getting wishlisted show ", err)
|
log.Println("Got error getting wishlisted show ", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
s := NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
s := NewWithClient(&polochon.Show{ImdbID: id}, client, pShow, wShow)
|
||||||
// Refresh the polochon detailers
|
// Refresh the polochon detailers
|
||||||
detailers := env.Config.Show.Detailers
|
detailers := env.Config.Show.Detailers
|
||||||
err = s.Refresh(env, detailers)
|
err = s.Refresh(env, detailers)
|
||||||
@ -163,7 +163,7 @@ func SearchShow(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
|||||||
for _, s := range shows {
|
for _, s := range shows {
|
||||||
pShow, _ := pShows.Has(s.ImdbID)
|
pShow, _ := pShows.Has(s.ImdbID)
|
||||||
wShow, _ := wShows.IsShowInWishlist(s.ImdbID)
|
wShow, _ := wShows.IsShowInWishlist(s.ImdbID)
|
||||||
show := NewWithClient(s, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
show := NewWithClient(s, client, pShow, wShow)
|
||||||
|
|
||||||
// First try from the db
|
// First try from the db
|
||||||
first := []polochon.Detailer{env.Backend.Detailer}
|
first := []polochon.Detailer{env.Backend.Detailer}
|
||||||
@ -243,7 +243,7 @@ func GetWishlistHandler(env *web.Env, w http.ResponseWriter, r *http.Request) er
|
|||||||
for _, wishedShow := range wShows.List() {
|
for _, wishedShow := range wShows.List() {
|
||||||
pShow, _ := pShows.Has(wishedShow.ImdbID)
|
pShow, _ := pShows.Has(wishedShow.ImdbID)
|
||||||
poloShow := &polochon.Show{ImdbID: wishedShow.ImdbID}
|
poloShow := &polochon.Show{ImdbID: wishedShow.ImdbID}
|
||||||
show := NewWithClient(poloShow, client, pShow, wishedShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
show := NewWithClient(poloShow, client, pShow, wishedShow)
|
||||||
|
|
||||||
// First check in the DB
|
// First check in the DB
|
||||||
before := []polochon.Detailer{env.Backend.Detailer}
|
before := []polochon.Detailer{env.Backend.Detailer}
|
||||||
@ -309,11 +309,9 @@ func RefreshEpisodeHandler(env *web.Env, w http.ResponseWriter, r *http.Request)
|
|||||||
}
|
}
|
||||||
|
|
||||||
s := &Show{
|
s := &Show{
|
||||||
Show: &polochon.Show{ImdbID: id},
|
Show: &polochon.Show{ImdbID: id},
|
||||||
client: client,
|
client: client,
|
||||||
pShow: pShow,
|
pShow: pShow,
|
||||||
publicDir: env.Config.PublicDir,
|
|
||||||
imgURLPrefix: env.Config.ImgURLPrefix,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
e := NewEpisode(s, season, episode)
|
e := NewEpisode(s, season, episode)
|
||||||
@ -361,9 +359,11 @@ func RefreshEpisodeSubtitlesHandler(env *web.Env, w http.ResponseWriter, r *http
|
|||||||
}
|
}
|
||||||
|
|
||||||
e := &papi.Episode{
|
e := &papi.Episode{
|
||||||
ShowImdbID: id,
|
ShowEpisode: &polochon.ShowEpisode{
|
||||||
Season: season,
|
ShowImdbID: id,
|
||||||
Episode: episode,
|
Season: season,
|
||||||
|
Episode: episode,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshedSubs, err := client.UpdateSubtitles(e)
|
refreshedSubs, err := client.UpdateSubtitles(e)
|
||||||
@ -402,9 +402,11 @@ func DownloadVVTSubtitle(env *web.Env, w http.ResponseWriter, r *http.Request) e
|
|||||||
}
|
}
|
||||||
|
|
||||||
url, err := client.SubtitleURL(&papi.Episode{
|
url, err := client.SubtitleURL(&papi.Episode{
|
||||||
ShowImdbID: id,
|
ShowEpisode: &polochon.ShowEpisode{
|
||||||
Season: season,
|
ShowImdbID: id,
|
||||||
Episode: episode,
|
Season: season,
|
||||||
|
Episode: episode,
|
||||||
|
},
|
||||||
}, lang)
|
}, lang)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return env.RenderError(w, err)
|
return env.RenderError(w, err)
|
||||||
|
@ -10,8 +10,8 @@ import (
|
|||||||
"git.quimbo.fr/odwrtw/canape/backend/models"
|
"git.quimbo.fr/odwrtw/canape/backend/models"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
"github.com/odwrtw/errors"
|
"github.com/odwrtw/errors"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
|
"github.com/odwrtw/polochon/lib/papi"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,8 +22,6 @@ type Show struct {
|
|||||||
*polochon.Show
|
*polochon.Show
|
||||||
TrackedSeason *int `json:"tracked_season"`
|
TrackedSeason *int `json:"tracked_season"`
|
||||||
TrackedEpisode *int `json:"tracked_episode"`
|
TrackedEpisode *int `json:"tracked_episode"`
|
||||||
publicDir string
|
|
||||||
imgURLPrefix string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// MarshalJSON implements the Marshal interface
|
// MarshalJSON implements the Marshal interface
|
||||||
@ -55,24 +53,20 @@ func (s *Show) MarshalJSON() ([]byte, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// New returns a new Show with a polochon ShowConfig
|
// New returns a new Show with a polochon ShowConfig
|
||||||
func New(imdbID string, publicDir, imgURLPrefix string) *Show {
|
func New(imdbID string) *Show {
|
||||||
return &Show{
|
return &Show{
|
||||||
Show: &polochon.Show{
|
Show: &polochon.Show{
|
||||||
ImdbID: imdbID,
|
ImdbID: imdbID,
|
||||||
},
|
},
|
||||||
publicDir: publicDir,
|
|
||||||
imgURLPrefix: imgURLPrefix,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewWithClient returns a new Show with a polochon ShowConfig
|
// NewWithClient returns a new Show with a polochon ShowConfig
|
||||||
func NewWithClient(show *polochon.Show, client *papi.Client, pShow *papi.Show, wShow *models.WishedShow, publicDir, imgURLPrefix string) *Show {
|
func NewWithClient(show *polochon.Show, client *papi.Client, pShow *papi.Show, wShow *models.WishedShow) *Show {
|
||||||
s := &Show{
|
s := &Show{
|
||||||
Show: show,
|
Show: show,
|
||||||
client: client,
|
client: client,
|
||||||
pShow: pShow,
|
pShow: pShow,
|
||||||
publicDir: publicDir,
|
|
||||||
imgURLPrefix: imgURLPrefix,
|
|
||||||
}
|
}
|
||||||
if wShow != nil {
|
if wShow != nil {
|
||||||
s.TrackedSeason = &wShow.Season
|
s.TrackedSeason = &wShow.Season
|
||||||
@ -155,7 +149,7 @@ func (s *Show) GetImageURL(imgType string) string {
|
|||||||
if _, err := os.Stat(s.imgFile(imgType)); os.IsNotExist(err) {
|
if _, err := os.Stat(s.imgFile(imgType)); os.IsNotExist(err) {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return s.imgURLPrefix + s.imgURL(imgType)
|
return models.ImgURLPrefix + s.imgURL(imgType)
|
||||||
}
|
}
|
||||||
|
|
||||||
// downloadImages will download the show images
|
// downloadImages will download the show images
|
||||||
@ -217,12 +211,12 @@ func (s *Show) imgURL(imgType string) string {
|
|||||||
|
|
||||||
// imgDirectory returns the directory containing all the show images
|
// imgDirectory returns the directory containing all the show images
|
||||||
func (s *Show) imgDirectory() string {
|
func (s *Show) imgDirectory() string {
|
||||||
return filepath.Join(s.publicDir, "img", fmt.Sprintf("shows/%s", s.ImdbID))
|
return filepath.Join(models.PublicDir, "img", fmt.Sprintf("shows/%s", s.ImdbID))
|
||||||
}
|
}
|
||||||
|
|
||||||
// imgFile returns the image location on disk
|
// imgFile returns the image location on disk
|
||||||
func (s *Show) imgFile(imgType string) string {
|
func (s *Show) imgFile(imgType string) string {
|
||||||
return filepath.Join(s.publicDir, "img", s.imgURL(imgType))
|
return filepath.Join(models.PublicDir, "img", s.imgURL(imgType))
|
||||||
}
|
}
|
||||||
|
|
||||||
// getPolochonShows returns all the Shows from the polochon of a user
|
// getPolochonShows returns all the Shows from the polochon of a user
|
||||||
@ -248,7 +242,7 @@ func getPolochonShows(env *web.Env, user *models.User) ([]*Show, error) {
|
|||||||
// Create Shows objects from the shows retrieved
|
// Create Shows objects from the shows retrieved
|
||||||
for _, pShow := range pshows.List() {
|
for _, pShow := range pshows.List() {
|
||||||
wShow, _ := wShows.IsShowInWishlist(pShow.ImdbID)
|
wShow, _ := wShows.IsShowInWishlist(pShow.ImdbID)
|
||||||
show := NewWithClient(&polochon.Show{ImdbID: pShow.ImdbID}, client, pShow, wShow, env.Config.PublicDir, env.Config.ImgURLPrefix)
|
show := NewWithClient(&polochon.Show{ImdbID: pShow.ImdbID}, client, pShow, wShow)
|
||||||
shows = append(shows, show)
|
shows = append(shows, show)
|
||||||
}
|
}
|
||||||
return shows, nil
|
return shows, nil
|
||||||
|
@ -10,14 +10,13 @@ import (
|
|||||||
"git.quimbo.fr/odwrtw/canape/backend/models"
|
"git.quimbo.fr/odwrtw/canape/backend/models"
|
||||||
"git.quimbo.fr/odwrtw/canape/backend/web"
|
"git.quimbo.fr/odwrtw/canape/backend/web"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"github.com/odwrtw/papi"
|
|
||||||
polochon "github.com/odwrtw/polochon/lib"
|
polochon "github.com/odwrtw/polochon/lib"
|
||||||
"github.com/sirupsen/logrus"
|
"github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
// DownloadHandler downloads a movie via polochon
|
// DownloadHandler downloads a movie via polochon
|
||||||
func DownloadHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
func DownloadHandler(env *web.Env, w http.ResponseWriter, r *http.Request) error {
|
||||||
torrent := &papi.Torrent{}
|
torrent := &polochon.Torrent{}
|
||||||
err := json.NewDecoder(r.Body).Decode(torrent)
|
err := json.NewDecoder(r.Body).Decode(torrent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return env.RenderError(w, errors.New("failed to get the url"))
|
return env.RenderError(w, errors.New("failed to get the url"))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
|
import moment from "moment";
|
||||||
import PropTypes from "prop-types";
|
import PropTypes from "prop-types";
|
||||||
import { useSelector } from "react-redux";
|
import { useSelector } from "react-redux";
|
||||||
|
|
||||||
@ -7,10 +8,10 @@ import { UserEdit } from "./userEdit";
|
|||||||
export const User = ({ id }) => {
|
export const User = ({ id }) => {
|
||||||
const user = useSelector((state) => state.admin.users.get(id));
|
const user = useSelector((state) => state.admin.users.get(id));
|
||||||
const polochon = user.polochon;
|
const polochon = user.polochon;
|
||||||
|
const lastSeen = moment(user.last_seen, "YYYY-MM-DDTHH:mm:ss.SZ");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<tr>
|
<tr>
|
||||||
<td>{user.id}</td>
|
|
||||||
<td>{user.name}</td>
|
<td>{user.name}</td>
|
||||||
<td>
|
<td>
|
||||||
<span
|
<span
|
||||||
@ -32,6 +33,7 @@ export const User = ({ id }) => {
|
|||||||
}
|
}
|
||||||
></span>
|
></span>
|
||||||
</td>
|
</td>
|
||||||
|
<td>{lastSeen.isValid() ? lastSeen.fromNow() : "-"}</td>
|
||||||
<td>
|
<td>
|
||||||
<UserEdit id={id} />
|
<UserEdit id={id} />
|
||||||
</td>
|
</td>
|
||||||
|
@ -24,13 +24,13 @@ export const UserList = () => {
|
|||||||
<table className="table table-striped">
|
<table className="table table-striped">
|
||||||
<thead className="table-secondary">
|
<thead className="table-secondary">
|
||||||
<tr>
|
<tr>
|
||||||
<th>#</th>
|
|
||||||
<th>Name</th>
|
<th>Name</th>
|
||||||
<th>Activated</th>
|
<th>Activated</th>
|
||||||
<th>Admin</th>
|
<th>Admin</th>
|
||||||
<th>Polochon URL</th>
|
<th>Polochon URL</th>
|
||||||
<th>Polochon token</th>
|
<th>Polochon token</th>
|
||||||
<th>Polochon activated</th>
|
<th>Polochon activated</th>
|
||||||
|
<th>Last seen</th>
|
||||||
<th>Actions</th>
|
<th>Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
@ -51,15 +51,17 @@ export default (state = defaultState, action) =>
|
|||||||
});
|
});
|
||||||
|
|
||||||
let seasonMap = new Map();
|
let seasonMap = new Map();
|
||||||
seasonNumbers.sort().forEach((n) => {
|
seasonNumbers
|
||||||
let episodes = [];
|
.sort((a, b) => a - b)
|
||||||
seasons[n]
|
.forEach((n) => {
|
||||||
.sort((a, b) => a.episode - b.episode)
|
let episodes = [];
|
||||||
.forEach((episode) => {
|
seasons[n]
|
||||||
episodes.push([episode.episode, episode]);
|
.sort((a, b) => a.episode - b.episode)
|
||||||
});
|
.forEach((episode) => {
|
||||||
seasonMap.set(n, new Map(episodes));
|
episodes.push([episode.episode, episode]);
|
||||||
});
|
});
|
||||||
|
seasonMap.set(n, new Map(episodes));
|
||||||
|
});
|
||||||
draft.show.seasons = seasonMap;
|
draft.show.seasons = seasonMap;
|
||||||
|
|
||||||
draft.loading = false;
|
draft.loading = false;
|
||||||
|
3
go.mod
3
go.mod
@ -15,8 +15,7 @@ require (
|
|||||||
github.com/mattn/go-sqlite3 v1.10.0 // indirect
|
github.com/mattn/go-sqlite3 v1.10.0 // indirect
|
||||||
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646
|
||||||
github.com/odwrtw/errors v0.0.0-20170604160533-c747b9d17833
|
github.com/odwrtw/errors v0.0.0-20170604160533-c747b9d17833
|
||||||
github.com/odwrtw/papi v0.0.0-20200416090004-26e95d2feb66
|
github.com/odwrtw/polochon v0.0.0-20200416140115-2ad474aa633d
|
||||||
github.com/odwrtw/polochon v0.0.0-20200416085801-6331a40936bf
|
|
||||||
github.com/phyber/negroni-gzip v0.0.0-20180113114010-ef6356a5d029
|
github.com/phyber/negroni-gzip v0.0.0-20180113114010-ef6356a5d029
|
||||||
github.com/pioz/tvdb v0.0.0-20190503215423-f45c687faba9 // indirect
|
github.com/pioz/tvdb v0.0.0-20190503215423-f45c687faba9 // indirect
|
||||||
github.com/robfig/cron v1.1.0
|
github.com/robfig/cron v1.1.0
|
||||||
|
6
go.sum
6
go.sum
@ -134,10 +134,8 @@ github.com/odwrtw/guessit v0.0.0-20200131084001-f88613483547/go.mod h1:W22g7wtc0
|
|||||||
github.com/odwrtw/imdb-watchlist v0.0.0-20190417175016-b7a9f7503d69 h1:ow6b/4Jj7J5iYwU678/rbijvaNUJrYkg13j9Nivkung=
|
github.com/odwrtw/imdb-watchlist v0.0.0-20190417175016-b7a9f7503d69 h1:ow6b/4Jj7J5iYwU678/rbijvaNUJrYkg13j9Nivkung=
|
||||||
github.com/odwrtw/imdb-watchlist v0.0.0-20190417175016-b7a9f7503d69/go.mod h1:o2tLH95CtNdqhDb0aS2NbU+1I4PmaNsODpr33Ry0JC0=
|
github.com/odwrtw/imdb-watchlist v0.0.0-20190417175016-b7a9f7503d69/go.mod h1:o2tLH95CtNdqhDb0aS2NbU+1I4PmaNsODpr33Ry0JC0=
|
||||||
github.com/odwrtw/papi v0.0.0-20190413103029-bd5bfea85ae6/go.mod h1:CXotdtODLpW0/yuFV5XH8Rmrj0eAfPLvdMKykPM2WCk=
|
github.com/odwrtw/papi v0.0.0-20190413103029-bd5bfea85ae6/go.mod h1:CXotdtODLpW0/yuFV5XH8Rmrj0eAfPLvdMKykPM2WCk=
|
||||||
github.com/odwrtw/papi v0.0.0-20200416090004-26e95d2feb66 h1:E+UrY1WG5xp65UXs2rbtVVD4FdSffMR9E0lbd7xdf80=
|
github.com/odwrtw/polochon v0.0.0-20200416140115-2ad474aa633d h1:jquS1D5p2ldxmbbWW4Vg2FCmvXxIIhq5zeoHSpwGtLw=
|
||||||
github.com/odwrtw/papi v0.0.0-20200416090004-26e95d2feb66/go.mod h1:eY0skvVHJBwbSJ18uq2c1T4SvhdEV8R0XFSb0zKh5Yo=
|
github.com/odwrtw/polochon v0.0.0-20200416140115-2ad474aa633d/go.mod h1:rBjekia21ToZoTxJqR/5Ued8EYwKTtamq+bo/XINOjA=
|
||||||
github.com/odwrtw/polochon v0.0.0-20200416085801-6331a40936bf h1:zzsX9o1Gxe1esokjdcOMa5hMC2aqubWXQoAEqMCMyyY=
|
|
||||||
github.com/odwrtw/polochon v0.0.0-20200416085801-6331a40936bf/go.mod h1:rBjekia21ToZoTxJqR/5Ued8EYwKTtamq+bo/XINOjA=
|
|
||||||
github.com/odwrtw/tpb v0.0.0-20200130133144-c846aa382c6f h1:fwEIGT+o3e8+XkBqrwsE3/+9ketTQXflPhCkv3/w990=
|
github.com/odwrtw/tpb v0.0.0-20200130133144-c846aa382c6f h1:fwEIGT+o3e8+XkBqrwsE3/+9ketTQXflPhCkv3/w990=
|
||||||
github.com/odwrtw/tpb v0.0.0-20200130133144-c846aa382c6f/go.mod h1:updLvMbQo2xHoz94MX9+GqmSoKhf6E8fs/J+wLvvu6A=
|
github.com/odwrtw/tpb v0.0.0-20200130133144-c846aa382c6f/go.mod h1:updLvMbQo2xHoz94MX9+GqmSoKhf6E8fs/J+wLvvu6A=
|
||||||
github.com/odwrtw/trakttv v0.0.0-20200404161731-0d594827e4f9 h1:PuQLHO75MXUsJpf9BcTVxvR/FCkdn1MZnZt6h3o6cJI=
|
github.com/odwrtw/trakttv v0.0.0-20200404161731-0d594827e4f9 h1:PuQLHO75MXUsJpf9BcTVxvR/FCkdn1MZnZt6h3o6cJI=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user