From 3c3f542de59a7b522d8304cb0140dc43ae7362ae Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Wed, 28 Nov 2012 13:44:10 +0000 Subject: [PATCH] --- src/com/upc/pbe/upcnews/Directoris.java | 4 ++-- src/com/upc/pbe/upcnews/HTMLParser.java | 19 +++++++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/com/upc/pbe/upcnews/Directoris.java b/src/com/upc/pbe/upcnews/Directoris.java index e6175d0..cec9a84 100644 --- a/src/com/upc/pbe/upcnews/Directoris.java +++ b/src/com/upc/pbe/upcnews/Directoris.java @@ -27,8 +27,8 @@ public class Directoris extends Activity { title.setText("Server --> " + ((UpcApp) getApplication()).getUrl()); s = ((UpcApp) getApplication()).getDesc(); - HTMLParser pars = new HTMLParser((String) s); - ArrayList dirs = pars.parse(); + HTMLParser pars = new HTMLParser(); + ArrayList dirs = pars.parse(s); for (int i = 0; i < dirs.size(); i++) { diff --git a/src/com/upc/pbe/upcnews/HTMLParser.java b/src/com/upc/pbe/upcnews/HTMLParser.java index 1366b1e..c91a786 100644 --- a/src/com/upc/pbe/upcnews/HTMLParser.java +++ b/src/com/upc/pbe/upcnews/HTMLParser.java @@ -7,22 +7,33 @@ public class HTMLParser { String code; ArrayList directoris; - public HTMLParser(String code){ - this.code = code; + public HTMLParser(){ + this.code = null; directoris = new ArrayList(); } - public ArrayList parse(){ + public ArrayList parse(String code){ //Separem el codi en linies String[] split = code.split("\n"); //Mirem a cada linia si conté un href, i hi haurà un directori si conté el conjunt /" //Si hi ha un directori, tallem l'string per obtenir-ne el nom. for(int i = 0; i < split.length; i++){ if(split[i].contains("href") && split[i].contains("/\"")){ - directoris.add(split[i].substring((split[i].indexOf("href="))+4, (split[i].indexOf("/\"")))); + directoris.add(split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/\"")))); } } return directoris; } + public String findvideo(String name, String code){ + name = name+".m3u8"; + String[] split = code.split("\n"); + for(int i = 0; i< split.lenght; i++){ + if(split[i].contains(name)){ + + } + } + return null; + } + } -- libgit2 0.22.2