Commit 1288a4bb474cb8b0481ed0024484b00985bcca03
1 parent
94240569
Casi-casi\!\! me queda el ext-x-media (ahora lo termino) y falta conocer la func…
…ión de Marc para pillar listas recursivamente
Showing
2 changed files
with
33 additions
and
20 deletions
src/com/upc/pbe/upcnews/Directoris.java
@@ -126,7 +126,9 @@ public class Directoris extends Activity implements OnClickListener { | @@ -126,7 +126,9 @@ public class Directoris extends Activity implements OnClickListener { | ||
126 | Parser p = new Parser(); | 126 | Parser p = new Parser(); |
127 | try { | 127 | try { |
128 | ArrayList<ParentList> m3u8parsed = p.parseFile(m3u8); | 128 | ArrayList<ParentList> m3u8parsed = p.parseFile(m3u8); |
129 | - | 129 | + /* |
130 | + * Imanol: Recorda'm que et comenti una cosa sobre les excepcions! | ||
131 | + */ | ||
130 | } catch (ErrorException e) { | 132 | } catch (ErrorException e) { |
131 | e.printStackTrace(); | 133 | e.printStackTrace(); |
132 | } catch (WarningException e) { | 134 | } catch (WarningException e) { |
src/com/upc/pbe/upcnews/Parser.java
1 | package com.upc.pbe.upcnews; | 1 | package com.upc.pbe.upcnews; |
2 | 2 | ||
3 | +import java.net.MalformedURLException; | ||
3 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
4 | 5 | ||
5 | public class Parser | 6 | public class Parser |
@@ -35,7 +36,8 @@ public class Parser | @@ -35,7 +36,8 @@ public class Parser | ||
35 | { | 36 | { |
36 | parseLine(lines[i],lists); | 37 | parseLine(lines[i],lists); |
37 | } | 38 | } |
38 | - /* Esto contiene una lista de RECURSOS, | 39 | + /* |
40 | + * Esto contiene una lista de RECURSOS, | ||
39 | * que a su vez contiene una lista de CALIDADES. | 41 | * que a su vez contiene una lista de CALIDADES. |
40 | * Si no te gusta mis VERSOS, | 42 | * Si no te gusta mis VERSOS, |
41 | * te mando a la mierda sin SUTILIDADES. | 43 | * te mando a la mierda sin SUTILIDADES. |
@@ -109,6 +111,11 @@ public class Parser | @@ -109,6 +111,11 @@ public class Parser | ||
109 | throw new ErrorException("Invalid file, should contain Lists, " + | 111 | throw new ErrorException("Invalid file, should contain Lists, " + |
110 | "but segments were found."); | 112 | "but segments were found."); |
111 | } | 113 | } |
114 | + if(expectSegment) | ||
115 | + { | ||
116 | + throw new ErrorException("Expected segment URI, got a different" + | ||
117 | + "segment declaration"); | ||
118 | + } | ||
112 | String[] args = extTag[1].split(","); | 119 | String[] args = extTag[1].split(","); |
113 | int duration = Integer.parseInt(args[0]); | 120 | int duration = Integer.parseInt(args[0]); |
114 | if (duration > pls.getMaxDuration()) | 121 | if (duration > pls.getMaxDuration()) |
@@ -203,29 +210,33 @@ public class Parser | @@ -203,29 +210,33 @@ public class Parser | ||
203 | { | 210 | { |
204 | if(expectSegment) | 211 | if(expectSegment) |
205 | { | 212 | { |
206 | - | 213 | + expectSegment = false; |
214 | + try | ||
215 | + { | ||
216 | + pls.getSegments().get(currentSegment).setURL(line); | ||
217 | + } | ||
218 | + catch (MalformedURLException e) | ||
219 | + { | ||
220 | + throw new ErrorException(e.getMessage()); | ||
221 | + } | ||
222 | + currentSegment++; | ||
207 | } | 223 | } |
208 | else if(expectList) | 224 | else if(expectList) |
209 | { | 225 | { |
210 | - | 226 | + expectList = false; |
227 | + /* | ||
228 | + * Aquí hay que bajarse la playlist que hay en la url contenida en line | ||
229 | + * primero se baja el file, se pillan las lineas en un string enorme | ||
230 | + * y se crea una nueva instancia de parser (pa no mezclar los argumentos) | ||
231 | + * y se parsea con arte y gracia, luego se recogen los frutos | ||
232 | + * | ||
233 | + * TO-DO: Necesito la función de Marc | ||
234 | + */ | ||
211 | } | 235 | } |
212 | - | ||
213 | - /*if [[ $EXTINF -eq 1 ]]; then | ||
214 | - echo -n "SEGMENT $CURRENT_SEGMENT: \"$NAME\" - $DURATION seconds ($line)" | ||
215 | - EXTINF=0 | ||
216 | - if [[ $CURRENT_SEGMENT -eq $SEQUENCE_FIRST ]]; then | ||
217 | - echo " (first element)" | ||
218 | else | 236 | else |
219 | - echo "" | ||
220 | - fi; | ||
221 | - ((CURRENT_SEGMENT++)) | ||
222 | - elif [[ $EXTXSTREAM -eq 1 ]]; then | ||
223 | - echo "PLAYLIST: $line [PROGRAM-ID=$PROGRAMID,BANDWIDTH=$BANDWIDTH,RESOLUTION=$RESOLUTION,CODECS=$CODECS]" | ||
224 | - EXTXSTREAM=0 | ||
225 | - else | ||
226 | - echo "ERROR: Unexpected string \"$line\"" | ||
227 | - exit 1 | ||
228 | - */ | 237 | + { |
238 | + throw new ErrorException("ERROR: Unexpected string " + line); | ||
239 | + } | ||
229 | } | 240 | } |
230 | } | 241 | } |
231 | currentLine++; | 242 | currentLine++; |