@@ -3,6 +3,7 @@ package main
33import (
44 "bytes"
55 "encoding/json"
6+ "explo/debug"
67 "fmt"
78 "log"
89 "net/url"
@@ -221,21 +222,21 @@ func searchPlexPlaylist(cfg Config) (string, error) {
221222 return "" , fmt .Errorf ("searchPlexPlaylist(): failed to parse response: %s" , err .Error ())
222223 }
223224
224- key , err := getPlexPlaylist (playlists , cfg .PlaylistName )
225- if err != nil {
226- return "" , fmt . Errorf ( "getPlexPlaylist(): %s" , err . Error () )
225+ key := getPlexPlaylist (playlists , cfg .PlaylistName )
226+ if key == "" {
227+ debug . Debug ( "no playlist found" )
227228 }
228229 return key , nil
229230}
230231
231- func getPlexPlaylist (playlists PlexPlaylist , playlistName string ) ( string , error ) {
232+ func getPlexPlaylist (playlists PlexPlaylist , playlistName string ) string {
232233
233234 for _ , playlist := range playlists .MediaContainer .Metadata {
234235 if playlist .Title == playlistName {
235- return playlist .Key , nil
236+ return playlist .Key
236237 }
237238 }
238- return "" , fmt . Errorf ( "failed to find playlist" )
239+ return ""
239240}
240241
241242func getPlexServer (cfg Config ) (string , error ) {
@@ -255,8 +256,8 @@ func getPlexServer(cfg Config) (string, error) {
255256 return server .MediaContainer .MachineIdentifier , nil
256257}
257258
258- func createPlexPlaylist (cfg Config , libraryKey , machineID string ) (string , error ) {
259- params := fmt .Sprintf ("/playlists?title=%s&type=audio&smart=0&uri=server://%s/com.plexapp.plugins.library/%s&X-Plex-Token=%s" , cfg .PlaylistName , machineID , libraryKey , cfg .Creds .APIKey )
259+ func createPlexPlaylist (cfg Config , machineID string ) (string , error ) {
260+ params := fmt .Sprintf ("/playlists?title=%s&type=audio&smart=0&uri=server://%s/com.plexapp.plugins.library/%s&X-Plex-Token=%s" , cfg .PlaylistName , machineID , cfg . Plex . LibraryID , cfg .Creds .APIKey )
260261
261262 body , err := makeRequest ("POST" , cfg .URL + params , nil , cfg .Creds .Headers )
262263 if err != nil {
@@ -273,16 +274,15 @@ func createPlexPlaylist(cfg Config, libraryKey, machineID string) (string, error
273274 return playlist .MediaContainer .Metadata [0 ].Key , nil
274275}
275276
276- func addToPlexPlaylist (cfg Config , playlistKey , machineID string , tracks []Track ) error {
277+ func addToPlexPlaylist (cfg Config , playlistKey , machineID string , tracks []Track ) {
277278 for _ , track := range tracks {
278279 params := fmt .Sprintf ("/playlists/%s?uri=server://%s/com.plexapp.plugins.library/%s&X-Plex-Token=%s" , playlistKey , machineID , track .ID , cfg .Creds .APIKey )
279280
280281 _ , err := makeRequest ("PUT" , cfg .URL + params , nil , cfg .Creds .Headers )
281282 if err != nil {
282- return fmt . Errorf ("addToPlexPlaylist(): failed to add %s to playlist: %s" , track .Title , err .Error ())
283+ log . Printf ("addToPlexPlaylist(): failed to add %s to playlist: %s" , track .Title , err .Error ())
283284 }
284285 }
285- return nil
286286}
287287
288288func deletePlexPlaylist (cfg Config , playlistKey string ) error {
0 commit comments