/**
   * Retrieve the latest video in the specified playlist.
   *
   * @param pPlaylistId the id of the playlist for which to retrieve the latest video id
   * @return the video id of the latest video, null if something goes wrong
   * @throws java.io.IOException
   * @throws org.apache.http.client.ClientProtocolException
   * @throws javax.xml.parsers.FactoryConfigurationError
   */
  public static String queryLatestPlaylistVideo(PlaylistId pPlaylistId)
      throws IOException, ClientProtocolException, FactoryConfigurationError {

    String lVideoId = null;

    HttpClient lClient = new DefaultHttpClient();

    HttpGet lGetMethod =
        new HttpGet(
            YoutubeUrlIDs.YOUTUBE_PLAYLIST_ATOM_FEED_URL
                + pPlaylistId.getId()
                + "?v=2&max-results=50&alt=json");

    HttpResponse lResp = null;

    lResp = lClient.execute(lGetMethod);

    ByteArrayOutputStream lBOS = new ByteArrayOutputStream();
    String lInfoStr = null;
    JSONObject lYouTubeResponse = null;

    try {

      lResp.getEntity().writeTo(lBOS);
      lInfoStr = lBOS.toString("UTF-8");
      lYouTubeResponse = new JSONObject(lInfoStr);

      JSONArray lEntryArr = lYouTubeResponse.getJSONObject("feed").getJSONArray("entry");
      JSONArray lLinkArr = lEntryArr.getJSONObject(lEntryArr.length() - 1).getJSONArray("link");
      for (int i = 0; i < lLinkArr.length(); i++) {
        JSONObject lLinkObj = lLinkArr.getJSONObject(i);
        ;
        String lRelVal = lLinkObj.optString("rel", null);
        if (lRelVal != null && lRelVal.equals("alternate")) {

          String lUriStr = lLinkObj.optString("href", null);
          Uri lVideoUri = Uri.parse(lUriStr);
          lVideoId = lVideoUri.getQueryParameter("v");
          break;
        }
      }
    } catch (IllegalStateException e) {
      Log.i(YouTubeUtility.class.getSimpleName(), "Error retrieving content from YouTube", e);
    } catch (IOException e) {
      Log.i(YouTubeUtility.class.getSimpleName(), "Error retrieving content from YouTube", e);
    } catch (JSONException e) {
      Log.i(YouTubeUtility.class.getSimpleName(), "Error retrieving content from YouTube", e);
    }

    return lVideoId;
  }
 public Tracks getTracks(final PlaylistId playlistId) {
   return baseService.get(PREFIX_PLAYLIST, playlistId.getId(), "tracks", Tracks.class);
 }
 public Comments getComments(final PlaylistId playlistId) {
   return baseService.get(PREFIX_PLAYLIST, playlistId.getId(), "comments", Comments.class);
 }
 public Fans getFans(final PlaylistId playlistId) {
   return baseService.get(PREFIX_PLAYLIST, playlistId.getId(), "fans", Fans.class);
 }
 public Playlist get(final PlaylistId playlistId) {
   return baseService.get(PREFIX_PLAYLIST, playlistId.getId(), Playlist.class);
 }