diff --git a/apiGo/videoparser/ReIndexVideos.go b/apiGo/videoparser/ReIndexVideos.go index 1c6459b..239d7d9 100644 --- a/apiGo/videoparser/ReIndexVideos.go +++ b/apiGo/videoparser/ReIndexVideos.go @@ -129,9 +129,9 @@ func addVideo(videoName string, fileName string, year int) { 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) - + // we insert the poster here also because it might not be nil when tmdb index is enabled. + query := `INSERT INTO videos(movie_name,movie_url,thumbnail) VALUES (?,?,?)` + err, insertid = database.Insert(query, videoName, fileName, poster) } 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) @@ -211,22 +211,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 } diff --git a/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go b/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go index 7cdc51d..3559f5c 100644 --- a/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go +++ b/apiGo/videoparser/thumbnail/Thumbnailparser_shared_ffmpeg.go @@ -23,7 +23,7 @@ func Parse(filename string, time uint64) (*string, *VidInfo, error) { func decodePic(srcFileName string, decodeExtension 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 { diff --git a/apiGo/videoparser/tmdb/TMDBApi.go b/apiGo/videoparser/tmdb/TMDBApi.go index f5461ef..8a36aa9 100644 --- a/apiGo/videoparser/tmdb/TMDBApi.go +++ b/apiGo/videoparser/tmdb/TMDBApi.go @@ -205,10 +205,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 { diff --git a/database.sql b/database.sql index 295fe42..97f685d 100644 --- a/database.sql +++ b/database.sql @@ -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 );