Commit 6bd1ad5f891b8da4f4a79590def7c341384aa689
1 parent
e18b5808
--no commit message
Showing
1 changed file
with
14 additions
and
1 deletions
src/com/upc/pbe/upcnews/HTMLParser.java
@@ -19,13 +19,15 @@ public class HTMLParser { | @@ -19,13 +19,15 @@ public class HTMLParser { | ||
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("/index.html\"")){ | 21 | if(split[i].contains("href") && split[i].contains("/index.html\"")){ |
22 | - directoris.add(split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/index.html\"")))); | 22 | + directoris.add(processar(split[i].substring((split[i].indexOf("href="))+6, (split[i].indexOf("/index.html\""))))); |
23 | } | 23 | } |
24 | } | 24 | } |
25 | return directoris; | 25 | return directoris; |
26 | } | 26 | } |
27 | 27 | ||
28 | public String findvideo(String code, String direccio){ | 28 | public String findvideo(String code, String direccio){ |
29 | + //Donada la direcció del directori i el html del mateix, troba l'arxiu .m3u8 i retorna | ||
30 | + //la url directe. | ||
29 | String[] split = code.split("\n"); | 31 | String[] split = code.split("\n"); |
30 | for(int i = 0; i < split.length; i++){ | 32 | for(int i = 0; i < split.length; i++){ |
31 | if(split[i].contains(".m3u8") && !split[i].contains("._")){ | 33 | if(split[i].contains(".m3u8") && !split[i].contains("._")){ |
@@ -35,4 +37,15 @@ public class HTMLParser { | @@ -35,4 +37,15 @@ public class HTMLParser { | ||
35 | } | 37 | } |
36 | return "No s'ha trobat"; | 38 | return "No s'ha trobat"; |
37 | } | 39 | } |
40 | + | ||
41 | + public String processar(String text){ | ||
42 | + //Elimina els caràcters no desitjats dels noms dels directoris. | ||
43 | + char[] c = text.toCharArray(); | ||
44 | + for (int i=0; i<c.length; i++){ | ||
45 | + if(c[i]=='-'){ | ||
46 | + c[i]=' '; | ||
47 | + } | ||
48 | + } | ||
49 | + return new String(c); | ||
50 | + } | ||
38 | } | 51 | } |