1

I am new to java and I am trying to do some URL encoding to retrieve plex livetv directories with GET command. The issue I am having is with the colon ":" if I use the colon, I get this error, but if I use URL encoding "tv.plex.providers.epg.onconnect%3A23" I get a blank livetv library.

What is the proper way to define URL encoding for the ":" string?

Malformed URL. Base: http://192.168.1.50:32400/, Relative: tv.plex.providers.epg.onconnect:23/sections

public interface PlexMediaContainerService {

    @GET("/")
    Call<MediaContainer> retrieveRoot();

    @GET("tv.plex.providers.epg.onconnect%3A23")
    Call<MediaContainer> retrieveLibrary();

    @GET("tv.plex.providers.epg.onconnect%3A23/sections")
    Call<MediaContainer> retrieveSections();

    @GET("tv.plex.providers.epg.onconnect%3A23/sections/{key}")
    Call<MediaContainer> retrieveSections(@Path("key") String key);

    @GET("tv.plex.providers.epg.onconnect%3A23/sections/{key}/{category}")
    Call<MediaContainer> retrieveSections(@Path("key") String key,
                                          @Path(value = "category", encoded = true) String category);

    @GET("tv.plex.providers.epg.onconnect%3A23/sections/{key}/{category}/{secondaryCategory}")
    Call<MediaContainer> retrieveSections(@Path("key") String key,
                                          @Path(value = "category", encoded = true)  String category,
                                          @Path(value = "secondaryCategory", encoded = true) String secondaryCategory);

    @GET("{urlPath}")
    Call<MediaContainer> retrieveItemByUrlPath(@Path(value = "urlPath", encoded = true) String key);


    @GET("tv.plex.providers.epg.onconnect%3A23/sections/{key}/search?type=1")
    Call<MediaContainer> movieSearch(@Path("key") String key,
                                    @Query("query") String query);

    @GET("tv.plex.providers.epg.onconnect%3A23/sections/{key}/search?type=2")
    Call<MediaContainer> tvShowsSearch(@Path("key") String key,
                              @Query("query") String query);

    @GET("tv.plex.providers.epg.onconnect%3A23/sections/{key}/search?type=4")
    Call<MediaContainer> episodeSearch(@Path("key") String key,
                                       @Query("query") String query);
}
  • This most likely will work from here:https://stackoverflow.com/questions/7874922/how-can-i-make-urlencoding-not-encode-colon URLEncoder.encode(theUrl).replace("%3A", ":"); – Matthew Gorski Apr 27 '18 at 13:32

1 Answers1

0

The issue is that resolve method down in the okhttp layer doesn't know how to merge to urls that both start with a host. You can add a / to the start of your paths to make okhttp understand that it is a path and not a host. You shouldn't need to encode the : yourself. For example,

@GET("/tv.plex.providers.epg.onconnect:23")
Call<MediaContainer> retrieveLibrary();
iagreen
  • 31,470
  • 8
  • 76
  • 90
  • Thank you so much lagreen! Adding the / to the start of the path fixed this issue. Now data is parsing correctly. Much appreciation for your time. – Matthew Gorski May 01 '18 at 02:55