diff --git a/TODO b/TODO index 4d721fa..406e064 100644 --- a/TODO +++ b/TODO @@ -2,6 +2,9 @@ ## features +- make language a pull down menu tv / movies page +- re-assess new filter for tv / movie page + ## bugs - mandalorian is not showing up on amazon tv search diff --git a/cmd/root.go b/cmd/root.go index 9e636a3..27fc382 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -66,7 +66,7 @@ func initializeFlags() { func initializePlexMovies() []types.PlexMovie { var allMovies []types.PlexMovie - allMovies = append(allMovies, plex.GetPlexMovies(plexIP, plexMovieLibraryID, plexToken)...) + allMovies = append(allMovies, plex.AllMovies(plexIP, plexMovieLibraryID, plexToken)...) fmt.Printf("\nThere are a total of %d movies in the library.\n\nMovies available:\n", len(allMovies)) return allMovies diff --git a/plex/plex.go b/plex/plex.go index e90cfa6..59aa0f2 100644 --- a/plex/plex.go +++ b/plex/plex.go @@ -827,7 +827,7 @@ type Filter struct { Modifier string } -func GetPlexMovies(ipAddress, libraryID, plexToken string) (movieList []types.PlexMovie) { +func AllMovies(ipAddress, libraryID, plexToken string) (movieList []types.PlexMovie) { url := fmt.Sprintf("http://%s:32400/library/sections/%s/all", ipAddress, libraryID) response, err := makePlexAPIRequest(url, plexToken) @@ -845,7 +845,7 @@ func GetPlexMovies(ipAddress, libraryID, plexToken string) (movieList []types.Pl semaphore <- struct{}{} go func(i int) { defer func() { <-semaphore }() - getPlexMovieDetails(ipAddress, plexToken, &movieList[i], ch) + getMovieDetails(ipAddress, plexToken, &movieList[i], ch) }(i) } detailedMovies := make([]types.PlexMovie, len(movieList)) @@ -876,7 +876,7 @@ func extractMovies(xmlString string) (movieList []types.PlexMovie) { return movieList } -func getPlexMovieDetails(ipAddress, plexToken string, movie *types.PlexMovie, ch chan<- types.PlexMovie) { +func getMovieDetails(ipAddress, plexToken string, movie *types.PlexMovie, ch chan<- types.PlexMovie) { url := fmt.Sprintf("http://%s:32400/library/metadata/%s", ipAddress, movie.RatingKey) response, err := makePlexAPIRequest(url, plexToken) @@ -908,7 +908,7 @@ func getPlexMovieDetails(ipAddress, plexToken string, movie *types.PlexMovie, ch } // ================================================================================================= -func GetPlexTV(ipAddress, libraryID, plexToken string) (tvShowList []types.PlexTVShow) { +func AllTV(ipAddress, libraryID, plexToken string) (tvShowList []types.PlexTVShow) { url := fmt.Sprintf("http://%s:32400/library/sections/%s/all", ipAddress, libraryID) response, err := makePlexAPIRequest(url, plexToken) @@ -954,7 +954,7 @@ func getPlexTVSeasons(ipAddress, plexToken, ratingKey string) (seasonList []type semaphore <- struct{}{} go func(i int) { defer func() { <-semaphore }() - getPlexTVEpisodes(ipAddress, plexToken, &seasonList[i], ch) + getTVEpisodes(ipAddress, plexToken, &seasonList[i], ch) }(i) } @@ -988,7 +988,7 @@ func getPlexTVSeasons(ipAddress, plexToken, ratingKey string) (seasonList []type return filteredSeasons } -func getPlexTVEpisodes(ipAddress, plexToken string, season *types.PlexTVSeason, ch chan<- types.PlexTVSeason) { +func getTVEpisodes(ipAddress, plexToken string, season *types.PlexTVSeason, ch chan<- types.PlexTVSeason) { url := fmt.Sprintf("http://%s:32400/library/metadata/%s/children?", ipAddress, season.RatingKey) response, err := makePlexAPIRequest(url, plexToken) @@ -1062,7 +1062,7 @@ func extractTVEpisodes(xmlString string) (episodeList []types.PlexTVEpisode) { } // ================================================================================================= -func GetPlexMusicArtists(ipAddress, plexToken, libraryID string) (artists []types.PlexMusicArtist) { +func AllMusicArtists(ipAddress, plexToken, libraryID string) (artists []types.PlexMusicArtist) { url := fmt.Sprintf("http://%s:32400/library/sections/%s/all", ipAddress, libraryID) response, err := makePlexAPIRequest(url, plexToken) @@ -1079,14 +1079,14 @@ func GetPlexMusicArtists(ipAddress, plexToken, libraryID string) (artists []type } // now we need to get the albums for each artist for i := range artists { - artists[i].Albums = GetPlexMusicAlbums(ipAddress, plexToken, libraryID, artists[i].RatingKey) + artists[i].Albums = GetArtistMusicAlbums(ipAddress, plexToken, libraryID, artists[i].RatingKey) } fmt.Printf("Plex music artists: %d.\n", len(artists)) return artists } -func GetPlexMusicAlbums(ipAddress, plexToken, libraryID, ratingKey string) (albums []types.PlexMusicAlbum) { +func GetArtistMusicAlbums(ipAddress, plexToken, libraryID, ratingKey string) (albums []types.PlexMusicAlbum) { url := fmt.Sprintf("http://%s:32400/library/sections/%s/all?artist.id=%s&type=9", ipAddress, libraryID, ratingKey) response, err := makePlexAPIRequest(url, plexToken) diff --git a/plex/plex_test.go b/plex/plex_test.go index 1636e45..d61a98f 100644 --- a/plex/plex_test.go +++ b/plex/plex_test.go @@ -57,7 +57,7 @@ func TestGetPlexMovies(t *testing.T) { if plexIP == "" || plexMovieLibraryID == "" || plexToken == "" { t.Skip("ACCEPTANCE TEST: PLEX environment variables not set") } - result := GetPlexMovies(plexIP, plexMovieLibraryID, plexToken) + result := AllMovies(plexIP, plexMovieLibraryID, plexToken) if len(result) == 0 { t.Errorf("Expected at least one TV show, but got %d", len(result)) @@ -68,7 +68,7 @@ func TestGetPlexTV(t *testing.T) { if plexIP == "" || plexTVLibraryID == "" || plexToken == "" { t.Skip("ACCEPTANCE TEST: PLEX environment variables not set") } - result := GetPlexTV(plexIP, plexTVLibraryID, plexToken) + result := AllTV(plexIP, plexTVLibraryID, plexToken) if len(result) == 0 { t.Errorf("Expected at least one TV show, but got %d", len(result)) @@ -102,7 +102,7 @@ func TestGetPlexMusic(t *testing.T) { if plexIP == "" || plexMusicLibraryID == "" || plexToken == "" { t.Skip("ACCEPTANCE TEST: PLEX environment variables not set") } - result := GetPlexMusicArtists(plexIP, plexToken, plexMusicLibraryID) + result := AllMusicArtists(plexIP, plexToken, plexMusicLibraryID) if len(result) == 0 { t.Errorf("Expected at least one album, but got %d", len(result)) diff --git a/web/movies/movies.go b/web/movies/movies.go index 9b44901..f1b1e0d 100644 --- a/web/movies/movies.go +++ b/web/movies/movies.go @@ -48,7 +48,7 @@ func (c MoviesConfig) ProcessHTML(w http.ResponseWriter, r *http.Request) { // fetch from plex if playlist == "all" { if len(plexMovies) == 0 { - plexMovies = plex.GetPlexMovies(c.Config.PlexIP, c.Config.PlexMovieLibraryID, c.Config.PlexToken) + plexMovies = plex.AllMovies(c.Config.PlexIP, c.Config.PlexMovieLibraryID, c.Config.PlexToken) } } else { plexMovies = plex.GetMoviesFromPlaylist(c.Config.PlexIP, c.Config.PlexToken, playlist) diff --git a/web/music/music.go b/web/music/music.go index 03215b0..1e37327 100644 --- a/web/music/music.go +++ b/web/music/music.go @@ -77,7 +77,7 @@ func (c MusicConfig) ProcessHTML(w http.ResponseWriter, r *http.Request) { lookupType = r.FormValue("lookuptype") // only get the artists from plex once if playlist == "all" { - plexMusic = plex.GetPlexMusicArtists(c.Config.PlexIP, c.Config.PlexToken, c.Config.PlexMusicLibraryID) + plexMusic = plex.AllMusicArtists(c.Config.PlexIP, c.Config.PlexToken, c.Config.PlexMusicLibraryID) } else { plexMusic = plex.GetArtistsFromPlaylist(c.Config.PlexIP, c.Config.PlexToken, playlist) } diff --git a/web/tv/tv.go b/web/tv/tv.go index 37d35d9..2fd44be 100644 --- a/web/tv/tv.go +++ b/web/tv/tv.go @@ -46,7 +46,7 @@ func (c TVConfig) ProcessHTML(w http.ResponseWriter, r *http.Request) { newFilters.AudioLanguage = r.FormValue("language") newFilters.NewerVersion = r.FormValue("newerVersion") == types.StringTrue if len(plexTV) == 0 || filters != newFilters { - plexTV = plex.GetPlexTV(c.Config.PlexIP, c.Config.PlexTVLibraryID, c.Config.PlexToken) + plexTV = plex.AllTV(c.Config.PlexIP, c.Config.PlexTVLibraryID, c.Config.PlexToken) } filters = newFilters //nolint: gocritic