Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix) return audio for movie playlists #46

Merged
merged 1 commit into from
Jun 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions TODO
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@
- vikings, Once Upon a Time in Wonderland, What We Do in the Shadows, The Peter Serafinowicz Show is not showing up on cinema-paradiso tv search
- allow the use of playlists for finding music / TV / movies `https://www.plexopedia.com/plex-media-server/api/playlists/view/`
- make language a pull down menu tv / movies page
- plex audio types not showing for plex movie playlists
2 changes: 1 addition & 1 deletion musicbrainz/musicbrainz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestSearchMusicBrainzArtist(t *testing.T) {
{
Name: "AC/DC",
ID: "66c662b6-6e2f-4930-8610-912e24c63ed1",
Albums: make([]types.MusicAlbumSearchResult, 18),
Albums: make([]types.MusicAlbumSearchResult, 17),
},
},
},
Expand Down
28 changes: 23 additions & 5 deletions plex/plex.go
Original file line number Diff line number Diff line change
Expand Up @@ -1405,7 +1405,7 @@ func GetMoviesFromPlaylist(ipAddress, plexToken, ratingKey string) (playlistItem
return playlistItems
}

playlistItems, err = extractMoviesFromPlaylist(response)
playlistItems, err = extractMoviesFromPlaylist(response, ipAddress, plexToken)
if err != nil {
fmt.Println("Error extracting playlist items:", err)
}
Expand Down Expand Up @@ -1442,23 +1442,41 @@ func GetArtistsFromPlaylist(ipAddress, plexToken, ratingKey string) (playlistIte
return playlistItems
}

func extractMoviesFromPlaylist(xmlString string) (playlistItems []types.PlexMovie, err error) {
func extractMoviesFromPlaylist(xmlString, ipAddress, plexToken string) (movieList []types.PlexMovie, err error) {
var container MoviePlaylist
err = xml.Unmarshal([]byte(xmlString), &container)
if err != nil {
fmt.Println("Error parsing XML:", err)
return playlistItems, err
return movieList, err
}

for i := range container.Video {
playlistItems = append(playlistItems, types.PlexMovie{
movieList = append(movieList, types.PlexMovie{
Title: container.Video[i].Title,
RatingKey: container.Video[i].RatingKey,
Resolution: container.Video[i].Media[0].VideoResolution,
Year: container.Video[i].Year,
DateAdded: parsePlexDate(container.Video[i].AddedAt)})
}
return playlistItems, nil
// this is were we get the movie details
ch := make(chan types.PlexMovie, len(movieList))
semaphore := make(chan struct{}, types.ConcurrencyLimit)

for i := range movieList {
semaphore <- struct{}{}
go func(i int) {
defer func() { <-semaphore }()
getMovieDetails(ipAddress, plexToken, &movieList[i], ch)
}(i)
}
detailedMovies := make([]types.PlexMovie, len(movieList))
// wait for all of the go routines to finish
for i := range movieList {
detailedMovies[i] = <-ch
}
fmt.Printf("Plex movies: %d.\n", len(detailedMovies))

return movieList, nil
}

func extractTVFromPlaylist(xmlString string) (playlistItems []types.PlexTVShow, err error) {
Expand Down
2 changes: 1 addition & 1 deletion plex/plex_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestGetPlexTV(t *testing.T) {
if plexIP == "" || plexTVLibraryID == "" || plexToken == "" {
t.Skip("ACCEPTANCE TEST: PLEX environment variables not set")
}
result := AllTV(plexIP, plexTVLibraryID, plexToken)
result := AllTV(plexIP, plexToken, plexTVLibraryID)

if len(result) == 0 {
t.Errorf("Expected at least one TV show, but got %d", len(result))
Expand Down
Loading