Commit 3c3f542de59a7b522d8304cb0140dc43ae7362ae

Authored by Imanol-Mikel Barba Sabariego
1 parent 887effd3

--no commit message

src/com/upc/pbe/upcnews/Directoris.java
@@ -27,8 +27,8 @@ public class Directoris extends Activity { @@ -27,8 +27,8 @@ public class Directoris extends Activity {
27 title.setText("Server --> " + ((UpcApp) getApplication()).getUrl()); 27 title.setText("Server --> " + ((UpcApp) getApplication()).getUrl());
28 28
29 s = ((UpcApp) getApplication()).getDesc(); 29 s = ((UpcApp) getApplication()).getDesc();
30 - HTMLParser pars = new HTMLParser((String) s);  
31 - ArrayList<String> dirs = pars.parse(); 30 + HTMLParser pars = new HTMLParser();
  31 + ArrayList<String> dirs = pars.parse(s);
32 32
33 for (int i = 0; i < dirs.size(); i++) { 33 for (int i = 0; i < dirs.size(); i++) {
34 34
src/com/upc/pbe/upcnews/HTMLParser.java
@@ -7,22 +7,33 @@ public class HTMLParser { @@ -7,22 +7,33 @@ public class HTMLParser {
7 String code; 7 String code;
8 ArrayList<String> directoris; 8 ArrayList<String> directoris;
9 9
10 - public HTMLParser(String code){  
11 - this.code = code; 10 + public HTMLParser(){
  11 + this.code = null;
12 directoris = new ArrayList<String>(); 12 directoris = new ArrayList<String>();
13 } 13 }
14 14
15 - public ArrayList<String> parse(){ 15 + public ArrayList<String> parse(String code){
16 //Separem el codi en linies 16 //Separem el codi en linies
17 String[] split = code.split("\n"); 17 String[] split = code.split("\n");
18 //Mirem a cada linia si conté un href, i hi haurà un directori si conté el conjunt /" 18 //Mirem a cada linia si conté un href, i hi haurà un directori si conté el conjunt /"
19 //Si hi ha un directori, tallem l'string per obtenir-ne el nom. 19 //Si hi ha un directori, tallem l'string per obtenir-ne el nom.
20 for(int i = 0; i < split.length; i++){ 20 for(int i = 0; i < split.length; i++){
21 if(split[i].contains("href") && split[i].contains("/\"")){ 21 if(split[i].contains("href") && split[i].contains("/\"")){
22 - directoris.add(split[i].substring((split[i].indexOf("href="))+4, (split[i].indexOf("/\"")))); 22 + directoris.add(split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/\""))));
23 } 23 }
24 } 24 }
25 return directoris; 25 return directoris;
26 } 26 }
27 27
  28 + public String findvideo(String name, String code){
  29 + name = name+".m3u8";
  30 + String[] split = code.split("\n");
  31 + for(int i = 0; i< split.lenght; i++){
  32 + if(split[i].contains(name)){
  33 +
  34 + }
  35 + }
  36 + return null;
  37 + }
  38 +
28 } 39 }