func RemoveMovie(ctx *gin.Context) { LibraryPath := config.Get().LibraryPath MoviesLibraryPath := filepath.Join(LibraryPath, "Movies") DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName)) imdbId := ctx.Params.ByName("imdbId") movie := tmdb.GetMovieFromIMDB(imdbId, "en") MovieStrm := toFileName(fmt.Sprintf("%s (%s)", movie.OriginalTitle, strings.Split(movie.ReleaseDate, "-")[0])) MoviePath := filepath.Join(MoviesLibraryPath, MovieStrm) if err := RemoveFromJsonDB(DBPath, imdbId, LMovie); err != nil { libraryLog.Info("Unable to remove movie from db") ctx.String(404, "") return } if err := os.RemoveAll(MoviePath); err != nil { libraryLog.Info("Unable to remove movie folder") ctx.String(404, "") return } xbmc.Notify("Quasar", "LOCALIZE[30222]", config.AddonIcon()) ctx.String(200, "") xbmc.VideoLibraryClean() libraryLog.Info("Movie removed") }
func RemoveShow(ctx *gin.Context) { LibraryPath := config.Get().LibraryPath ShowsLibraryPath := filepath.Join(LibraryPath, "Shows") DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName)) showId := ctx.Params.ByName("showId") show, err := tvdb.NewShow(showId, "en") if err != nil { ctx.String(404, "") return } ShowPath := filepath.Join(ShowsLibraryPath, toFileName(show.SeriesName)) if err := RemoveFromJsonDB(DBPath, showId, LShow); err != nil { libraryLog.Info("Unable to remove show from db") ctx.String(404, "") return } if err := os.RemoveAll(ShowPath); err != nil { libraryLog.Info("Unable to remove show folder") ctx.String(404, "") return } xbmc.Notify("Quasar", "LOCALIZE[30222]", config.AddonIcon()) ctx.String(200, "") xbmc.VideoLibraryClean() libraryLog.Info("Show removed") }
func RemoveShow(ctx *gin.Context) { LibraryPath := config.Get().LibraryPath ShowsLibraryPath := filepath.Join(LibraryPath, "Shows") DBPath := filepath.Join(LibraryPath, fmt.Sprintf("%s.json", DBName)) showId := ctx.Params.ByName("showId") Id, _ := strconv.Atoi(showId) show := tmdb.GetShow(Id, "en") if show == nil { ctx.String(404, "") return } ShowStrm := toFileName(fmt.Sprintf("%s (%s)", show.Name, strings.Split(show.FirstAirDate, "-")[0])) ShowPath := filepath.Join(ShowsLibraryPath, ShowStrm) if err := RemoveFromJsonDB(DBPath, showId, LShow); err != nil { libraryLog.Error("Unable to remove show from db") ctx.String(404, "") return } if err := os.RemoveAll(ShowPath); err != nil { libraryLog.Error("Unable to remove show folder") ctx.String(404, "") return } xbmc.Notify("Quasar", "LOCALIZE[30222]", config.AddonIcon()) ctx.String(200, "") xbmc.VideoLibraryClean() ClearCache(ctx) xbmc.Refresh() libraryLog.Notice("Show removed") }