Android Open Source - glvideoplayer-android Video Rss Parser






From Project

Back to project page glvideoplayer-android.

License

The source code is released under:

Apache License

If you think the Android project glvideoplayer-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package net.binzume.android.nicovideo.webapi;
//ww  w .  ja v  a 2  s.  c om
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.binzume.android.nicovideo.VideoInfo;
import net.binzume.android.nicovideo.util.HtmlUtil;

public class VideoRssParser {

  public static List<VideoInfo> parseList(CharSequence data) {

    // id thumb title
    Pattern ptnItem = Pattern.compile("<item[^>]*>(.*?)</item>", Pattern.DOTALL);
    Pattern ptnLink = Pattern.compile("<link[^>]*>(.*?)</link>");
    Pattern ptnThumb = Pattern.compile("<p\\s+class=\"nico-thumbnail\"><img alt=\"([^\"]*)\" src=\"([^\"]+)\"");
    Pattern ptnLength = Pattern.compile("<[\\w\\s]+class=\"nico-info-length\">([^<]+)");
    Pattern ptnDate = Pattern.compile("<[\\w\\s]+class=\"nico-info-date\">([^<]+)");
    Pattern ptnDesc = Pattern.compile("<[\\w\\s]+class=\"nico-description\">([^<]+)", Pattern.DOTALL);
    Pattern ptnCount = Pattern
        .compile("<strong class=\"nico-info-total-view\">([^>]+)</strong>.*?<strong class=\"nico-info-total-res\">([^>]+)</strong>.*?<strong class=\"nico-info-total-mylist\">([^>]+)</strong>");

    ArrayList<VideoInfo> list = new ArrayList<VideoInfo>();

    Matcher matcher = ptnItem.matcher(data);
    while (matcher.find()) {

      Matcher matcher2 = ptnLink.matcher(matcher.group(1));
      if (!matcher2.find())
        continue;

      String a[] = matcher2.group(1).split("/");
      final String vid = a[a.length - 1];

      matcher2 = ptnThumb.matcher(matcher.group(1));
      if (!matcher2.find())
        continue;

      VideoInfo v = new VideoInfo(vid, HtmlUtil.unescape(HtmlUtil.unescape(matcher2.group(1)))); // ???????????????????
      v.thumbnailUrl = HtmlUtil.unescape(matcher2.group(2));

      matcher2 = ptnDate.matcher(matcher.group(1));
      if (matcher2.find()) {
        v.firstRetrive = matcher2.group(1).replace("?", ":");
      }

      matcher2 = ptnLength.matcher(matcher.group(1));
      if (matcher2.find()) {
        v.lengthStr = matcher2.group(1);
      }

      matcher2 = ptnDesc.matcher(matcher.group(1));
      if (matcher2.find()) {
        v.description = matcher2.group(1);
      }

      matcher2 = ptnCount.matcher(matcher.group(1));
      if (matcher2.find()) {
        v.viewCount = Integer.parseInt(matcher2.group(1).replaceAll(",", ""));
        v.commentCount = Integer.parseInt(matcher2.group(2).replaceAll(",", ""));
        v.mylistCount = Integer.parseInt(matcher2.group(3).replaceAll(",", ""));
      }

      list.add(v);
    }

    return list;

  }

}




Java Source Code List

net.binzume.android.glvideoplayer.DeviceCameraPlane.java
net.binzume.android.glvideoplayer.FBOTexture.java
net.binzume.android.glvideoplayer.GLShaderProgram.java
net.binzume.android.glvideoplayer.GLVideoRenderer.java
net.binzume.android.glvideoplayer.MainActivity.java
net.binzume.android.glvideoplayer.MediaPlayerPlane.java
net.binzume.android.glvideoplayer.NicoCommentPlane.java
net.binzume.android.glvideoplayer.OESTexture.java
net.binzume.android.glvideoplayer.TextureFactory.java
net.binzume.android.glvideoplayer.Texture.java
net.binzume.android.glvideoplayer.VideoSurfaceView.java
net.binzume.android.nicoplayer.player.CommentController.java
net.binzume.android.nicoplayer.player.CommentLoadTask.java
net.binzume.android.nicoplayer.player.CommentSlot.java
net.binzume.android.nicovideo.ChannelCategoryInfo.java
net.binzume.android.nicovideo.ChannelInfo.java
net.binzume.android.nicovideo.Comment.java
net.binzume.android.nicovideo.MyList.java
net.binzume.android.nicovideo.NicoSession.java
net.binzume.android.nicovideo.ThreadInfo.java
net.binzume.android.nicovideo.VideoFileInfo.java
net.binzume.android.nicovideo.VideoInfo.java
net.binzume.android.nicovideo.util.HtmlUtil.java
net.binzume.android.nicovideo.util.HttpClient.java
net.binzume.android.nicovideo.webapi.ChannelAPI.java
net.binzume.android.nicovideo.webapi.CommentAPI.java
net.binzume.android.nicovideo.webapi.Constants.java
net.binzume.android.nicovideo.webapi.FriendListAPI.java
net.binzume.android.nicovideo.webapi.LoginAPI.java
net.binzume.android.nicovideo.webapi.MyListAPI.java
net.binzume.android.nicovideo.webapi.NotLoginException.java
net.binzume.android.nicovideo.webapi.PaymentRequiredException.java
net.binzume.android.nicovideo.webapi.VideoAPI.java
net.binzume.android.nicovideo.webapi.VideoRssParser.java
net.binzume.android.nicovideo.webapi.VideoSearchAPI.java
net.binzume.android.nicovideo.webapi.WatchItemAPI.java
net.binzume.android.nicovideo.webapi.WebApiException.java