Commit 3c3f542de59a7b522d8304cb0140dc43ae7362ae
1 parent
887effd3
--no commit message
Showing
2 changed files
with
17 additions
and
6 deletions
src/com/upc/pbe/upcnews/Directoris.java
... | ... | @@ -27,8 +27,8 @@ public class Directoris extends Activity { |
27 | 27 | title.setText("Server --> " + ((UpcApp) getApplication()).getUrl()); |
28 | 28 | |
29 | 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 | 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 | 7 | String code; |
8 | 8 | ArrayList<String> directoris; |
9 | 9 | |
10 | - public HTMLParser(String code){ | |
11 | - this.code = code; | |
10 | + public HTMLParser(){ | |
11 | + this.code = null; | |
12 | 12 | directoris = new ArrayList<String>(); |
13 | 13 | } |
14 | 14 | |
15 | - public ArrayList<String> parse(){ | |
15 | + public ArrayList<String> parse(String code){ | |
16 | 16 | //Separem el codi en linies |
17 | 17 | String[] split = code.split("\n"); |
18 | 18 | //Mirem a cada linia si conté un href, i hi haurà un directori si conté el conjunt /" |
19 | 19 | //Si hi ha un directori, tallem l'string per obtenir-ne el nom. |
20 | 20 | for(int i = 0; i < split.length; i++){ |
21 | 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 | 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 | } | ... | ... |