Advertisement
jar3817

PF youtube parse

May 22nd, 2015
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. if (parts[i].startsWith("http://www.youtube.com") ||
  2.         parts[i].startsWith("http://youtu.be") ||
  3.         parts[i].startsWith("https://www.youtube.com"))
  4. {
  5.     uri = new URI(parts[i]);
  6.     Parser html = new Parser(uri.toString());
  7.     NodeList nodes = html.parse(new TagNameFilter("title"));
  8.     if (nodes.size() > 0)
  9.     {
  10.         String title = nodes.elementAt(0).toPlainTextString().trim().split("\n")[0];
  11.         title = com.tecnick.htmlutils.htmlentities.HTMLEntities.unhtmlentities(title);
  12.         title = com.tecnick.htmlutils.htmlentities.HTMLEntities.unhtmlQuotes(title);
  13.         title = com.tecnick.htmlutils.htmlentities.HTMLEntities.htmlAngleBrackets(title);
  14.         title = com.tecnick.htmlutils.htmlentities.HTMLEntities.unhtmlAmpersand(title);
  15.         sendMessage("Video Title: " + title, message.getReplyDestination());
  16.     }
  17.     break;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement