Compare commits

..

4 Commits

Author SHA1 Message Date
e3f6ff1fe2 Fix empty torrents returned as array in show episodes
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
The show episodes can handle undefined values themselves.
2020-04-10 16:41:24 +02:00
c9c3541b4e Fix torrent search on every keystroke
Cleanup the search results when leaving the page.
2020-04-10 16:41:24 +02:00
b66c32402a Add the torrent URL in the torrent button
This allows us to copy the link without clicking on the button.
2020-04-10 16:41:24 +02:00
88e5f87c62 Update papi and polochon to use the new torrent API 2020-04-10 16:35:24 +02:00
2 changed files with 22 additions and 22 deletions

View File

@ -25,8 +25,8 @@ const (
FROM episode_torrents WHERE imdb_id=$1 AND season=$2 AND episode=$3;`
)
// episodeTorrentDB represents the EpisodeTorrent in the DB
type episodeTorrentDB struct {
// EpisodeTorrentDB represents the EpisodeTorrent in the DB
type EpisodeTorrentDB struct {
ID string `db:"id"`
ImdbID string `db:"imdb_id"`
URL string `db:"url"`
@ -42,9 +42,9 @@ type episodeTorrentDB struct {
Updated time.Time `db:"updated_at"`
}
// newTorrentFromEpisodeTorrentDB returns a polochon.Torrent from an
// NewTorrentFromEpisodeTorrentDB returns a polochon.Torrent from an
// EpisodeTorrentDB
func newTorrentFromEpisodeTorrentDB(eDB *episodeTorrentDB) *polochon.Torrent {
func NewTorrentFromEpisodeTorrentDB(eDB *EpisodeTorrentDB) *polochon.Torrent {
return &polochon.Torrent{
ImdbID: eDB.ImdbID,
Type: polochon.TypeEpisode,
@ -62,10 +62,10 @@ func newTorrentFromEpisodeTorrentDB(eDB *episodeTorrentDB) *polochon.Torrent {
}
}
// newEpisodeTorrentDB returns an episodeTorrentDB ready to be put in DB from a
// NewEpisodeTorrentDB returns an EpisodeTorrentDB ready to be put in DB from a
// polochon.Torrent
func newEpisodeTorrentDB(t *polochon.Torrent) *episodeTorrentDB {
e := &episodeTorrentDB{
func NewEpisodeTorrentDB(t *polochon.Torrent) *EpisodeTorrentDB {
e := &EpisodeTorrentDB{
ImdbID: t.ImdbID,
Quality: string(t.Quality),
Season: t.Season,
@ -87,7 +87,7 @@ func newEpisodeTorrentDB(t *polochon.Torrent) *episodeTorrentDB {
// GetEpisodeTorrents returns show episodes torrents from database
func GetEpisodeTorrents(db *sqlx.DB, imdbID string, season, episode int) ([]*polochon.Torrent, error) {
var torrentsDB = []*episodeTorrentDB{}
var torrentsDB = []*EpisodeTorrentDB{}
err := db.Select(&torrentsDB, getEpisodeTorrentQuery, imdbID, season, episode)
if err != nil {
return nil, err
@ -99,7 +99,7 @@ func GetEpisodeTorrents(db *sqlx.DB, imdbID string, season, episode int) ([]*pol
var torrents []*polochon.Torrent
for _, torrentDB := range torrentsDB {
torrent := newTorrentFromEpisodeTorrentDB(torrentDB)
torrent := NewTorrentFromEpisodeTorrentDB(torrentDB)
torrents = append(torrents, torrent)
}
@ -109,7 +109,7 @@ func GetEpisodeTorrents(db *sqlx.DB, imdbID string, season, episode int) ([]*pol
// UpsertEpisodeTorrent upserts an episode torrent from a polochon torrent
func UpsertEpisodeTorrent(db *sqlx.DB, torrent *polochon.Torrent) error {
// Create the EpisodeTorrent ready to be put in db
eDB := newEpisodeTorrentDB(torrent)
eDB := NewEpisodeTorrentDB(torrent)
r, err := db.NamedQuery(upsertEpisodeTorrentQuery, eDB)
if err != nil {
return err

View File

@ -24,8 +24,8 @@ const (
FROM movie_torrents WHERE imdb_id=$1;`
)
// movieTorrentDB represents the MovieTorrent in the DB
type movieTorrentDB struct {
// MovieTorrentDB represents the MovieTorrent in the DB
type MovieTorrentDB struct {
ID string `db:"id"`
ImdbID string `db:"imdb_id"`
URL string `db:"url"`
@ -39,9 +39,9 @@ type movieTorrentDB struct {
Updated time.Time `db:"updated_at"`
}
// newTorrentFromMovieTorrentDB creates a new polochon.Torrent from a
// movieTorrentDB
func newTorrentFromMovieTorrentDB(mDB *movieTorrentDB) *polochon.Torrent {
// NewTorrentFromMovieTorrentDB creates a new polochon.Torrent from a
// MovieTorrentDB
func NewTorrentFromMovieTorrentDB(mDB *MovieTorrentDB) *polochon.Torrent {
return &polochon.Torrent{
ImdbID: mDB.ImdbID,
Quality: polochon.Quality(mDB.Quality),
@ -57,10 +57,10 @@ func newTorrentFromMovieTorrentDB(mDB *movieTorrentDB) *polochon.Torrent {
}
}
// newMovieTorrentDB returns a MovieTorrent ready to be put in DB from a
// NewMovieTorrentDB returns a MovieTorrent ready to be put in DB from a
// Torrent
func newMovieTorrentDB(t *polochon.Torrent) movieTorrentDB {
m := movieTorrentDB{
func NewMovieTorrentDB(t *polochon.Torrent) MovieTorrentDB {
m := MovieTorrentDB{
ImdbID: t.ImdbID,
Quality: string(t.Quality),
}
@ -80,7 +80,7 @@ func newMovieTorrentDB(t *polochon.Torrent) movieTorrentDB {
// GetMovieTorrents returns polochon.Torrents from the database
func GetMovieTorrents(db *sqlx.DB, imdbID string) ([]*polochon.Torrent, error) {
var torrentsDB = []*movieTorrentDB{}
var torrentsDB = []*MovieTorrentDB{}
// Get the torrents from the DB
err := db.Select(&torrentsDB, getMovieTorrentQueryByImdbID, imdbID)
if err != nil {
@ -91,10 +91,10 @@ func GetMovieTorrents(db *sqlx.DB, imdbID string) ([]*polochon.Torrent, error) {
return nil, sql.ErrNoRows
}
// Create polochon Torrents from the movieTorrentDB
// Create polochon Torrents from the MovieTorrentDB
var torrents []*polochon.Torrent
for _, torrentDB := range torrentsDB {
torrent := newTorrentFromMovieTorrentDB(torrentDB)
torrent := NewTorrentFromMovieTorrentDB(torrentDB)
torrents = append(torrents, torrent)
}
@ -103,7 +103,7 @@ func GetMovieTorrents(db *sqlx.DB, imdbID string) ([]*polochon.Torrent, error) {
// UpsertMovieTorrent adds or updates MovieTorrent in db
func UpsertMovieTorrent(db *sqlx.DB, t *polochon.Torrent) error {
mDB := newMovieTorrentDB(t)
mDB := NewMovieTorrentDB(t)
r, err := db.NamedQuery(upsertMovieTorrentQuery, mDB)
if err != nil {
return err