Compare commits

..

No commits in common. "master" and "morevidefiletypes" have entirely different histories.

44 changed files with 309 additions and 817 deletions

View File

@ -93,9 +93,11 @@ 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
@ -108,13 +110,15 @@ Debian_Server:
- Minimize_Frontend
- Build_Backend
.Test_Server_Common:
Test_Server:
stage: deploy
image: luki42/ssh:latest
needs:
- Frontend_Tests
- Backend_Tests
- Debian_Server
only:
- master
script:
- eval $(ssh-agent -s)
- echo "$SSH_PRIVATE_KEY" | ssh-add -
@ -124,38 +128,3 @@ Debian_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_CD:
extends: .Test_Server_Common
only:
refs:
- master
Test_Server_MANUAL:
extends: .Test_Server_Common
when: manual
.Test_Server_2_Common:
stage: deploy
image: luki42/ssh:latest
needs:
- Frontend_Tests
- Backend_Tests
- Debian_Server
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.44:/tmp/
- ssh root@192.168.0.44 "DEBIAN_FRONTEND=noninteractive apt-get --reinstall -y -qq install /tmp/OpenMediaCenter-*.deb && rm /tmp/OpenMediaCenter-*.deb"
allow_failure: true
Test_Server_2_CD:
extends: .Test_Server_2_Common
only:
refs:
- master
Test_Server_2_MANUAL:
extends: .Test_Server_2_Common
when: manual

View File

@ -25,7 +25,7 @@ func getActorsFromDB() {
* @apiSuccess {string} .Thumbnail Portrait Thumbnail
*/
api.AddHandler("getAllActors", api.ActorNode, api.PermUser, func(context api.Context) {
query := "SELECT actor_id, name, thumbnail FROM actors ORDER BY name ASC"
query := "SELECT actor_id, name, thumbnail FROM actors"
context.Json(readActorsFromResultset(database.Query(query)))
})

View File

@ -78,7 +78,7 @@ func getFromDB() {
* @apiSuccess {string} TagName name of the Tag
*/
api.AddHandler("getAllTags", api.TagNode, api.PermUser, func(context api.Context) {
query := "SELECT tag_id,tag_name from tags ORDER BY tag_name ASC"
query := "SELECT tag_id,tag_name from tags"
context.Json(readTagsFromResultset(database.Query(query)))
})
}

View File

@ -1,7 +1,6 @@
package api
import (
"encoding/json"
"fmt"
"net/url"
"openmediacenter/apiGo/api/api"
@ -10,7 +9,6 @@ import (
"openmediacenter/apiGo/database"
"os"
"strconv"
"strings"
)
func addVideoHandlers() {
@ -75,12 +73,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,previewratio,t.tag_name FROM videos
query = fmt.Sprintf(`SELECT movie_id,movie_name,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,previewratio, (SELECT 'All' as tag_name) FROM videos %s", SortClause)
query = fmt.Sprintf("SELECT movie_id,movie_name, (SELECT 'All' as tag_name) FROM videos %s", SortClause)
}
var result struct {
@ -93,7 +91,7 @@ func getVideoHandlers() {
var name string
for rows.Next() {
var vid types.VideoUnloadedType
err := rows.Scan(&vid.MovieId, &vid.MovieName, &vid.Ratio, &name)
err := rows.Scan(&vid.MovieId, &vid.MovieName, &name)
if err != nil {
return
}
@ -164,8 +162,7 @@ func getVideoHandlers() {
*/
api.AddHandler("getRandomMovies", api.VideoNode, api.PermUser, func(context api.Context) {
var args struct {
Number int
TagFilter []uint32
Number int
}
if api.DecodeRequest(context.GetRequest(), &args) != nil {
context.Text("unable to decode request")
@ -177,52 +174,34 @@ func getVideoHandlers() {
Videos []types.VideoUnloadedType
}
whereclause := "WHERE 1"
if len(args.TagFilter) > 0 {
d, _ := json.Marshal(args.TagFilter)
vals := strings.Trim(string(d), "[]")
whereclause = fmt.Sprintf("WHERE tag_id IN (%s)", vals)
}
query := fmt.Sprintf(`
SELECT video_tags.video_id,v.movie_name FROM video_tags join videos v on v.movie_id = video_tags.video_id
%s
group by video_id
ORDER BY RAND()
LIMIT %d`, whereclause, args.Number)
query := fmt.Sprintf("SELECT movie_id,movie_name FROM videos ORDER BY RAND() LIMIT %d", args.Number)
result.Videos = readVideosFromResultset(database.Query(query))
if len(result.Videos) > 0 {
var ids string
for i := range result.Videos {
ids += "video_tags.video_id=" + strconv.Itoa(result.Videos[i].MovieId)
var ids string
for i := range result.Videos {
ids += "video_tags.video_id=" + strconv.Itoa(result.Videos[i].MovieId)
if i < len(result.Videos)-1 {
ids += " OR "
}
if i < len(result.Videos)-1 {
ids += " OR "
}
}
// add the corresponding tags
query = fmt.Sprintf(`SELECT t.tag_name,t.tag_id FROM video_tags
// add the corresponding tags
query = fmt.Sprintf(`SELECT t.tag_name,t.tag_id FROM video_tags
INNER JOIN tags t on video_tags.tag_id = t.tag_id
WHERE %s
GROUP BY t.tag_id`, ids)
rows := database.Query(query)
if rows != nil {
for rows.Next() {
var tag types.Tag
err := rows.Scan(&tag.TagName, &tag.TagId)
if err != nil {
panic(err.Error()) // proper Error handling instead of panic in your app
}
// append to final array
result.Tags = append(result.Tags, tag)
}
rows := database.Query(query)
for rows.Next() {
var tag types.Tag
err := rows.Scan(&tag.TagName, &tag.TagId)
if err != nil {
panic(err.Error()) // proper Error handling instead of panic in your app
}
} else {
result.Tags = []types.Tag{}
// append to final array
result.Tags = append(result.Tags, tag)
}
context.Json(result)
@ -297,14 +276,14 @@ func loadVideosHandlers() {
return
}
query := fmt.Sprintf(`SELECT movie_name,movie_url,movie_id,thumbnail,poster,likes,quality,length,release_date
query := fmt.Sprintf(`SELECT movie_name,movie_url,movie_id,thumbnail,poster,likes,quality,length
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, &res.ReleaseDate)
err := database.QueryRow(query).Scan(&res.MovieName, &res.MovieUrl, &res.MovieId, &thumbnail, &poster, &res.Likes, &res.Quality, &res.Length)
if err != nil {
fmt.Printf("Error getting full data list of videoid - %d", args.MovieId)
fmt.Println(err.Error())

View File

@ -3,11 +3,16 @@ 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 (
@ -21,7 +26,7 @@ func (p Perm) String() string {
}
const SignKey = "89013f1753a6890c6090b09e3c23ff43"
const TokenExpireHours = 8760
const TokenExpireHours = 24
type Token struct {
Token string
@ -98,3 +103,15 @@ 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)
}
}

View File

@ -3,7 +3,6 @@ package types
type VideoUnloadedType struct {
MovieId int
MovieName string
Ratio float32
}
type FullVideoType struct {
@ -11,7 +10,6 @@ type FullVideoType struct {
MovieId uint32
MovieUrl string
Poster string
ReleaseDate *string
Likes uint64
Quality uint16
Length uint16

View File

@ -2,23 +2,16 @@ 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
//go:embed migrations/*.sql
var embedMigrations embed.FS
func InitDB() error {
func InitDB() {
dbconf := config.GetConfig().Database
DBName = dbconf.DBName
@ -28,32 +21,15 @@ func InitDB() error {
// if there is an error opening the connection, handle it
if err != nil {
return fmt.Errorf("Error while connecting to database! - %s\n", err.Error())
fmt.Printf("Error while connecting to database! - %s\n", err.Error())
}
if db != nil {
ping := db.Ping()
if ping != nil {
return fmt.Errorf("Error while connecting to database! - %s\n", ping.Error())
fmt.Printf("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 {

View File

@ -1,122 +0,0 @@
-- +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

View File

@ -1,12 +0,0 @@
-- +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

View File

@ -1,11 +0,0 @@
-- +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

View File

@ -5,10 +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/fsnotify/fsnotify v1.5.4
github.com/go-sql-driver/mysql v1.6.0
github.com/go-sql-driver/mysql v1.5.0
github.com/pelletier/go-toml/v2 v2.0.0-beta.3
github.com/pressly/goose/v3 v3.1.0
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2
gopkg.in/oauth2.v3 v3.12.0
nhooyr.io/websocket v1.8.7
)

View File

@ -1,16 +1,19 @@
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/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/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
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/fsnotify/fsnotify v1.5.4 h1:jRbGcIw6P2Meqdwuo0H1p6JVLbL5DHKAKlYndzMwVZI=
github.com/fsnotify/fsnotify v1.5.4/go.mod h1:OVB6XrOHzAwXMpEM7uPOzcehqUV2UqJxmVXmkdnm1bU=
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=
@ -22,79 +25,134 @@ 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-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/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/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-sql/civil v0.0.0-20190719163853-cb61b32ac6fe/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0=
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
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/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks=
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/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/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-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
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/pressly/goose/v3 v3.1.0 h1:V2Ulfm2XL9GtYNmrPUNFHieimf6diwADyMObnuuR2Mc=
github.com/pressly/goose/v3 v3.1.0/go.mod h1:tYsY0oL0yd48jg15POIZfOZiu66mqWpfDd/nJ28KWyU=
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/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/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=
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=
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/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad h1:ntjMns5wyP/fN65tdBD4g8J5w8n015+iIIs9rtjXkY0=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
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=

View File

@ -1,18 +0,0 @@
package housekeeping
import "fmt"
func RunHouseKeepingTasks() {
fmt.Println("Runnint houskeeping tasks!")
fmt.Println("Deduplicating Tags")
deduplicateTags()
fmt.Println("Deduplicating Tags assigned to videos")
deduplicateVideoTags()
fmt.Println("Fix missing video metadata like ratio")
fixMissingMetadata()
fmt.Println("Finished housekeeping")
}

View File

@ -1,5 +0,0 @@
package housekeeping
func fixMissingMetadata() {
// todo
}

View File

@ -1,86 +0,0 @@
package housekeeping
import (
"fmt"
"openmediacenter/apiGo/database"
)
func deduplicateTags() {
// find all duplicate tags
// gives first occurence of duplicate
query := `
SELECT
tag_name
FROM
tags
GROUP BY tag_name
HAVING COUNT(tag_name) > 1`
rows := database.Query(query)
duplicates := []string{}
if rows != nil {
for rows.Next() {
var id string
err := rows.Scan(&id)
if err != nil {
panic(err.Error()) // proper Error handling instead of panic in your app
}
duplicates = append(duplicates, id)
}
} else {
// nothing to do
return
}
fmt.Print("deleting duplicate tag ids: ")
fmt.Println(duplicates)
for _, el := range duplicates {
query := fmt.Sprintf("SELECT tag_id FROM tags WHERE tag_name='%s'", el)
rows := database.Query(query)
ids := []uint32{}
for rows.Next() {
var id uint32
err := rows.Scan(&id)
if err != nil {
panic(err.Error()) // proper Error handling instead of panic in your app
}
ids = append(ids, id)
}
// id to copy other data to
mainid := ids[0]
// ids to copy from
copyids := ids[1:]
fmt.Printf("Migrating %s\n", el)
migrateTags(mainid, copyids)
}
}
func migrateTags(destid uint32, sourcids []uint32) {
querytempl := `
UPDATE video_tags
SET
tag_id = %d
WHERE
tag_id = %d`
for _, id := range sourcids {
err := database.Edit(fmt.Sprintf(querytempl, destid, id))
if err != nil {
fmt.Printf("failed to set id from %d to %d\n", id, destid)
return
}
fmt.Printf("Merged %d into %d\n", id, destid)
// now lets delete this tag
query := fmt.Sprintf(`DELETE FROM tags WHERE tag_id=%d`, id)
err = database.Edit(query)
if err != nil {
fmt.Printf("failed to delete Tag %d", id)
return
}
}
}

View File

@ -1,37 +0,0 @@
package housekeeping
import (
"fmt"
"openmediacenter/apiGo/database"
)
func deduplicateVideoTags() {
// gives first occurence of duplicate
query := `
SELECT
tag_id, video_id, count(tag_id)
FROM
video_tags
GROUP BY tag_id, video_id
HAVING COUNT(tag_id) > 1`
rows := database.Query(query)
if rows != nil {
for rows.Next() {
var tagid uint32
var vidid uint32
var nr uint32
err := rows.Scan(&tagid, &vidid, &nr)
if err != nil {
panic(err.Error()) // proper Error handling instead of panic in your app
}
// now lets delete this tag
query := fmt.Sprintf(`DELETE FROM video_tags WHERE tag_id=%d AND video_id=%d LIMIT %d`, tagid, vidid, nr-1)
err = database.Edit(query)
if err != nil {
fmt.Printf("failed to delete Tag %d + vid %d", tagid, vidid)
return
}
}
}
}

View File

@ -1,13 +1,11 @@
package main
import (
"flag"
"fmt"
"openmediacenter/apiGo/api"
api2 "openmediacenter/apiGo/api/api"
"openmediacenter/apiGo/config"
"openmediacenter/apiGo/database"
"openmediacenter/apiGo/housekeeping"
"openmediacenter/apiGo/static"
"openmediacenter/apiGo/videoparser"
"os"
@ -17,9 +15,6 @@ import (
func main() {
fmt.Println("init OpenMediaCenter server")
const port uint16 = 8081
errc := make(chan error, 1)
housekPTr := flag.Bool("HouseKeeping", false, "Run housekeeping tasks")
config.Init()
@ -27,27 +22,18 @@ func main() {
fmt.Printf("Use verbose output: %t\n", config.GetConfig().General.VerboseLogging)
fmt.Printf("Videopath prefix: %s\n", config.GetConfig().General.ReindexPrefix)
err := database.InitDB()
if err != nil {
errc <- err
}
database.InitDB()
defer database.Close()
// check if we should run the housekeeping tasks
if *housekPTr {
housekeeping.RunHouseKeepingTasks()
return
}
api.AddHandlers()
videoparser.SetupSettingsWebsocket()
videoparser.InitFileWatcher()
// add the static files
static.ServeStaticFiles()
// init api
errc := make(chan error, 1)
go func() {
errc <- api2.ServerInit(port)
}()

View File

@ -1,58 +0,0 @@
package videoparser
import (
"github.com/fsnotify/fsnotify"
"log"
"openmediacenter/apiGo/config"
"openmediacenter/apiGo/database"
"strings"
)
func InitFileWatcher() {
watcher, err := fsnotify.NewWatcher()
if err != nil {
log.Fatal("NewWatcher failed: ", err)
}
mSettings, _, _ := database.GetSettings()
vidFolder := config.GetConfig().General.ReindexPrefix + mSettings.VideoPath
epsfolder := config.GetConfig().General.ReindexPrefix + mSettings.EpisodePath
defer watcher.Close()
go func() {
for {
select {
case event, ok := <-watcher.Events:
if !ok {
return
}
// start new reindex
// (may be optimized by checking here if added file is video
// and start reindex just for one file)
if strings.Contains(event.Name, vidFolder) {
StartReindex()
} else if strings.Contains(event.Name, epsfolder) {
StartTVShowReindex()
} else {
log.Printf("Event in wrong folder: %s %s\n", event.Name, event.Op)
}
case err, ok := <-watcher.Errors:
if !ok {
return
}
log.Println("error:", err)
}
}
}()
err = watcher.Add(vidFolder)
if err != nil {
log.Println("Adding of file watcher failed: ", err)
}
err = watcher.Add(epsfolder)
if err != nil {
log.Println("Adding of file watcher failed: ", err)
}
}

View File

@ -103,6 +103,7 @@ 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
@ -112,32 +113,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, ffmpegErr := thumbnail.Parse(vidFolder+fileName, 240)
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)
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 {
fmt.Printf("FFmpeg error occured: %s\n", ffmpegErr.Error())
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)
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)
// add default tags
if vinfo.Width != 0 && err == nil {
insertSizeTag(uint(vinfo.Width), uint(insertid))
}
}
@ -146,13 +147,6 @@ 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)
@ -217,30 +211,22 @@ func insertTMDBTags(ids []int, videoId int64) {
// now we check if the tag we want to add already exists
tagId := createTagToDB(idGenre.Name)
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)
}
// 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 := "SELECT tag_id FROM tags WHERE tag_name = ?"
var id int64 = -1
err := database.QueryRow(query, tagName).Scan(&id)
query := fmt.Sprintf("SELECT tag_id FROM tags WHERE tag_name = %s", tagName)
var id int64
err := database.QueryRow(query).Scan(&id)
if err == sql.ErrNoRows {
// tag doesn't exist -- add it
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())
}
query = fmt.Sprintf("INSERT INTO tags (tag_name) VALUES (%s)", tagName)
err, id = database.Insert(query)
}
return id
}

View File

@ -6,6 +6,7 @@ import (
"openmediacenter/apiGo/config"
"openmediacenter/apiGo/database"
"os"
"path/filepath"
"strings"
)
@ -46,19 +47,22 @@ func StartReindex() bool {
return false
}
filelist, err := ioutil.ReadDir(vidFolder)
var files []string
err := filepath.Walk(vidFolder, func(path string, info os.FileInfo, err error) error {
if err != nil {
fmt.Println(err.Error())
return err
}
if !info.IsDir() && ValidVideoSuffix(info.Name()) {
files = append(files, info.Name())
}
return nil
})
if err != nil {
fmt.Println(err.Error())
return false
}
var files []string
for _, file := range filelist {
if !file.IsDir() && ValidVideoSuffix(file.Name()) {
files = append(files, file.Name())
}
}
// start reindex process
AppendMessage("Starting Reindexing!")
InitDeps(&mSettings)

View File

@ -3,7 +3,6 @@
package thumbnail
import (
"fmt"
"github.com/3d0c/gmf"
"io"
"log"
@ -21,10 +20,10 @@ func Parse(filename string, time uint64) (*string, *VidInfo, error) {
}
}
func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]byte, info *VidInfo, err error) {
func decodePic(srcFileName string, decodeExtension string, time uint64) (pic *[]byte, info *VidInfo, err error) {
var swsctx *gmf.SwsCtx
gmf.LogSetLevel(gmf.AV_LOG_PANIC)
gmf.LogSetLevel(gmf.AV_LOG_ERROR)
stat, err := os.Stat(srcFileName)
if err != nil {
@ -47,19 +46,19 @@ func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]
return nil, nil, err
}
encodeCodec, err := gmf.FindEncoder(encodeExtension)
codec, err := gmf.FindEncoder(decodeExtension)
if err != nil {
log.Printf("%s\n", err)
return nil, nil, err
}
cc := gmf.NewCodecCtx(encodeCodec)
cc := gmf.NewCodecCtx(codec)
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 encodeCodec.IsExperimental() {
if codec.IsExperimental() {
cc.SetStrictCompliance(gmf.FF_COMPLIANCE_EXPERIMENTAL)
}
@ -69,35 +68,28 @@ func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]
}
defer cc.Free()
err = inputCtx.SeekFrameAt(int64(time), srcVideoStream.Index())
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)
if err != nil {
log.Printf("Error while seeking file: %s\n", err.Error())
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())
return
}
// 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(srcVideoStream.GetRFrameRate().AVR().Num) / float32(srcVideoStream.GetRFrameRate().AVR().Den)
frameRate := float32(ist.GetRFrameRate().AVR().Num) / float32(ist.GetRFrameRate().AVR().Den)
inf := VidInfo{
Width: uint32(icc.Width()),
Height: uint32(icc.Height()),
@ -135,7 +127,7 @@ func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]
continue
}
frames, err = srcVideoStream.CodecCtx().Decode(pkt)
frames, err = ist.CodecCtx().Decode(pkt)
if err != nil {
log.Printf("Fatal error during decoding - %s\n", err)
@ -170,7 +162,7 @@ func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]
p.Free()
}
for i := range frames {
for i, _ := range frames {
frames[i].Free()
frameCount++
}
@ -185,14 +177,9 @@ func decodePic(srcFileName string, encodeExtension string, time uint64) (pic *[]
}
for i := 0; i < inputCtx.StreamsCnt(); i++ {
st, err := inputCtx.GetStream(i)
if err == nil && st != nil {
st.Free()
}
st, _ := inputCtx.GetStream(i)
st.CodecCtx().Free()
st.Free()
}
icc.Free()
srcVideoStream.Free()
return
}

View File

@ -15,11 +15,10 @@ 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
ReleaseDate string
GenreIds []int
Thumbnail string
Overview string
Title string
GenreIds []int
}
type TVShowTMDB struct {
@ -121,11 +120,10 @@ cont:
}
result := VideoTMDB{
Thumbnail: thumbnail,
Overview: tmdbVid.Overview,
Title: tmdbVid.Title,
ReleaseDate: tmdbVid.ReleaseDate,
GenreIds: tmdbVid.GenreIds,
Thumbnail: thumbnail,
Overview: tmdbVid.Overview,
Title: tmdbVid.Title,
GenreIds: tmdbVid.GenreIds,
}
return &result
@ -207,14 +205,10 @@ func fetchGenres() *[]TMDBGenre {
return nil
}
type RespType struct {
Genres []TMDBGenre
}
var t RespType
var t []TMDBGenre
err = json.Unmarshal(body, &t)
return &t.Genres
return &t
}
func GetGenres() *[]TMDBGenre {

View File

@ -56,8 +56,8 @@ create table if not exists videos
thumbnail mediumblob null,
poster mediumblob null,
likes int default 0 null,
quality int default 0 null,
length int default 0 null comment 'in seconds',
quality int null,
length int null comment 'in seconds',
create_date datetime default current_timestamp() null
);

View File

@ -6,6 +6,10 @@ 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

View File

@ -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(5);
expect(wrapper.find('.navitem')).toHaveLength(4);
});
it('test render of password page', function () {

View File

@ -88,13 +88,6 @@ 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(' ')}

View File

@ -2,10 +2,7 @@
background-color: green;
border-radius: 5px;
border-width: 0;
color: white;
margin-right: 15px;
padding: 6px;
}
.button:hover{
opacity: 0.7;
}

View File

@ -1,6 +1,14 @@
import {shallow} from 'enzyme';
import React from 'react';
import {Button, IconButton} from './Button';
import {Button} from './Button';
function prepareFetchApi(response) {
const mockJsonPromise = Promise.resolve(response);
const mockFetchPromise = Promise.resolve({
json: () => mockJsonPromise
});
return (jest.fn().mockImplementation(() => mockFetchPromise));
}
describe('<Button/>', function () {
it('renders without crashing ', function () {
@ -22,24 +30,3 @@ 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);
});
});

View File

@ -1,8 +1,5 @@
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;
@ -11,30 +8,9 @@ interface ButtonProps {
}
export function Button(props: ButtonProps): JSX.Element {
const theme = GlobalInfos.getThemeStyle();
return (
<button className={style.button + ' ' + theme.textcolor} style={props.color} onClick={props.onClick}>
<button className={style.button} 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>
);
}

View File

@ -2,6 +2,7 @@
font-size: smaller;
font-weight: bold;
height: 20px;
max-width: 266px;
text-align: center;
}
@ -19,6 +20,13 @@
vertical-align: middle;
}
.previewimage {
max-height: 400px;
max-width: 410px;
min-height: 150px;
min-width: 266px;
}
.previewbottom {
height: 20px;
}

View File

@ -11,7 +11,6 @@ interface PreviewProps {
picLoader: (callback: (pic: string) => void) => void;
linkPath?: string;
onClick?: () => void;
aspectRatio?: number;
}
interface PreviewState {
@ -26,11 +25,6 @@ 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);
@ -49,7 +43,7 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
}
render(): JSX.Element {
if (this.props.linkPath != null) {
if (this.props.linkPath !== undefined) {
return <Link to={this.props.linkPath}>{this.content()}</Link>;
} else {
return this.content();
@ -58,31 +52,12 @@ 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
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}>
<div className={style.previewtitle + ' ' + themeStyle.lighttextcolor}>{this.props.name}</div>
<div className={style.previewpic}>
{this.state.picLoaded === false ? (
<FontAwesomeIcon
style={{
@ -97,20 +72,7 @@ class Preview extends React.Component<PreviewProps, PreviewState> {
<Spinner animation='border' />
</span>
) : (
<img
style={
dimstyle !== null
? dimstyle
: {
minWidth: Preview.DefMinWidth,
maxWidth: Preview.DefMaxWidth,
minHeight: Preview.DefMinHeight,
maxHeight: Preview.DefMaxHeight
}
}
src={this.pic}
alt='Pic loading.'
/>
<img className={style.previewimage} src={this.pic} alt='Pic loading.' />
)}
</div>
<div className={style.previewbottom} />

View File

@ -20,7 +20,7 @@ describe('<Preview/>', function () {
expect(func).toHaveBeenCalledTimes(1)
// received picture should be rendered into wrapper
expect(wrapper.find('img').props().src).toBe('42');
expect(wrapper.find('.previewimage').props().src).toBe('42');
// check if preview title renders correctly
expect(wrapper.find('.previewtitle').text()).toBe('test');
});

View File

@ -17,7 +17,7 @@ class Tag extends React.Component<props> {
if (this.props.onclick) {
return this.renderButton();
} else {
return <Link to={'/media/categories/' + this.props.tagInfo.TagId}>{this.renderButton()}</Link>;
return <Link to={'/categories/' + this.props.tagInfo.TagId}>{this.renderButton()}</Link>;
}
}

View File

@ -15,7 +15,6 @@ 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,

View File

@ -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='/media/actors'>
<Link to='/actors'>
<Button onClick={(): void => {}} title='Go to Actor overview' />
</Link>
</span>

View File

@ -58,7 +58,7 @@ export class HomePage extends React.Component<Props, state> {
};
}
sortState = SortBy.random;
sortState = SortBy.date;
tagState = DefaultTags.all;
componentDidMount(): void {

View File

@ -38,7 +38,7 @@ describe('<Player/>', function () {
// initial fetch for getting movie data
expect(global.fetch).toHaveBeenCalledTimes(1);
wrapper.find('.videoactions').find('IconButton').first().simulate('click');
wrapper.find('.videoactions').find('Button').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('IconButton').at(1).simulate('click');
wrapper.find('.videoactions').find('Button').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('IconButton').at(2).simulate('click');
wrapper.find('.videoactions').find('Button').at(2).simulate('click');
// click the first submit button
wrapper.find('ButtonPopup').dive().find('Button').at(0).simulate('click')

View File

@ -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, faTag, faThumbsUp, faTrash} from '@fortawesome/free-solid-svg-icons';
import {faPlusCircle} 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 {IconButton} from '../../elements/GPElements/Button';
import {Button} from '../../elements/GPElements/Button';
import {VideoTypes} from '../../types/ApiTypes';
import GlobalInfos from '../../utils/GlobalInfos';
import {ButtonPopup} from '../../elements/Popups/ButtonPopup/ButtonPopup';
@ -32,7 +32,6 @@ interface mystate {
movieName: string;
likes: number;
quality: number;
releaseDate: string | null;
length: number;
tags: TagType[];
suggesttag: TagType[];
@ -55,7 +54,6 @@ export class Player extends React.Component<Props, mystate> {
movieName: '',
likes: 0,
quality: 0,
releaseDate: null,
length: 0,
tags: [],
suggesttag: [],
@ -90,12 +88,18 @@ export class Player extends React.Component<Props, mystate> {
<div>not loaded yet</div>
)}
<div className={style.videoactions}>
<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!'
<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'}}
/>
</div>
{this.assembleActorTiles()}
@ -127,11 +131,6 @@ 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!
@ -324,7 +323,6 @@ 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,

View File

@ -2,21 +2,16 @@ import React from 'react';
import style from './RandomPage.module.css';
import SideBar, {SideBarTitle} from '../../elements/SideBar/SideBar';
import Tag from '../../elements/Tag/Tag';
import PageTitle, {Line} from '../../elements/PageTitle/PageTitle';
import PageTitle from '../../elements/PageTitle/PageTitle';
import VideoContainer from '../../elements/VideoContainer/VideoContainer';
import {APINode, callAPI} from '../../utils/Api';
import {TagType} from '../../types/VideoTypes';
import {VideoTypes} from '../../types/ApiTypes';
import {addKeyHandler, removeKeyHandler} from '../../utils/ShortkeyHandler';
import {IconButton} from '../../elements/GPElements/Button';
import {faMinusCircle, faPlusCircle} from '@fortawesome/free-solid-svg-icons';
import AddTagPopup from '../../elements/Popups/AddTagPopup/AddTagPopup';
interface state {
videos: VideoTypes.VideoUnloadedType[];
tags: TagType[];
filterTags: TagType[];
addTagPopup: boolean;
}
interface GetRandomMoviesType {
@ -34,10 +29,8 @@ class RandomPage extends React.Component<{}, state> {
super(props);
this.state = {
addTagPopup: false,
videos: [],
tags: [],
filterTags: []
tags: []
};
this.keypress = this.keypress.bind(this);
@ -56,76 +49,49 @@ class RandomPage extends React.Component<{}, state> {
render(): JSX.Element {
return (
<div>
<PageTitle title='Random Videos' subtitle='3pc' />
<PageTitle title='Random Videos' subtitle='4pc' />
<SideBar>
<SideBarTitle>Visible Tags:</SideBarTitle>
{this.state.tags.map((m) => (
<Tag key={m.TagId} tagInfo={m} />
))}
<Line />
<SideBarTitle>Filter Tags:</SideBarTitle>
{this.state.filterTags.map((m) => (
<Tag key={m.TagId} tagInfo={m} />
))}
<IconButton
title='Add'
icon={faPlusCircle}
onClick={(): void => {
this.setState({addTagPopup: true});
}}
/>
{this.state.filterTags.length > 0 ? (
<IconButton
title='Remove All'
icon={faMinusCircle}
onClick={(): void => {
this.setState({filterTags: []}, (): void => {
this.loadShuffledvideos(this.LoadNR);
});
}}
/>
) : (
<></>
)}
</SideBar>
{this.state.videos.length !== 0 ? <VideoContainer data={this.state.videos} /> : <div>No Data found!</div>}
<div className={style.Shufflebutton}>
<button onClick={(): void => this.loadShuffledvideos(this.LoadNR)} className={style.btnshuffle}>
Shuffle
</button>
</div>
{this.state.addTagPopup ? (
<AddTagPopup
onHide={(): void => this.setState({addTagPopup: false})}
submit={(tagId: number, tagName: string): void => {
this.setState({filterTags: [...this.state.filterTags, {TagId: tagId, TagName: tagName}]}, (): void => {
this.loadShuffledvideos(this.LoadNR);
});
}}
/>
) : null}
{this.state.videos.length !== 0 ? (
<VideoContainer data={this.state.videos}>
<div className={style.Shufflebutton}>
<button onClick={(): void => this.shuffleclick()} className={style.btnshuffle}>
Shuffle
</button>
</div>
</VideoContainer>
) : (
<div>No Data found!</div>
)}
</div>
);
}
/**
* click handler for shuffle btn
*/
shuffleclick(): void {
this.loadShuffledvideos(this.LoadNR);
}
/**
* load random videos from backend
* @param nr number of videos to load
*/
loadShuffledvideos(nr: number): void {
callAPI<GetRandomMoviesType>(
APINode.Video,
{action: 'getRandomMovies', Number: nr, TagFilter: this.state.filterTags.map((t) => t.TagId)},
(result) => {
this.setState({videos: []}); // needed to trigger rerender of main videoview
this.setState({
videos: result.Videos,
tags: result.Tags
});
}
);
callAPI<GetRandomMoviesType>(APINode.Video, {action: 'getRandomMovies', Number: nr}, (result) => {
this.setState({videos: []}); // needed to trigger rerender of main videoview
this.setState({
videos: result.Videos,
tags: result.Tags
});
});
}
/**
@ -135,7 +101,7 @@ class RandomPage extends React.Component<{}, state> {
private keypress(event: KeyboardEvent): void {
// bind s to shuffle
if (event.key === 's') {
this.loadShuffledvideos(3);
this.loadShuffledvideos(4);
}
}
}

View File

@ -66,7 +66,7 @@ export class EpisodePage extends React.Component<Props, State> {
export const EpisodeTile = (props: {episode: Episode}): JSX.Element => {
const themestyle = GlobalInfos.getThemeStyle();
return (
<Link to={'/media/tvplayer/' + props.episode.ID}>
<Link to={'/tvplayer/' + props.episode.ID}>
<div className={tileStyle.tile + ' ' + themestyle.secbackground + ' ' + themestyle.textcolor}>
<FontAwesomeIcon
style={{

View File

@ -55,7 +55,7 @@ export class TVShowPage extends React.Component<Props, State> {
(result) => callback(result)
);
}}
linkPath={'/media/tvshows/' + elem.Id}
linkPath={'/tvshows/' + elem.Id}
/>
)}
data={this.state.loading ? [] : this.data}

View File

@ -8,7 +8,6 @@ export namespace VideoTypes {
MovieName: string;
Likes: number;
Quality: number;
ReleaseDate: string | null;
Length: number;
Tags: TagType[];
SuggestedTag: TagType[];
@ -27,7 +26,6 @@ export namespace VideoTypes {
export interface VideoUnloadedType {
MovieId: number;
MovieName: string;
Ratio: number;
}
}

View File

@ -103,5 +103,5 @@ export enum APINode {
Tags = 'tags',
Actor = 'actor',
Video = 'video',
TVShow = 'tv'
TVShow = 'tvshow'
}

View File

@ -3538,9 +3538,9 @@ caniuse-api@^3.0.0:
lodash.uniq "^4.5.0"
caniuse-lite@^1.0.0, caniuse-lite@^1.0.30000981, caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001125, caniuse-lite@^1.0.30001219:
version "1.0.30001336"
resolved "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001336.tgz"
integrity sha512-/YxSlBmL7iKXTbIJ48IQTnAOBk7XmWsxhBF1PZLOko5Dt9qc4Pl+84lfqG3Tc4EuavurRn1QLoVJGxY2iSycfw==
version "1.0.30001236"
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001236.tgz#0a80de4cdf62e1770bb46a30d884fc8d633e3958"
integrity sha512-o0PRQSrSCGJKCPZcgMzl5fUaj5xHe8qA2m4QRvnyY4e1lITqoNkr7q/Oh1NcpGSy0Th97UZ35yoKcINPoq7YOQ==
capture-exit@^2.0.0:
version "2.0.0"