Compare commits
15 Commits
morevidefi
...
rememberLo
Author | SHA1 | Date | |
---|---|---|---|
9b23666fe6 | |||
1adafef4e1 | |||
43091ff7ed | |||
12dc8427aa | |||
23d91973d7 | |||
e513877019 | |||
be2b848f8e | |||
08310f78bb | |||
3d1671d6b5 | |||
c2a5d88743 | |||
3588df7c4f | |||
0df96a093f | |||
5b2eff3f6d | |||
ecef80f87f | |||
881281af70 |
@ -93,11 +93,9 @@ Debian_Server:
|
||||
- vers=$(grep -Po '"version":.*?[^\\]",' package.json | grep -Po '[0-9]+\.[0-9]+\.[0-9]+') # parse the version out of package .json
|
||||
- cd deb
|
||||
- mkdir -p "./OpenMediaCenter/var/www/openmediacenter/videos/"
|
||||
- mkdir -p "./OpenMediaCenter/tmp/"
|
||||
- mkdir -p "./OpenMediaCenter/usr/bin/"
|
||||
- cp -r ../build/* ./OpenMediaCenter/var/www/openmediacenter/
|
||||
- cp ../apiGo/openmediacenter ./OpenMediaCenter/usr/bin/
|
||||
- cp ../database.sql ./OpenMediaCenter/tmp/openmediacenter.sql
|
||||
- 'echo "Version: ${vers}" >> ./OpenMediaCenter/DEBIAN/control'
|
||||
- chmod -R 0775 *
|
||||
- dpkg-deb --build OpenMediaCenter
|
||||
@ -117,8 +115,11 @@ Test_Server:
|
||||
- Frontend_Tests
|
||||
- Backend_Tests
|
||||
- Debian_Server
|
||||
only:
|
||||
- master
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH # run this always on default branch
|
||||
- if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH # allow triggering this manually
|
||||
when: manual
|
||||
allow_failure: true
|
||||
script:
|
||||
- eval $(ssh-agent -s)
|
||||
- echo "$SSH_PRIVATE_KEY" | ssh-add -
|
||||
@ -128,3 +129,24 @@ Test_Server:
|
||||
- ssh root@192.168.0.42 "DEBIAN_FRONTEND=noninteractive apt-get --reinstall -y -qq install /tmp/OpenMediaCenter-*.deb && rm /tmp/OpenMediaCenter-*.deb"
|
||||
allow_failure: true
|
||||
|
||||
Test_Server_2:
|
||||
stage: deploy
|
||||
image: luki42/ssh:latest
|
||||
needs:
|
||||
- Frontend_Tests
|
||||
- Backend_Tests
|
||||
- Debian_Server
|
||||
rules:
|
||||
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH # run this always on default branch
|
||||
- if: $CI_COMMIT_REF_NAME != $CI_DEFAULT_BRANCH # allow triggering this manually
|
||||
when: manual
|
||||
allow_failure: true
|
||||
script:
|
||||
- eval $(ssh-agent -s)
|
||||
- echo "$SSH_PRIVATE_KEY_2" | ssh-add -
|
||||
- mkdir -p ~/.ssh
|
||||
- '[[ -f /.dockerenv ]] && echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
|
||||
- scp deb/OpenMediaCenter-*.deb root@192.168.0.209:/tmp/
|
||||
- ssh root@192.168.0.209 "DEBIAN_FRONTEND=noninteractive apt-get --reinstall -y -qq install /tmp/OpenMediaCenter-*.deb && rm /tmp/OpenMediaCenter-*.deb"
|
||||
allow_failure: true
|
||||
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"openmediacenter/apiGo/database"
|
||||
"openmediacenter/apiGo/videoparser"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
|
||||
func addUploadHandler() {
|
||||
@ -30,11 +31,11 @@ func addUploadHandler() {
|
||||
break
|
||||
}
|
||||
|
||||
// todo allow more video formats than mp4
|
||||
// only allow valid extensions
|
||||
if !videoparser.ValidVideoSuffix(part.FileName()) {
|
||||
if filepath.Ext(part.FileName()) != ".mp4" {
|
||||
continue
|
||||
}
|
||||
|
||||
vidpath := PathPrefix + mSettings.VideoPath + part.FileName()
|
||||
dst, err := os.OpenFile(vidpath, os.O_WRONLY|os.O_CREATE, 0644)
|
||||
if err != nil {
|
||||
|
@ -2,6 +2,7 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/url"
|
||||
"openmediacenter/apiGo/api/api"
|
||||
"openmediacenter/apiGo/api/types"
|
||||
@ -73,12 +74,12 @@ func getVideoHandlers() {
|
||||
var query string
|
||||
// 1 is the id of the ALL tag
|
||||
if args.Tag != 1 {
|
||||
query = fmt.Sprintf(`SELECT movie_id,movie_name,t.tag_name FROM videos
|
||||
query = fmt.Sprintf(`SELECT movie_id,movie_name,previewratio,t.tag_name FROM videos
|
||||
INNER JOIN video_tags vt on videos.movie_id = vt.video_id
|
||||
INNER JOIN tags t on vt.tag_id = t.tag_id
|
||||
WHERE t.tag_id = %d %s`, args.Tag, SortClause)
|
||||
} else {
|
||||
query = fmt.Sprintf("SELECT movie_id,movie_name, (SELECT 'All' as tag_name) FROM videos %s", SortClause)
|
||||
query = fmt.Sprintf("SELECT movie_id,movie_name,previewratio, (SELECT 'All' as tag_name) FROM videos %s", SortClause)
|
||||
}
|
||||
|
||||
var result struct {
|
||||
@ -91,7 +92,7 @@ func getVideoHandlers() {
|
||||
var name string
|
||||
for rows.Next() {
|
||||
var vid types.VideoUnloadedType
|
||||
err := rows.Scan(&vid.MovieId, &vid.MovieName, &name)
|
||||
err := rows.Scan(&vid.MovieId, &vid.MovieName, &vid.Ratio, &name)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@ -163,18 +164,25 @@ func getVideoHandlers() {
|
||||
api.AddHandler("getRandomMovies", api.VideoNode, api.PermUser, func(context api.Context) {
|
||||
var args struct {
|
||||
Number int
|
||||
Seed *int
|
||||
}
|
||||
if api.DecodeRequest(context.GetRequest(), &args) != nil {
|
||||
context.Text("unable to decode request")
|
||||
return
|
||||
}
|
||||
|
||||
// if Seed argument not passed generate random seed
|
||||
if args.Seed == nil {
|
||||
r := rand.Int()
|
||||
args.Seed = &r
|
||||
}
|
||||
|
||||
var result struct {
|
||||
Tags []types.Tag
|
||||
Videos []types.VideoUnloadedType
|
||||
}
|
||||
|
||||
query := fmt.Sprintf("SELECT movie_id,movie_name FROM videos ORDER BY RAND() LIMIT %d", args.Number)
|
||||
query := fmt.Sprintf("SELECT movie_id,movie_name FROM videos ORDER BY RAND(%d) LIMIT %d", *args.Seed, args.Number)
|
||||
result.Videos = readVideosFromResultset(database.Query(query))
|
||||
|
||||
var ids string
|
||||
@ -276,14 +284,14 @@ func loadVideosHandlers() {
|
||||
return
|
||||
}
|
||||
|
||||
query := fmt.Sprintf(`SELECT movie_name,movie_url,movie_id,thumbnail,poster,likes,quality,length
|
||||
query := fmt.Sprintf(`SELECT movie_name,movie_url,movie_id,thumbnail,poster,likes,quality,length,release_date
|
||||
FROM videos WHERE movie_id=%d`, args.MovieId)
|
||||
|
||||
var res types.FullVideoType
|
||||
var poster []byte
|
||||
var thumbnail []byte
|
||||
|
||||
err := database.QueryRow(query).Scan(&res.MovieName, &res.MovieUrl, &res.MovieId, &thumbnail, &poster, &res.Likes, &res.Quality, &res.Length)
|
||||
err := database.QueryRow(query).Scan(&res.MovieName, &res.MovieUrl, &res.MovieId, &thumbnail, &poster, &res.Likes, &res.Quality, &res.Length, &res.ReleaseDate)
|
||||
if err != nil {
|
||||
fmt.Printf("Error getting full data list of videoid - %d", args.MovieId)
|
||||
fmt.Println(err.Error())
|
||||
|
@ -3,16 +3,11 @@ package api
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dgrijalva/jwt-go"
|
||||
"gopkg.in/oauth2.v3"
|
||||
"gopkg.in/oauth2.v3/server"
|
||||
"net/http"
|
||||
"openmediacenter/apiGo/database"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
var srv *server.Server
|
||||
|
||||
type Perm uint8
|
||||
|
||||
const (
|
||||
@ -103,15 +98,3 @@ func InitOAuth() {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
func ValidateToken(f func(rw http.ResponseWriter, req *http.Request, node int, tokenInfo *oauth2.TokenInfo), node int) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
tokeninfo, err := srv.ValidationBearerToken(r)
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
return
|
||||
}
|
||||
|
||||
f(w, r, node, &tokeninfo)
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
func Jsonify(v interface{}) []byte {
|
||||
@ -29,3 +30,45 @@ func DecodeRequest(request *http.Request, arg interface{}) error {
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
// setField set a specific field of an object with an object provided
|
||||
func setField(obj interface{}, name string, value interface{}) error {
|
||||
structValue := reflect.ValueOf(obj).Elem()
|
||||
structFieldValue := structValue.FieldByName(name)
|
||||
|
||||
if !structFieldValue.IsValid() {
|
||||
return fmt.Errorf("no such field: %s in obj", name)
|
||||
}
|
||||
|
||||
if !structFieldValue.CanSet() {
|
||||
return fmt.Errorf("cannot set %s field value", name)
|
||||
}
|
||||
|
||||
structFieldType := structFieldValue.Type()
|
||||
val := reflect.ValueOf(value)
|
||||
|
||||
if structFieldType != val.Type() {
|
||||
if val.Type().ConvertibleTo(structFieldType) {
|
||||
// if type is convertible - convert and set
|
||||
structFieldValue.Set(val.Convert(structFieldType))
|
||||
} else {
|
||||
return fmt.Errorf("provided value %s type didn't match obj field type and isn't convertible", name)
|
||||
}
|
||||
} else {
|
||||
// set value if type is the same
|
||||
structFieldValue.Set(val)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// FillStruct fill a custom struct with objects of a map
|
||||
func FillStruct(i interface{}, m map[string]interface{}) error {
|
||||
for k, v := range m {
|
||||
err := setField(i, k, v)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package types
|
||||
type VideoUnloadedType struct {
|
||||
MovieId int
|
||||
MovieName string
|
||||
Ratio float32
|
||||
}
|
||||
|
||||
type FullVideoType struct {
|
||||
@ -10,6 +11,7 @@ type FullVideoType struct {
|
||||
MovieId uint32
|
||||
MovieUrl string
|
||||
Poster string
|
||||
ReleaseDate *string
|
||||
Likes uint64
|
||||
Quality uint16
|
||||
Length uint16
|
||||
|
@ -2,16 +2,23 @@ package database
|
||||
|
||||
import (
|
||||
"database/sql"
|
||||
"embed"
|
||||
"fmt"
|
||||
_ "github.com/go-sql-driver/mysql"
|
||||
"github.com/pressly/goose/v3"
|
||||
"log"
|
||||
"openmediacenter/apiGo/api/types"
|
||||
"openmediacenter/apiGo/config"
|
||||
"os"
|
||||
)
|
||||
|
||||
var db *sql.DB
|
||||
var DBName string
|
||||
|
||||
func InitDB() {
|
||||
//go:embed migrations/*.sql
|
||||
var embedMigrations embed.FS
|
||||
|
||||
func InitDB() error {
|
||||
dbconf := config.GetConfig().Database
|
||||
DBName = dbconf.DBName
|
||||
|
||||
@ -21,15 +28,32 @@ func InitDB() {
|
||||
|
||||
// if there is an error opening the connection, handle it
|
||||
if err != nil {
|
||||
fmt.Printf("Error while connecting to database! - %s\n", err.Error())
|
||||
return fmt.Errorf("Error while connecting to database! - %s\n", err.Error())
|
||||
}
|
||||
|
||||
if db != nil {
|
||||
ping := db.Ping()
|
||||
if ping != nil {
|
||||
fmt.Printf("Error while connecting to database! - %s\n", ping.Error())
|
||||
return fmt.Errorf("Error while connecting to database! - %s\n", ping.Error())
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Println("Running Database migrations!")
|
||||
// perform database migrations
|
||||
goose.SetBaseFS(embedMigrations)
|
||||
goose.SetLogger(log.New(os.Stdout, "", 0))
|
||||
|
||||
// set mysql dialect
|
||||
err = goose.SetDialect("mysql")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := goose.Up(db, "migrations"); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Query(query string, args ...interface{}) *sql.Rows {
|
||||
|
122
apiGo/database/migrations/20210927231631_init.sql
Normal file
122
apiGo/database/migrations/20210927231631_init.sql
Normal file
@ -0,0 +1,122 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
create table if not exists actors
|
||||
(
|
||||
actor_id int auto_increment
|
||||
primary key,
|
||||
name varchar(50) null,
|
||||
thumbnail mediumblob null
|
||||
)
|
||||
comment 'informations about different actors';
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists settings
|
||||
(
|
||||
video_path varchar(255) null,
|
||||
episode_path varchar(255) null,
|
||||
password varchar(32) default '-1' null,
|
||||
mediacenter_name varchar(32) default 'OpenMediaCenter' null,
|
||||
TMDB_grabbing tinyint null,
|
||||
DarkMode tinyint default 0 null
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists tags
|
||||
(
|
||||
tag_id int auto_increment
|
||||
primary key,
|
||||
tag_name varchar(50) null
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists tvshow
|
||||
(
|
||||
name varchar(100) null,
|
||||
thumbnail mediumblob null,
|
||||
id int auto_increment
|
||||
primary key,
|
||||
foldername varchar(100) null
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists tvshow_episodes
|
||||
(
|
||||
id int auto_increment
|
||||
primary key,
|
||||
name varchar(100) null,
|
||||
season int null,
|
||||
poster mediumblob null,
|
||||
tvshow_id int null,
|
||||
episode int null,
|
||||
filename varchar(100) null,
|
||||
constraint tvshow_episodes_tvshow_id_fk
|
||||
foreign key (tvshow_id) references tvshow (id)
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists videos
|
||||
(
|
||||
movie_id int auto_increment
|
||||
primary key,
|
||||
movie_name varchar(200) null,
|
||||
movie_url varchar(250) null,
|
||||
thumbnail mediumblob null,
|
||||
poster mediumblob null,
|
||||
likes int default 0 null,
|
||||
quality int default 0 null,
|
||||
length int default 0 null comment 'in seconds',
|
||||
create_date datetime default current_timestamp() null
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists actors_videos
|
||||
(
|
||||
actor_id int null,
|
||||
video_id int null,
|
||||
constraint actors_videos_actors_id_fk
|
||||
foreign key (actor_id) references actors (actor_id),
|
||||
constraint actors_videos_videos_movie_id_fk
|
||||
foreign key (video_id) references videos (movie_id)
|
||||
);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create index if not exists actors_videos_actor_id_index
|
||||
on actors_videos (actor_id);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create index if not exists actors_videos_video_id_index
|
||||
on actors_videos (video_id);
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
create table if not exists video_tags
|
||||
(
|
||||
tag_id int null,
|
||||
video_id int null,
|
||||
constraint video_tags_tags_tag_id_fk
|
||||
foreign key (tag_id) references tags (tag_id),
|
||||
constraint video_tags_videos_movie_id_fk
|
||||
foreign key (video_id) references videos (movie_id)
|
||||
on delete cascade
|
||||
);
|
||||
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
INSERT IGNORE INTO tags (tag_id, tag_name)
|
||||
VALUES (2, 'fullhd');
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
INSERT IGNORE INTO tags (tag_id, tag_name)
|
||||
VALUES (3, 'lowquality');
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
INSERT IGNORE INTO tags (tag_id, tag_name)
|
||||
VALUES (4, 'hd');
|
||||
-- +goose StatementEnd
|
||||
-- +goose StatementBegin
|
||||
INSERT IGNORE INTO settings (video_path, episode_path, password, mediacenter_name)
|
||||
VALUES ('./videos/', './tvshows/', -1, 'OpenMediaCenter');
|
||||
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
12
apiGo/database/migrations/20210927235150_relese_date.sql
Normal file
12
apiGo/database/migrations/20210927235150_relese_date.sql
Normal file
@ -0,0 +1,12 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
alter table videos
|
||||
add release_date date null;
|
||||
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
alter table videos
|
||||
drop release_date;
|
||||
-- +goose StatementEnd
|
11
apiGo/database/migrations/20211001195845_width_height.sql
Normal file
11
apiGo/database/migrations/20211001195845_width_height.sql
Normal file
@ -0,0 +1,11 @@
|
||||
-- +goose Up
|
||||
-- +goose StatementBegin
|
||||
alter table videos
|
||||
add previewratio FLOAT default -1.0 null;
|
||||
-- +goose StatementEnd
|
||||
|
||||
-- +goose Down
|
||||
-- +goose StatementBegin
|
||||
alter table videos
|
||||
drop previewratio;
|
||||
-- +goose StatementEnd
|
@ -5,9 +5,9 @@ go 1.16
|
||||
require (
|
||||
github.com/3d0c/gmf v0.0.0-20210925211039-e278e6e53b16
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/go-sql-driver/mysql v1.5.0
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.3
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
|
||||
gopkg.in/oauth2.v3 v3.12.0
|
||||
github.com/pressly/goose/v3 v3.1.0
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
|
||||
nhooyr.io/websocket v1.8.7
|
||||
)
|
||||
|
119
apiGo/go.sum
119
apiGo/go.sum
@ -1,19 +1,14 @@
|
||||
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/3d0c/gmf v0.0.0-20210925211039-e278e6e53b16 h1:LX3XWmS88yKgWJcMXb8vusphpDBe9+6LTI9FyHeFFWQ=
|
||||
github.com/3d0c/gmf v0.0.0-20210925211039-e278e6e53b16/go.mod h1:0QMRcUq2JsDECeAq7bj4h79k7XbhtTsrPUQf6G7qfPs=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/ClickHouse/clickhouse-go v1.4.5/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI=
|
||||
github.com/bkaradzic/go-lz4 v1.0.0/go.mod h1:0YdlkowM3VswSROI7qDxhRvJ3sLhlFrRRwjwegp5jy4=
|
||||
github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/denisenkom/go-mssqldb v0.10.0/go.mod h1:xbL0rPBG9cCiLr28tMa8zpbdarY27NDyej4t/EjAShU=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072/go.mod h1:duJ4Jxv5lDcvg4QuQr0oowTf7dz4/CR8NtyCooz9HL8=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gavv/httpexpect v2.0.0+incompatible h1:1X9kcRshkSKEjNJJxX9Y9mQ5BRfbxU5kORdjhlA1yX8=
|
||||
github.com/gavv/httpexpect v2.0.0+incompatible/go.mod h1:x+9tiU1YnrOvnB725RkpoLv1M62hOWzwo5OXotisrKc=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.6.3 h1:ahKqKTFpO5KTPHxWZjEdPScmYaGtLo8Y4DMHoEsnp14=
|
||||
@ -25,134 +20,78 @@ github.com/go-playground/universal-translator v0.17.0 h1:icxd5fm+REJzpZx7ZfpaD87
|
||||
github.com/go-playground/universal-translator v0.17.0/go.mod h1:UkSxE5sNxxRwHyU+Scu5vgOQjsIJAF8j9muTVoKLVtA=
|
||||
github.com/go-playground/validator/v10 v10.2.0 h1:KgJ0snyC2R9VXYN2rneOtQcw5aHQB1Vv0sFl1UcHBOY=
|
||||
github.com/go-playground/validator/v10 v10.2.0/go.mod h1:uOYAAleCW8F/7oMFd6aG0GOhaH6EGOAJShg8Id5JGkI=
|
||||
github.com/go-session/session v3.1.2+incompatible/go.mod h1:8B3iivBQjrz/JtC68Np2T1yBBLxTan3mn/3OM0CyRt0=
|
||||
github.com/go-sql-driver/mysql v1.5.0 h1:ozyZYNQW3x3HtqT1jira07DN2PArx2v7/mN66gGcHOs=
|
||||
github.com/go-sql-driver/mysql v1.5.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w=
|
||||
github.com/go-sql-driver/mysql v1.6.0 h1:BCTh4TKNUYmOmMUcQ3IipzF5prigylS7XXjEkfCHuOE=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee h1:s+21KNqlpePfkah2I+gwHF8xmJWRjooY+5248k6m4A0=
|
||||
github.com/gobwas/httphead v0.0.0-20180130184737-2c6c146eadee/go.mod h1:L0fX3K22YWvt/FAX9NnzrNzcI4wNYi9Yku4O0LKYflo=
|
||||
github.com/gobwas/pool v0.2.0 h1:QEmUOlnSjWtnpRGHF3SauEiOsy82Cup83Vf2LcMlnc8=
|
||||
github.com/gobwas/pool v0.2.0/go.mod h1:q8bcK0KcYlCgd9e7WYLm9LpyS+YeLd8JVDW6WezmKEw=
|
||||
github.com/gobwas/ws v1.0.2 h1:CoAavW/wd/kulfZmSIBt6p24n4j7tHgNVCjsfHVNUbo=
|
||||
github.com/gobwas/ws v1.0.2/go.mod h1:szmBTxLgaFppYjEmNtny/v3w89xOydFnnZMcgRRu/EM=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
|
||||
github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw=
|
||||
github.com/golang/protobuf v1.3.5 h1:F768QJ1E9tib+q5Sc8MkdJi1RxLTbRcTf8LJV56aRls=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
github.com/google/go-cmp v0.4.0 h1:xsAVV57WRhGj6kEIi8ReJzQlHHqcBYCElAvkovg3B/4=
|
||||
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-querystring v1.0.0 h1:Xkwi/a1rcvNg1PPYe5vI8GbeBY/jrVuDX5ASuANWTrk=
|
||||
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
||||
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
|
||||
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk=
|
||||
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
|
||||
github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
|
||||
github.com/json-iterator/go v1.1.9 h1:9yzud/Ht36ygwatGx56VwCZtlI/2AD15T1X2sjSuGns=
|
||||
github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4=
|
||||
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
|
||||
github.com/k0kubun/colorstring v0.0.0-20150214042306-9440f1994b88/go.mod h1:3w7q1U84EfirKl04SVQ/s7nPm1ZPhiXd34z40TNz36k=
|
||||
github.com/klauspost/compress v1.8.2/go.mod h1:RyIbtBH6LamlWaDj8nUwkbUhJ87Yi3uG0guNDohfE1A=
|
||||
github.com/klauspost/compress v1.10.3 h1:OP96hzwJVBIHYU52pVTI6CczrxPvrGfgqF9N5eTO0Q8=
|
||||
github.com/klauspost/compress v1.10.3/go.mod h1:aoV0uJVorq1K+umq18yTdKaF57EivdYsUV+/s2qKfXs=
|
||||
github.com/klauspost/cpuid v1.2.1/go.mod h1:Pj4uuM528wm8OyEC2QMXAi2YiTZ96dNQPGgoMS4s3ek=
|
||||
github.com/leodido/go-urn v1.2.0 h1:hpXL4XnriNwQ/ABnpepYM/1vCLWNDfUNts8dX3xTG6Y=
|
||||
github.com/leodido/go-urn v1.2.0/go.mod h1:+8+nEpDfqqsY+g338gtMEUOtuK+4dEMhiQEgxpxOKII=
|
||||
github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc=
|
||||
github.com/mattn/go-sqlite3 v1.14.8 h1:gDp86IdQsN/xWjIEmr9MF6o9mpksUgh0fu+9ByFxzIU=
|
||||
github.com/mattn/go-sqlite3 v1.14.8/go.mod h1:NyWgC/yNuGj7Q9rpYnZvas74GogHl5/Z4A/KQRfk6bU=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421 h1:ZqeYNhU3OHLH3mGKHDcjJRFFRrJa6eAM5H+CtDdOsPc=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742 h1:Esafd1046DLDQ0W1YjYsBW+p8U2u7vzgW2SQVmlNazg=
|
||||
github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
||||
github.com/moul/http2curl v1.0.0 h1:dRMWoAtb+ePxMlLkrCbAqh4TlPHXvoGUSQ323/9Zahs=
|
||||
github.com/moul/http2curl v1.0.0/go.mod h1:8UbvGypXm98wA/IqH45anm5Y2Z6ep6O31QGOAZ3H0fQ=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.10.2/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/gomega v1.7.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.3 h1:PNCTU4naEJ8mKal97P3A2qDU74QRQGlv4FXiL1XDqi4=
|
||||
github.com/pelletier/go-toml/v2 v2.0.0-beta.3/go.mod h1:aNseLYu/uKskg0zpr/kbr2z8yGuWtotWf/0BpGIAL2Y=
|
||||
github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
|
||||
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
|
||||
github.com/pressly/goose/v3 v3.1.0 h1:V2Ulfm2XL9GtYNmrPUNFHieimf6diwADyMObnuuR2Mc=
|
||||
github.com/pressly/goose/v3 v3.1.0/go.mod h1:tYsY0oL0yd48jg15POIZfOZiu66mqWpfDd/nJ28KWyU=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942 h1:t0lM6y/M5IiUZyvbBTcngso8SZEZICH7is9B6g/obVU=
|
||||
github.com/stretchr/testify v1.7.1-0.20210427113832-6241f9ab9942/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/tidwall/btree v0.0.0-20170113224114-9876f1454cf0 h1:QnyrPZZvPmR0AtJCxxfCtI1qN+fYpKTKJ/5opWmZ34k=
|
||||
github.com/tidwall/btree v0.0.0-20170113224114-9876f1454cf0/go.mod h1:huei1BkDWJ3/sLXmO+bsCNELL+Bp2Kks9OLyQFkzvA8=
|
||||
github.com/tidwall/buntdb v1.1.0 h1:H6LzK59KiNjf1nHVPFrYj4Qnl8d8YLBsYamdL8N+Bao=
|
||||
github.com/tidwall/buntdb v1.1.0/go.mod h1:Y39xhcDW10WlyYXeLgGftXVbjtM0QP+/kpz8xl9cbzE=
|
||||
github.com/tidwall/gjson v1.3.2 h1:+7p3qQFaH3fOMXAJSrdZwGKcOO/lYdGS0HqGhPqDdTI=
|
||||
github.com/tidwall/gjson v1.3.2/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
|
||||
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb h1:5NSYaAdrnblKByzd7XByQEJVT8+9v0W/tIY0Oo4OwrE=
|
||||
github.com/tidwall/grect v0.0.0-20161006141115-ba9a043346eb/go.mod h1:lKYYLFIr9OIgdgrtgkZ9zgRxRdvPYsExnYBsEAd8W5M=
|
||||
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
|
||||
github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E=
|
||||
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
|
||||
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
|
||||
github.com/tidwall/rtree v0.0.0-20180113144539-6cd427091e0e h1:+NL1GDIUOKxVfbp2KoJQD9cTQ6dyP2co9q4yzmT9FZo=
|
||||
github.com/tidwall/rtree v0.0.0-20180113144539-6cd427091e0e/go.mod h1:/h+UnNGt0IhNNJLkGikcdcJqm66zGD/uJGMRxK/9+Ao=
|
||||
github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563 h1:Otn9S136ELckZ3KKDyCkxapfufrqDqwmGjcHfAyXRrE=
|
||||
github.com/tidwall/tinyqueue v0.0.0-20180302190814-1e39f5511563/go.mod h1:mLqSmt7Dv/CNneF2wfcChfN1rvapyQr01LGKnKex0DQ=
|
||||
github.com/ugorji/go v1.1.7 h1:/68gy2h+1mWMrwZFeD1kQialdSzAb432dtpeJ42ovdo=
|
||||
github.com/ugorji/go v1.1.7/go.mod h1:kZn38zHttfInRq0xu/PH0az30d+z6vm202qpg1oXVMw=
|
||||
github.com/ugorji/go/codec v1.1.7 h1:2SvQaVZ1ouYrrKKwoSk2pzd4A9evlKJb9oTL+OaLUSs=
|
||||
github.com/ugorji/go/codec v1.1.7/go.mod h1:Ax+UKWsSmolVDwsd+7N3ZtXu+yMGCf907BLYF3GoBXY=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.6.0 h1:uWF8lgKmeaIewWVPwi4GRq2P6+R46IgYZdxWtM+GtEY=
|
||||
github.com/valyala/fasthttp v1.6.0/go.mod h1:FstJa9V+Pj9vQ7OJie2qMHdwemEDaDiSdBnvPM1Su9w=
|
||||
github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f h1:J9EGpcZtP0E/raorCMxlFGSTBrsSlaDGf3jU/qvAE2c=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
|
||||
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
|
||||
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
|
||||
github.com/yudai/pp v2.0.1+incompatible/go.mod h1:PuxR/8QJ7cyCkFp/aUDS+JY727OFEZkTdatxwunjIkc=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2 h1:VklqNMn3ovrHsnt90PveolxSbWFaJdECFbxSq0Mqo2M=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297 h1:k7pJ2yAPLPgbskkFdhRCsA77k2fySZ1zf2zCjvQCiIM=
|
||||
golang.org/x/net v0.0.0-20190827160401-ba9fcec4b297/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
||||
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
github.com/ziutek/mymysql v1.5.4/go.mod h1:LMSpPZ6DbqWFxNCHW77HeMg9I646SAhApZ/wKdgO/C0=
|
||||
golang.org/x/crypto v0.0.0-20190325154230-a5d413f7728c/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 h1:7I4JAnoQBe7ZtJcBaYHi5UtiO8tQHbUSXxL+pnGRANg=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42 h1:vEOn+mP2zCOVzKckCZy6YsCtDblrpj/w7B9nxGNELpg=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1 h1:SrN+KX8Art/Sf4HNj6Zcz06G7VEz+7w9tdXTPOZ7+l4=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
|
||||
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/oauth2.v3 v3.12.0 h1:yOffAPoolH/i2JxwmC+pgtnY3362iPahsDpLXfDFvNg=
|
||||
gopkg.in/oauth2.v3 v3.12.0/go.mod h1:XEYgKqWX095YiPT+Aw5y3tCn+7/FMnlTFKrupgSiJ3I=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8 h1:obN1ZagJSUGI0Ek/LBmuj4SNLPfIny3KsKFopxRdj10=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
func main() {
|
||||
fmt.Println("init OpenMediaCenter server")
|
||||
const port uint16 = 8081
|
||||
errc := make(chan error, 1)
|
||||
|
||||
config.Init()
|
||||
|
||||
@ -22,7 +23,10 @@ func main() {
|
||||
fmt.Printf("Use verbose output: %t\n", config.GetConfig().General.VerboseLogging)
|
||||
fmt.Printf("Videopath prefix: %s\n", config.GetConfig().General.ReindexPrefix)
|
||||
|
||||
database.InitDB()
|
||||
err := database.InitDB()
|
||||
if err != nil {
|
||||
errc <- err
|
||||
}
|
||||
defer database.Close()
|
||||
|
||||
api.AddHandlers()
|
||||
@ -33,7 +37,6 @@ func main() {
|
||||
static.ServeStaticFiles()
|
||||
|
||||
// init api
|
||||
errc := make(chan error, 1)
|
||||
go func() {
|
||||
errc <- api2.ServerInit(port)
|
||||
}()
|
||||
|
@ -25,18 +25,20 @@ func startTVShowReindex(files []Show) {
|
||||
}
|
||||
|
||||
func insertEpisodesIfNotExisting(show Show) {
|
||||
query := "SELECT filename FROM tvshow_episodes JOIN tvshow t on t.id = tvshow_episodes.tvshow_id WHERE t.name=?"
|
||||
query := "SELECT tvshow_episodes.name, season, episode FROM tvshow_episodes JOIN tvshow t on t.id = tvshow_episodes.tvshow_id WHERE t.name=?"
|
||||
rows := database.Query(query, show.Name)
|
||||
|
||||
var dbepisodes []string
|
||||
for rows.Next() {
|
||||
var filename string
|
||||
err := rows.Scan(&filename)
|
||||
var epname string
|
||||
var season int
|
||||
var episode int
|
||||
err := rows.Scan(&epname, &season, &episode)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
dbepisodes = append(dbepisodes, filename)
|
||||
dbepisodes = append(dbepisodes, fmt.Sprintf("%s S%02dE%02d.mp4", epname, season, episode))
|
||||
}
|
||||
|
||||
// get those episodes that are missing in db
|
||||
@ -81,10 +83,6 @@ VALUES (?, ?, ?, (SELECT tvshow.id FROM tvshow WHERE tvshow.name=?), ?, ?)`
|
||||
|
||||
// difference returns the elements in `a` that aren't in `b`.
|
||||
func difference(a, b []string) []string {
|
||||
if b == nil || len(b) == 0 {
|
||||
return a
|
||||
}
|
||||
|
||||
mb := make(map[string]struct{}, len(b))
|
||||
for _, x := range b {
|
||||
mb[x] = struct{}{}
|
||||
@ -131,10 +129,7 @@ func getAllTVShows() *[]string {
|
||||
var res []string
|
||||
for rows.Next() {
|
||||
var show string
|
||||
err := rows.Scan(&show)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
rows.Scan(&show)
|
||||
|
||||
res = append(res, show)
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ func ProcessVideo(fileNameOrig string) {
|
||||
// add a video to the database
|
||||
func addVideo(videoName string, fileName string, year int) {
|
||||
var ppic *string
|
||||
var poster *string
|
||||
var tmdbData *tmdb.VideoTMDB
|
||||
var err error
|
||||
var insertid int64
|
||||
@ -113,32 +112,32 @@ func addVideo(videoName string, fileName string, year int) {
|
||||
// if TMDB grabbing is enabled serach in api for video...
|
||||
if mSettings.TMDBGrabbing {
|
||||
tmdbData = tmdb.SearchVideo(videoName, year)
|
||||
if tmdbData != nil {
|
||||
// and tmdb pic as thumbnail
|
||||
poster = &tmdbData.Thumbnail
|
||||
}
|
||||
}
|
||||
|
||||
// parse pic from 4min frame
|
||||
ppic, vinfo, err := thumbnail.Parse(vidFolder+fileName, 240)
|
||||
// use parsed pic also for poster pic
|
||||
if poster == nil {
|
||||
poster = ppic
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("FFmpeg error occured: %s\n", err.Error())
|
||||
|
||||
query := `INSERT INTO videos(movie_name,movie_url) VALUES (?,?)`
|
||||
err, insertid = database.Insert(query, videoName, fileName)
|
||||
ppic, vinfo, ffmpegErr := thumbnail.Parse(vidFolder+fileName, 240)
|
||||
|
||||
if ffmpegErr == nil {
|
||||
if mSettings.TMDBGrabbing && tmdbData != nil {
|
||||
// inesert fixed pic ratio what we get from tmdb
|
||||
previewRatio := 2 / 3
|
||||
query := `INSERT INTO videos(movie_name,movie_url,poster,thumbnail,quality,previewratio,length,release_date) VALUES (?,?,?,?,?,?,?,?)`
|
||||
err, insertid = database.Insert(query, videoName, fileName, ppic, tmdbData.Thumbnail, vinfo.Width, previewRatio, vinfo.Length, tmdbData.ReleaseDate)
|
||||
} else {
|
||||
previewRatio := float32(vinfo.Height) / float32(vinfo.Width)
|
||||
// insert without tmdb info
|
||||
query := `INSERT INTO videos(movie_name,movie_url,poster,thumbnail,quality,previewratio,length) VALUES (?,?,?,?,?,?,?)`
|
||||
err, insertid = database.Insert(query, videoName, fileName, ppic, ppic, vinfo.Width, previewRatio, vinfo.Length)
|
||||
}
|
||||
} else {
|
||||
query := `INSERT INTO videos(movie_name,movie_url,poster,thumbnail,quality,length) VALUES (?,?,?,?,?,?)`
|
||||
err, insertid = database.Insert(query, videoName, fileName, ppic, poster, vinfo.Width, vinfo.Length)
|
||||
fmt.Printf("FFmpeg error occured: %s\n", ffmpegErr.Error())
|
||||
|
||||
// add default tags
|
||||
if vinfo.Width != 0 && err == nil {
|
||||
insertSizeTag(uint(vinfo.Width), uint(insertid))
|
||||
if mSettings.TMDBGrabbing && tmdbData != nil {
|
||||
query := `INSERT INTO videos(movie_name,movie_url,thumbnail,release_date) VALUES (?,?,?,?)`
|
||||
err, insertid = database.Insert(query, videoName, fileName, tmdbData.Thumbnail, tmdbData.ReleaseDate)
|
||||
} else {
|
||||
query := `INSERT INTO videos(movie_name,movie_url) VALUES (?,?)`
|
||||
err, insertid = database.Insert(query, videoName, fileName)
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,6 +146,13 @@ func addVideo(videoName string, fileName string, year int) {
|
||||
return
|
||||
}
|
||||
|
||||
if ffmpegErr == nil {
|
||||
// add default tags
|
||||
if vinfo.Width != 0 {
|
||||
insertSizeTag(uint(vinfo.Width), uint(insertid))
|
||||
}
|
||||
}
|
||||
|
||||
// add tmdb tags
|
||||
if mSettings.TMDBGrabbing && tmdbData != nil {
|
||||
insertTMDBTags(tmdbData.GenreIds, insertid)
|
||||
@ -211,22 +217,30 @@ func insertTMDBTags(ids []int, videoId int64) {
|
||||
|
||||
// now we check if the tag we want to add already exists
|
||||
tagId := createTagToDB(idGenre.Name)
|
||||
|
||||
// now we add the tag
|
||||
query := fmt.Sprintf("INSERT INTO video_tags(video_id,tag_id) VALUES (%d,%d)", videoId, tagId)
|
||||
_ = database.Edit(query)
|
||||
if tagId != -1 {
|
||||
// now we add the tag
|
||||
query := fmt.Sprintf("INSERT INTO video_tags(video_id,tag_id) VALUES (%d,%d)", videoId, tagId)
|
||||
_ = database.Edit(query)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// returns id of tag or creates it if not existing
|
||||
func createTagToDB(tagName string) int64 {
|
||||
query := fmt.Sprintf("SELECT tag_id FROM tags WHERE tag_name = %s", tagName)
|
||||
var id int64
|
||||
err := database.QueryRow(query).Scan(&id)
|
||||
query := "SELECT tag_id FROM tags WHERE tag_name = ?"
|
||||
var id int64 = -1
|
||||
err := database.QueryRow(query, tagName).Scan(&id)
|
||||
if err == sql.ErrNoRows {
|
||||
// tag doesn't exist -- add it
|
||||
query = fmt.Sprintf("INSERT INTO tags (tag_name) VALUES (%s)", tagName)
|
||||
err, id = database.Insert(query)
|
||||
query = "INSERT INTO tags (tag_name) VALUES (?)"
|
||||
err, id = database.Insert(query, tagName)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
} else if err != nil {
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
}
|
||||
return id
|
||||
}
|
||||
|
@ -15,20 +15,6 @@ type StatusMessage struct {
|
||||
ContentAvailable bool
|
||||
}
|
||||
|
||||
func getVideoTypes() []string {
|
||||
return []string{".mp4", ".mov", ".mkv", ".flv", ".avi", ".mpeg", ".m4v"}
|
||||
}
|
||||
|
||||
func ValidVideoSuffix(filename string) bool {
|
||||
validExts := getVideoTypes()
|
||||
for _, validExt := range validExts {
|
||||
if strings.HasSuffix(filename, validExt) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func StartReindex() bool {
|
||||
fmt.Println("starting reindex..")
|
||||
SendEvent("start")
|
||||
@ -54,7 +40,7 @@ func StartReindex() bool {
|
||||
return err
|
||||
}
|
||||
|
||||
if !info.IsDir() && ValidVideoSuffix(info.Name()) {
|
||||
if !info.IsDir() && strings.HasSuffix(info.Name(), ".mp4") {
|
||||
files = append(files, info.Name())
|
||||
}
|
||||
return nil
|
||||
@ -121,7 +107,7 @@ func StartTVShowReindex() {
|
||||
}
|
||||
|
||||
for _, epfile := range episodefiles {
|
||||
if ValidVideoSuffix(epfile.Name()) {
|
||||
if strings.HasSuffix(epfile.Name(), ".mp4") {
|
||||
elem.files = append(elem.files, epfile.Name())
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@
|
||||
package thumbnail
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/3d0c/gmf"
|
||||
"io"
|
||||
"log"
|
||||
@ -20,10 +21,10 @@ func Parse(filename string, time uint64) (*string, *VidInfo, error) {
|
||||
}
|
||||
}
|
||||
|
||||
func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]byte, info *VidInfo, err error) {
|
||||
func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]byte, info *VidInfo, err error) {
|
||||
var swsctx *gmf.SwsCtx
|
||||
|
||||
gmf.LogSetLevel(gmf.AV_LOG_ERROR)
|
||||
gmf.LogSetLevel(gmf.AV_LOG_PANIC)
|
||||
|
||||
stat, err := os.Stat(srcFileName)
|
||||
if err != nil {
|
||||
@ -46,19 +47,19 @@ func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
codec, err := gmf.FindEncoder(decodeExtension)
|
||||
encodeCodec, err := gmf.FindEncoder(encodeExtension)
|
||||
if err != nil {
|
||||
log.Printf("%s\n", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
cc := gmf.NewCodecCtx(codec)
|
||||
cc := gmf.NewCodecCtx(encodeCodec)
|
||||
defer gmf.Release(cc)
|
||||
|
||||
cc.SetTimeBase(gmf.AVR{Num: 1, Den: 1})
|
||||
|
||||
cc.SetPixFmt(gmf.AV_PIX_FMT_YUVJ444P).SetWidth(srcVideoStream.CodecPar().Width()).SetHeight(srcVideoStream.CodecPar().Height())
|
||||
if codec.IsExperimental() {
|
||||
if encodeCodec.IsExperimental() {
|
||||
cc.SetStrictCompliance(gmf.FF_COMPLIANCE_EXPERIMENTAL)
|
||||
}
|
||||
|
||||
@ -68,28 +69,35 @@ func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]
|
||||
}
|
||||
defer cc.Free()
|
||||
|
||||
ist, err := inputCtx.GetStream(srcVideoStream.Index())
|
||||
if err != nil {
|
||||
log.Printf("Error getting stream - %s\n", err)
|
||||
return nil, nil, err
|
||||
}
|
||||
defer ist.Free()
|
||||
|
||||
err = inputCtx.SeekFrameAt(int64(time), 0)
|
||||
err = inputCtx.SeekFrameAt(int64(time), srcVideoStream.Index())
|
||||
if err != nil {
|
||||
log.Printf("Error while seeking file: %s\n", err.Error())
|
||||
return
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// find encodeCodec to decode video
|
||||
decodeCodec, err := gmf.FindDecoder(srcVideoStream.CodecPar().CodecId())
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
icc := gmf.NewCodecCtx(decodeCodec)
|
||||
defer gmf.Release(icc)
|
||||
|
||||
// copy stream parameters in codeccontext
|
||||
err = srcVideoStream.CodecPar().ToContext(icc)
|
||||
if err != nil {
|
||||
fmt.Println(err.Error())
|
||||
}
|
||||
|
||||
// convert source pix_fmt into AV_PIX_FMT_RGBA
|
||||
// which is set up by codec context above
|
||||
icc := srcVideoStream.CodecCtx()
|
||||
if swsctx, err = gmf.NewSwsCtx(icc.Width(), icc.Height(), icc.PixFmt(), cc.Width(), cc.Height(), cc.PixFmt(), gmf.SWS_BICUBIC); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
defer swsctx.Free()
|
||||
|
||||
frameRate := float32(ist.GetRFrameRate().AVR().Num) / float32(ist.GetRFrameRate().AVR().Den)
|
||||
frameRate := float32(srcVideoStream.GetRFrameRate().AVR().Num) / float32(srcVideoStream.GetRFrameRate().AVR().Den)
|
||||
inf := VidInfo{
|
||||
Width: uint32(icc.Width()),
|
||||
Height: uint32(icc.Height()),
|
||||
@ -127,7 +135,7 @@ func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]
|
||||
continue
|
||||
}
|
||||
|
||||
frames, err = ist.CodecCtx().Decode(pkt)
|
||||
frames, err = srcVideoStream.CodecCtx().Decode(pkt)
|
||||
|
||||
if err != nil {
|
||||
log.Printf("Fatal error during decoding - %s\n", err)
|
||||
@ -162,7 +170,7 @@ func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]
|
||||
p.Free()
|
||||
}
|
||||
|
||||
for i, _ := range frames {
|
||||
for i := range frames {
|
||||
frames[i].Free()
|
||||
frameCount++
|
||||
}
|
||||
@ -177,9 +185,14 @@ func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]
|
||||
}
|
||||
|
||||
for i := 0; i < inputCtx.StreamsCnt(); i++ {
|
||||
st, _ := inputCtx.GetStream(i)
|
||||
st.CodecCtx().Free()
|
||||
st.Free()
|
||||
st, err := inputCtx.GetStream(i)
|
||||
if err == nil && st != nil {
|
||||
st.Free()
|
||||
}
|
||||
}
|
||||
|
||||
icc.Free()
|
||||
srcVideoStream.Free()
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -15,10 +15,11 @@ const baseUrl = "https://api.themoviedb.org/3/"
|
||||
const pictureBase = "https://image.tmdb.org/t/p/w500"
|
||||
|
||||
type VideoTMDB struct {
|
||||
Thumbnail string
|
||||
Overview string
|
||||
Title string
|
||||
GenreIds []int
|
||||
Thumbnail string
|
||||
Overview string
|
||||
Title string
|
||||
ReleaseDate string
|
||||
GenreIds []int
|
||||
}
|
||||
|
||||
type TVShowTMDB struct {
|
||||
@ -120,10 +121,11 @@ cont:
|
||||
}
|
||||
|
||||
result := VideoTMDB{
|
||||
Thumbnail: thumbnail,
|
||||
Overview: tmdbVid.Overview,
|
||||
Title: tmdbVid.Title,
|
||||
GenreIds: tmdbVid.GenreIds,
|
||||
Thumbnail: thumbnail,
|
||||
Overview: tmdbVid.Overview,
|
||||
Title: tmdbVid.Title,
|
||||
ReleaseDate: tmdbVid.ReleaseDate,
|
||||
GenreIds: tmdbVid.GenreIds,
|
||||
}
|
||||
|
||||
return &result
|
||||
@ -205,10 +207,14 @@ func fetchGenres() *[]TMDBGenre {
|
||||
return nil
|
||||
}
|
||||
|
||||
var t []TMDBGenre
|
||||
type RespType struct {
|
||||
Genres []TMDBGenre
|
||||
}
|
||||
|
||||
var t RespType
|
||||
err = json.Unmarshal(body, &t)
|
||||
|
||||
return &t
|
||||
return &t.Genres
|
||||
}
|
||||
|
||||
func GetGenres() *[]TMDBGenre {
|
||||
|
@ -56,8 +56,8 @@ create table if not exists videos
|
||||
thumbnail mediumblob null,
|
||||
poster mediumblob null,
|
||||
likes int default 0 null,
|
||||
quality int null,
|
||||
length int null comment 'in seconds',
|
||||
quality int default 0 null,
|
||||
length int default 0 null comment 'in seconds',
|
||||
create_date datetime default current_timestamp() null
|
||||
);
|
||||
|
||||
|
@ -6,10 +6,6 @@ ln -sf /etc/nginx/sites-available/OpenMediaCenter.conf /etc/nginx/sites-enabled/
|
||||
mysql -uroot -pPASS -e "CREATE DATABASE IF NOT EXISTS mediacenter;"
|
||||
mysql -uroot -pPASS -e "CREATE USER IF NOT EXISTS 'mediacenteruser'@'localhost' IDENTIFIED BY 'mediapassword';"
|
||||
mysql -uroot -pPASS -e "GRANT ALL PRIVILEGES ON mediacenter . * TO 'mediacenteruser'@'localhost';"
|
||||
mysql -u mediacenteruser -pmediapassword mediacenter < /tmp/openmediacenter.sql
|
||||
|
||||
# removed unused sql style file
|
||||
rm /tmp/openmediacenter.sql
|
||||
|
||||
# correct user rights
|
||||
chown -R www-data:www-data /var/www/openmediacenter
|
||||
|
@ -19,7 +19,7 @@ describe('<App/>', function () {
|
||||
it('are navlinks correct', function () {
|
||||
const wrapper = shallow(<App/>);
|
||||
wrapper.setState({password: false});
|
||||
expect(wrapper.find('.navitem')).toHaveLength(4);
|
||||
expect(wrapper.find('.navitem')).toHaveLength(5);
|
||||
});
|
||||
|
||||
it('test render of password page', function () {
|
||||
|
@ -88,6 +88,13 @@ class App extends React.Component<{}, state> {
|
||||
Categories
|
||||
</NavLink>
|
||||
|
||||
<NavLink
|
||||
className={[style.navitem, themeStyle.navitem].join(' ')}
|
||||
to={'/media/actors'}
|
||||
activeStyle={{opacity: '0.85'}}>
|
||||
Actors
|
||||
</NavLink>
|
||||
|
||||
{this.context.TVShowEnabled ? (
|
||||
<NavLink
|
||||
className={[style.navitem, themeStyle.navitem].join(' ')}
|
||||
|
@ -2,7 +2,10 @@
|
||||
background-color: green;
|
||||
border-radius: 5px;
|
||||
border-width: 0;
|
||||
color: white;
|
||||
margin-right: 15px;
|
||||
padding: 6px;
|
||||
}
|
||||
|
||||
.button:hover{
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
@ -1,14 +1,6 @@
|
||||
import {shallow} from 'enzyme';
|
||||
import React from 'react';
|
||||
import {Button} from './Button';
|
||||
|
||||
function prepareFetchApi(response) {
|
||||
const mockJsonPromise = Promise.resolve(response);
|
||||
const mockFetchPromise = Promise.resolve({
|
||||
json: () => mockJsonPromise
|
||||
});
|
||||
return (jest.fn().mockImplementation(() => mockFetchPromise));
|
||||
}
|
||||
import {Button, IconButton} from './Button';
|
||||
|
||||
describe('<Button/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
@ -30,3 +22,24 @@ describe('<Button/>', function () {
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
||||
describe('<IconButton/>', function () {
|
||||
it('renders without crashing ', function () {
|
||||
const wrapper = shallow(<IconButton onClick={() => {}} title='test'/>);
|
||||
wrapper.unmount();
|
||||
});
|
||||
|
||||
it('renders title', function () {
|
||||
const wrapper = shallow(<IconButton onClick={() => {}} title='test1'/>);
|
||||
expect(wrapper.text()).toBe('<FontAwesomeIcon />test1');
|
||||
});
|
||||
|
||||
it('test onclick handling', () => {
|
||||
const func = jest.fn();
|
||||
const wrapper = shallow(<IconButton onClick={func} title='test1'/>);
|
||||
|
||||
wrapper.find('button').simulate('click');
|
||||
|
||||
expect(func).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
});
|
||||
|
@ -1,5 +1,8 @@
|
||||
import React from 'react';
|
||||
import style from './Button.module.css';
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||
import {IconDefinition} from '@fortawesome/fontawesome-common-types';
|
||||
import GlobalInfos from '../../utils/GlobalInfos';
|
||||
|
||||
interface ButtonProps {
|
||||
title: string | JSX.Element;
|
||||
@ -8,9 +11,30 @@ interface ButtonProps {
|
||||
}
|
||||
|
||||
export function Button(props: ButtonProps): JSX.Element {
|
||||
const theme = GlobalInfos.getThemeStyle();
|
||||
|
||||
return (
|
||||
<button className={style.button} style={props.color} onClick={props.onClick}>
|
||||
<button className={style.button + ' ' + theme.textcolor} style={props.color} onClick={props.onClick}>
|
||||
{props.title}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
interface IconButtonProps {
|
||||
title: string | JSX.Element;
|
||||
onClick?: () => void;
|
||||
icon: IconDefinition;
|
||||
}
|
||||
|
||||
export function IconButton(props: IconButtonProps): JSX.Element {
|
||||
const theme = GlobalInfos.getThemeStyle();
|
||||
|
||||
return (
|
||||
<button className={style.button + ' ' + theme.textcolor} style={{backgroundColor: '#00000000'}} onClick={props.onClick}>
|
||||
<span style={{fontSize: 12}}>
|
||||
<FontAwesomeIcon className={theme.textcolor} icon={props.icon} size='2x' />
|
||||
</span>
|
||||
<span style={{marginLeft: 10}}>{props.title}</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
@ -2,7 +2,6 @@
|
||||
font-size: smaller;
|
||||
font-weight: bold;
|
||||
height: 20px;
|
||||
max-width: 266px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@ -20,13 +19,6 @@
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.previewimage {
|
||||
max-height: 400px;
|
||||
max-width: 410px;
|
||||
min-height: 150px;
|
||||
min-width: 266px;
|
||||
}
|
||||
|
||||
.previewbottom {
|
||||
height: 20px;
|
||||
}
|
||||
|
@ -11,6 +11,7 @@ interface PreviewProps {
|
||||
picLoader: (callback: (pic: string) => void) => void;
|
||||
linkPath?: string;
|
||||
onClick?: () => void;
|
||||
aspectRatio?: number;
|
||||
}
|
||||
|
||||
interface PreviewState {
|
||||
@ -25,6 +26,11 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
|
||||
// store the picture to display
|
||||
pic?: string;
|
||||
|
||||
static readonly DefMinWidth = 266;
|
||||
static readonly DefMaxWidth = 410;
|
||||
static readonly DefMinHeight = 150;
|
||||
static readonly DefMaxHeight = 400;
|
||||
|
||||
constructor(props: PreviewProps) {
|
||||
super(props);
|
||||
|
||||
@ -43,7 +49,7 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
|
||||
}
|
||||
|
||||
render(): JSX.Element {
|
||||
if (this.props.linkPath !== undefined) {
|
||||
if (this.props.linkPath != null) {
|
||||
return <Link to={this.props.linkPath}>{this.content()}</Link>;
|
||||
} else {
|
||||
return this.content();
|
||||
@ -52,12 +58,31 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
|
||||
|
||||
content(): JSX.Element {
|
||||
const themeStyle = GlobalInfos.getThemeStyle();
|
||||
const ratio = this.props.aspectRatio;
|
||||
let dimstyle = null;
|
||||
|
||||
// check if aspect ratio is passed
|
||||
if (ratio != null) {
|
||||
// if ratio is <1 we need to calc height
|
||||
if (ratio < 1) {
|
||||
const height = Preview.DefMaxWidth * ratio;
|
||||
dimstyle = {height: height, width: Preview.DefMaxWidth};
|
||||
} else {
|
||||
const width = Preview.DefMaxHeight * ratio;
|
||||
dimstyle = {width: width, height: Preview.DefMaxHeight};
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className={style.videopreview + ' ' + themeStyle.secbackground + ' ' + themeStyle.preview}
|
||||
onClick={this.props.onClick}>
|
||||
<div className={style.previewtitle + ' ' + themeStyle.lighttextcolor}>{this.props.name}</div>
|
||||
<div className={style.previewpic}>
|
||||
<div
|
||||
style={{maxWidth: dimstyle !== null ? dimstyle.width : Preview.DefMaxWidth}}
|
||||
className={style.previewtitle + ' ' + themeStyle.lighttextcolor}>
|
||||
{this.props.name}
|
||||
</div>
|
||||
<div style={dimstyle !== null ? dimstyle : undefined} className={style.previewpic}>
|
||||
{this.state.picLoaded === false ? (
|
||||
<FontAwesomeIcon
|
||||
style={{
|
||||
@ -72,7 +97,20 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
|
||||
<Spinner animation='border' />
|
||||
</span>
|
||||
) : (
|
||||
<img className={style.previewimage} src={this.pic} alt='Pic loading.' />
|
||||
<img
|
||||
style={
|
||||
dimstyle !== null
|
||||
? dimstyle
|
||||
: {
|
||||
minWidth: Preview.DefMinWidth,
|
||||
maxWidth: Preview.DefMaxWidth,
|
||||
minHeight: Preview.DefMinHeight,
|
||||
maxHeight: Preview.DefMaxHeight
|
||||
}
|
||||
}
|
||||
src={this.pic}
|
||||
alt='Pic loading.'
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
<div className={style.previewbottom} />
|
||||
|
@ -20,7 +20,7 @@ describe('<Preview/>', function () {
|
||||
expect(func).toHaveBeenCalledTimes(1)
|
||||
|
||||
// received picture should be rendered into wrapper
|
||||
expect(wrapper.find('.previewimage').props().src).toBe('42');
|
||||
expect(wrapper.find('img').props().src).toBe('42');
|
||||
// check if preview title renders correctly
|
||||
expect(wrapper.find('.previewtitle').text()).toBe('test');
|
||||
});
|
||||
|
@ -17,7 +17,7 @@ class Tag extends React.Component<props> {
|
||||
if (this.props.onclick) {
|
||||
return this.renderButton();
|
||||
} else {
|
||||
return <Link to={'/categories/' + this.props.tagInfo.TagId}>{this.renderButton()}</Link>;
|
||||
return <Link to={'/media/categories/' + this.props.tagInfo.TagId}>{this.renderButton()}</Link>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ const VideoContainer = (props: Props): JSX.Element => {
|
||||
renderElement={(el): JSX.Element => (
|
||||
<Preview
|
||||
key={el.MovieId}
|
||||
aspectRatio={el.Ratio > 0 ? el.Ratio : undefined}
|
||||
picLoader={(callback: (pic: string) => void): void => {
|
||||
callAPIPlain(
|
||||
APINode.Video,
|
||||
|
@ -37,7 +37,7 @@ export class ActorPage extends React.Component<Props, state> {
|
||||
<>
|
||||
<PageTitle title={this.state.actor.Name} subtitle={this.state.data ? this.state.data.length + ' videos' : null}>
|
||||
<span className={style.overviewbutton}>
|
||||
<Link to='/actors'>
|
||||
<Link to='/media/actors'>
|
||||
<Button onClick={(): void => {}} title='Go to Actor overview' />
|
||||
</Link>
|
||||
</span>
|
||||
|
@ -90,14 +90,12 @@ describe('<HomePage/>', function () {
|
||||
const wrapper = shallow(<HomePage/>);
|
||||
|
||||
// expect those default values
|
||||
expect(wrapper.state().sortby).toBe('Date Added');
|
||||
expect(wrapper.instance().sortState).toBe(SortBy.date);
|
||||
expect(wrapper.state().sortby).toBe(0);
|
||||
expect(wrapper.instance().tagState).toBe(DefaultTags.all);
|
||||
|
||||
wrapper.instance().onDropDownItemClick(SortBy.name, 'namesort');
|
||||
wrapper.instance().onDropDownItemClick(SortBy.name);
|
||||
|
||||
expect(wrapper.state().sortby).toBe('namesort');
|
||||
expect(wrapper.instance().sortState).toBe(SortBy.name);
|
||||
expect(wrapper.state().sortby).toBe(SortBy.name);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -29,7 +29,7 @@ interface state {
|
||||
subtitle: string;
|
||||
data: VideoTypes.VideoUnloadedType[];
|
||||
selectionnr: number;
|
||||
sortby: string;
|
||||
sortby: SortBy;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -39,9 +39,33 @@ export class HomePage extends React.Component<Props, state> {
|
||||
/** keyword variable needed temporary store search keyword */
|
||||
keyword = '';
|
||||
|
||||
/**
|
||||
* get text label from sort type
|
||||
* @param type SortBy type
|
||||
*/
|
||||
getLabelFromSortType(type: SortBy): String {
|
||||
switch (type) {
|
||||
case SortBy.date:
|
||||
return 'Date Added';
|
||||
case SortBy.length:
|
||||
return 'Length';
|
||||
case SortBy.likes:
|
||||
return 'Most likes';
|
||||
case SortBy.name:
|
||||
return 'Name';
|
||||
case SortBy.random:
|
||||
return 'Random';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
|
||||
// get previously stored location from localstorage
|
||||
const storedSelection = global.localStorage.getItem('sortby');
|
||||
|
||||
this.state = {
|
||||
sideinfo: {
|
||||
VideoNr: 0,
|
||||
@ -54,11 +78,10 @@ export class HomePage extends React.Component<Props, state> {
|
||||
subtitle: 'All Videos',
|
||||
data: [],
|
||||
selectionnr: 0,
|
||||
sortby: 'Date Added'
|
||||
sortby: storedSelection == null ? SortBy.date : parseInt(storedSelection, 10)
|
||||
};
|
||||
}
|
||||
|
||||
sortState = SortBy.date;
|
||||
tagState = DefaultTags.all;
|
||||
|
||||
componentDidMount(): void {
|
||||
@ -87,7 +110,7 @@ export class HomePage extends React.Component<Props, state> {
|
||||
fetchVideoData(): void {
|
||||
callAPI(
|
||||
APINode.Video,
|
||||
{action: 'getMovies', Tag: this.tagState.TagId, Sort: this.sortState},
|
||||
{action: 'getMovies', Tag: this.tagState.TagId, Sort: this.state.sortby},
|
||||
(result: {Videos: VideoTypes.VideoUnloadedType[]; TagName: string}) => {
|
||||
this.setState({
|
||||
data: result.Videos,
|
||||
@ -190,15 +213,25 @@ export class HomePage extends React.Component<Props, state> {
|
||||
<span className={style.sortbyLabel}>Sort By: </span>
|
||||
<div className={style.dropdown}>
|
||||
<span className={style.dropbtn}>
|
||||
<span>{this.state.sortby}</span>
|
||||
<span>{this.getLabelFromSortType(this.state.sortby)}</span>
|
||||
<FontAwesomeIcon style={{marginLeft: 3, paddingBottom: 3}} icon={faSortDown} size='1x' />
|
||||
</span>
|
||||
<div className={style.dropdownContent}>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.date, 'Date Added')}>Date Added</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.likes, 'Most likes')}>Most likes</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.random, 'Random')}>Random</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.name, 'Name')}>Name</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.length, 'Length')}>Length</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.date)}>
|
||||
{this.getLabelFromSortType(SortBy.date)}
|
||||
</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.likes)}>
|
||||
{this.getLabelFromSortType(SortBy.likes)}
|
||||
</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.random)}>
|
||||
{this.getLabelFromSortType(SortBy.random)}
|
||||
</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.name)}>
|
||||
{this.getLabelFromSortType(SortBy.name)}
|
||||
</span>
|
||||
<span onClick={(): void => this.onDropDownItemClick(SortBy.length)}>
|
||||
{this.getLabelFromSortType(SortBy.length)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -214,10 +247,12 @@ export class HomePage extends React.Component<Props, state> {
|
||||
* @param type type of sort action
|
||||
* @param name new header title
|
||||
*/
|
||||
onDropDownItemClick(type: SortBy, name: string): void {
|
||||
this.sortState = type;
|
||||
this.setState({sortby: name});
|
||||
this.fetchVideoData();
|
||||
onDropDownItemClick(type: SortBy): void {
|
||||
this.setState({sortby: type}, (): void => {
|
||||
global.localStorage.setItem('sortby', type.toString());
|
||||
|
||||
this.fetchVideoData();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ describe('<Player/>', function () {
|
||||
|
||||
// initial fetch for getting movie data
|
||||
expect(global.fetch).toHaveBeenCalledTimes(1);
|
||||
wrapper.find('.videoactions').find('Button').first().simulate('click');
|
||||
wrapper.find('.videoactions').find('IconButton').first().simulate('click');
|
||||
// fetch for liking
|
||||
expect(global.fetch).toHaveBeenCalledTimes(2);
|
||||
|
||||
@ -81,7 +81,7 @@ describe('<Player/>', function () {
|
||||
const wrapper = instance();
|
||||
expect(wrapper.find('AddTagPopup')).toHaveLength(0);
|
||||
// todo dynamic button find without index
|
||||
wrapper.find('.videoactions').find('Button').at(1).simulate('click');
|
||||
wrapper.find('.videoactions').find('IconButton').at(1).simulate('click');
|
||||
// addtagpopup should be showing now
|
||||
expect(wrapper.find('AddTagPopup')).toHaveLength(1);
|
||||
});
|
||||
@ -106,7 +106,7 @@ describe('<Player/>', function () {
|
||||
wrapper.setContext({VideosFullyDeleteable: false})
|
||||
|
||||
// request the popup to pop
|
||||
wrapper.find('.videoactions').find('Button').at(2).simulate('click');
|
||||
wrapper.find('.videoactions').find('IconButton').at(2).simulate('click');
|
||||
|
||||
// click the first submit button
|
||||
wrapper.find('ButtonPopup').dive().find('Button').at(0).simulate('click')
|
||||
|
@ -9,7 +9,7 @@ import Tag from '../../elements/Tag/Tag';
|
||||
import AddTagPopup from '../../elements/Popups/AddTagPopup/AddTagPopup';
|
||||
import PageTitle, {Line} from '../../elements/PageTitle/PageTitle';
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||
import {faPlusCircle} from '@fortawesome/free-solid-svg-icons';
|
||||
import {faPlusCircle, faTag, faThumbsUp, faTrash} from '@fortawesome/free-solid-svg-icons';
|
||||
import AddActorPopup from '../../elements/Popups/AddActorPopup/AddActorPopup';
|
||||
import ActorTile from '../../elements/ActorTile/ActorTile';
|
||||
import {withRouter} from 'react-router-dom';
|
||||
@ -18,7 +18,7 @@ import {RouteComponentProps} from 'react-router';
|
||||
import {DefaultPlyrOptions, GeneralSuccess} from '../../types/GeneralTypes';
|
||||
import {ActorType, TagType} from '../../types/VideoTypes';
|
||||
import PlyrJS from 'plyr';
|
||||
import {Button} from '../../elements/GPElements/Button';
|
||||
import {IconButton} from '../../elements/GPElements/Button';
|
||||
import {VideoTypes} from '../../types/ApiTypes';
|
||||
import GlobalInfos from '../../utils/GlobalInfos';
|
||||
import {ButtonPopup} from '../../elements/Popups/ButtonPopup/ButtonPopup';
|
||||
@ -32,6 +32,7 @@ interface mystate {
|
||||
movieName: string;
|
||||
likes: number;
|
||||
quality: number;
|
||||
releaseDate: string | null;
|
||||
length: number;
|
||||
tags: TagType[];
|
||||
suggesttag: TagType[];
|
||||
@ -54,6 +55,7 @@ export class Player extends React.Component<Props, mystate> {
|
||||
movieName: '',
|
||||
likes: 0,
|
||||
quality: 0,
|
||||
releaseDate: null,
|
||||
length: 0,
|
||||
tags: [],
|
||||
suggesttag: [],
|
||||
@ -88,18 +90,12 @@ export class Player extends React.Component<Props, mystate> {
|
||||
<div>not loaded yet</div>
|
||||
)}
|
||||
<div className={style.videoactions}>
|
||||
<Button onClick={(): void => this.likebtn()} title='Like this Video!' color={{backgroundColor: 'green'}} />
|
||||
<Button
|
||||
onClick={(): void => this.setState({popupvisible: true})}
|
||||
title='Give this Video a Tag'
|
||||
color={{backgroundColor: '#3574fe'}}
|
||||
/>
|
||||
<Button
|
||||
title='Delete Video'
|
||||
onClick={(): void => {
|
||||
this.setState({deletepopupvisible: true});
|
||||
}}
|
||||
color={{backgroundColor: 'red'}}
|
||||
<IconButton icon={faThumbsUp} onClick={(): void => this.likebtn()} title='Like!' />
|
||||
<IconButton icon={faTag} onClick={(): void => this.setState({popupvisible: true})} title='Add Tag!' />
|
||||
<IconButton
|
||||
icon={faTrash}
|
||||
onClick={(): void => this.setState({deletepopupvisible: true})}
|
||||
title='Delete Video!'
|
||||
/>
|
||||
</div>
|
||||
{this.assembleActorTiles()}
|
||||
@ -131,6 +127,11 @@ export class Player extends React.Component<Props, mystate> {
|
||||
<b>{this.state.quality}p</b> Quality!
|
||||
</SideBarItem>
|
||||
) : null}
|
||||
{this.state.releaseDate !== null ? (
|
||||
<SideBarItem>
|
||||
<b>{this.state.releaseDate}</b> released!
|
||||
</SideBarItem>
|
||||
) : null}
|
||||
{this.state.length !== 0 ? (
|
||||
<SideBarItem>
|
||||
<b>{Math.round(this.state.length / 60)}</b> Minutes of length!
|
||||
@ -323,6 +324,7 @@ export class Player extends React.Component<Props, mystate> {
|
||||
movieName: result.MovieName,
|
||||
likes: result.Likes,
|
||||
quality: result.Quality,
|
||||
releaseDate: result.ReleaseDate,
|
||||
length: result.Length,
|
||||
tags: result.Tags,
|
||||
suggesttag: result.SuggestedTag,
|
||||
|
@ -25,9 +25,18 @@ interface GetRandomMoviesType {
|
||||
class RandomPage extends React.Component<{}, state> {
|
||||
readonly LoadNR = 3;
|
||||
|
||||
// random seed to load videos, remains page reload.
|
||||
seed = this.genRandInt();
|
||||
|
||||
constructor(props: {}) {
|
||||
super(props);
|
||||
|
||||
// get previously stored location from localstorage
|
||||
const storedseed = global.localStorage.getItem('randpageseed');
|
||||
if (storedseed != null) {
|
||||
this.seed = parseInt(storedseed, 10);
|
||||
}
|
||||
|
||||
this.state = {
|
||||
videos: [],
|
||||
tags: []
|
||||
@ -36,6 +45,10 @@ class RandomPage extends React.Component<{}, state> {
|
||||
this.keypress = this.keypress.bind(this);
|
||||
}
|
||||
|
||||
genRandInt(): number {
|
||||
return Math.floor(Math.random() * 2147483647) + 1;
|
||||
}
|
||||
|
||||
componentDidMount(): void {
|
||||
addKeyHandler(this.keypress);
|
||||
|
||||
@ -77,15 +90,21 @@ class RandomPage extends React.Component<{}, state> {
|
||||
* click handler for shuffle btn
|
||||
*/
|
||||
shuffleclick(): void {
|
||||
this.genSeed();
|
||||
this.loadShuffledvideos(this.LoadNR);
|
||||
}
|
||||
|
||||
genSeed(): void {
|
||||
this.seed = this.genRandInt();
|
||||
global.localStorage.setItem('randpageseed', this.seed.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* load random videos from backend
|
||||
* @param nr number of videos to load
|
||||
*/
|
||||
loadShuffledvideos(nr: number): void {
|
||||
callAPI<GetRandomMoviesType>(APINode.Video, {action: 'getRandomMovies', Number: nr}, (result) => {
|
||||
callAPI<GetRandomMoviesType>(APINode.Video, {action: 'getRandomMovies', Number: nr, Seed: this.seed}, (result) => {
|
||||
this.setState({videos: []}); // needed to trigger rerender of main videoview
|
||||
this.setState({
|
||||
videos: result.Videos,
|
||||
@ -101,7 +120,8 @@ class RandomPage extends React.Component<{}, state> {
|
||||
private keypress(event: KeyboardEvent): void {
|
||||
// bind s to shuffle
|
||||
if (event.key === 's') {
|
||||
this.loadShuffledvideos(4);
|
||||
this.genSeed();
|
||||
this.loadShuffledvideos(this.LoadNR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ export namespace VideoTypes {
|
||||
MovieName: string;
|
||||
Likes: number;
|
||||
Quality: number;
|
||||
ReleaseDate: string | null;
|
||||
Length: number;
|
||||
Tags: TagType[];
|
||||
SuggestedTag: TagType[];
|
||||
@ -26,6 +27,7 @@ export namespace VideoTypes {
|
||||
export interface VideoUnloadedType {
|
||||
MovieId: number;
|
||||
MovieName: string;
|
||||
Ratio: number;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,5 +103,5 @@ export enum APINode {
|
||||
Tags = 'tags',
|
||||
Actor = 'actor',
|
||||
Video = 'video',
|
||||
TVShow = 'tvshow'
|
||||
TVShow = 'tv'
|
||||
}
|
||||
|
Reference in New Issue
Block a user