TESTING YOUR URL SERVICE
To test your url service, the best way is to use
http://localhost:32400/system/services/url/lookup?url=
This should be followed by an http address for a page within the website the URL service is used for that contains a video. Also, you must first use a URL encoder like http://meyerweb.com/eric/tools/dencoder/ to put that video page URL in the proper format.
UPDATE: When using the latest version of PMS that includes Plex Home, you must add &X-Plex-Token= to the end of the encoded URL. To find your token, see these instructions https://support.plex.tv/hc/en-us/articles/204059436-Finding-your-account-token-X-Plex-Token. So it would be:
http://localhost:32400/system/services/url/lookup?url=&X-Plex-Token=
Once you paste the Plex test address into the address bar of your browser, an XML page will show you the metadata for this video along with the available media with keys for the video parts. If this info does not come up, check the system log (come.plexapp.system.log) for errors.
To see the actual video file URL and any errors that may result from playing this video listed in a key, you will then cut the key data from that XML page you pulled up above and paste it in the address bar of your browser following the base Plex address of 'http://localhost:32400'.
The resulting page should take you either directly to a page that plays the video file if you used Redirect in your PlayVideo function or if you use @indirect in your PlayVideo function, it will take you to an XML document that provides the exact details of that video file based on how your media is returned in your ServiceCode.pys. If it does not open the video or the proper XML file with the video information, the resulting XML page should show you any errors within the code including which lines of your code caused the error.
Example:
To test the URL service for the L Studios URL service, I will use the video available at http://www.lstudio.com/web-therapy/season-4-morals-to-the-max.html. The full format of the Plex test URL for the video page above is http://localhost:32400/system/services/url/lookup?url=http%3A%2F%2Fwww.lstudio.com%2Fweb-therapy%2Fseason-4-morals-to-the-max.html.
We will use the first key for the first media part available through the Plex test URL above that is the 720p version of the video. The value of that key is:
/:/plugins/com.plexapp.system/serviceFunction/url/com.plexapp.plugins.lstudio/L%20Studio/PlayVideo?args=Y2VyZWFsMQoxCnR1cGxlCjAKcjAK&kwargs=Y2VyZWFsMQoxCmRpY3QKMgpzNjYKaHR0cDovL3d3dy5sc3R1ZGlvLmNvbS93ZWItdGhlcmFweS9zZWFzb24tNC1tb3JhbHMtdG8tdGhlLW1heC5odG1sczMKdXJsczIKaGlzMwpmbXRyMAo_&indirect=1&mediaInfo=%7B%22audio_channels%22%3A%202%2C%20%22protocol%22%3A%20null%2C%20%22optimized_for_streaming%22%3A%20null%2C%20%22video_frame_rate%22%3A%20null%2C%20%22duration%22%3A%20null%2C%20%22height%22%3A%20720%2C%20%22width%22%3A%201280%2C%20%22container%22%3A%20%22mp4%22%2C%20%22audio_codec%22%3A%20%22aac%22%2C%20%22aspect_ratio%22%3A%20null%2C%20%22video_codec%22%3A%20%22h264%22%2C%20%22video_resolution%22%3A%20%22720%22%2C%20%22bitrate%22%3A%20null%7D
Since @indirect is used in the PlayVideo function of this example URL service, when you put that URL into the address bar of your web browser, it takes you to an XML page that has the final and direct info about the video associated with that page that is of type mp4 and a quality of 720p, since that was the version of the video we chose from the keys.
IMPORTANT NOTE:
I have recently been informed that you should always use the @indirect method in your code. Redirect can cause errors with some clients if the video file has to be transcoded, so it is always the best practice to use @indirect.
The information on this page includes the direct video file URL for the media (http://videos.lstudio.com/high/WT_S4_Ep1_HI.mp4) that is associated with the video page we chose in the beginning of this example.