From 22367466c9985ee737e1f8cdaad9470ed9608413 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Thu, 6 Dec 2012 16:55:48 +0000 Subject: [PATCH] --- src/com/upc/pbe/upcnews/List.java | 18 ++++++------------ src/com/upc/pbe/upcnews/ParentList.java | 12 ++++++++++++ src/com/upc/pbe/upcnews/Parser.java | 47 ++++++++++++++++++++++++++++++++++------------- 3 files changed, 52 insertions(+), 25 deletions(-) diff --git a/src/com/upc/pbe/upcnews/List.java b/src/com/upc/pbe/upcnews/List.java index dbaff23..3fad367 100644 --- a/src/com/upc/pbe/upcnews/List.java +++ b/src/com/upc/pbe/upcnews/List.java @@ -4,7 +4,7 @@ import java.util.ArrayList; public class List { - private boolean validated; + private int quality; private int sequenceFirst; private int maxDuration; @@ -13,20 +13,9 @@ public class List public List(int q) { quality = q; - validated = false; segments = new ArrayList(); } - public void setValidated(boolean val) - { - validated = val; - } - - public boolean getValidated() - { - return validated; - } - public void setSequence(int seq) { sequenceFirst = seq; @@ -52,6 +41,11 @@ public class List return quality; } + public void setQuality(int q) + { + quality = q; + } + public ArrayList getSegments() { return segments; diff --git a/src/com/upc/pbe/upcnews/ParentList.java b/src/com/upc/pbe/upcnews/ParentList.java index afc5b72..72ebb27 100644 --- a/src/com/upc/pbe/upcnews/ParentList.java +++ b/src/com/upc/pbe/upcnews/ParentList.java @@ -9,9 +9,11 @@ public class ParentList private String Type, Name; private boolean Default; //Estos 3 últimos son para los ext-x-media, los ext-x-stream lo IGNORAN private ArrayList lists; //per cada qualitat + private boolean validated; public ParentList(String ID) { + validated = false; this.ID = ID; currentQuality = 0; Type = ""; @@ -20,6 +22,16 @@ public class ParentList lists = new ArrayList(); //Lista de CALIDADES } + public void setValidated(boolean val) + { + validated = val; + } + + public boolean getValidated() + { + return validated; + } + public String getID() { return ID; diff --git a/src/com/upc/pbe/upcnews/Parser.java b/src/com/upc/pbe/upcnews/Parser.java index 49edd4c..8b43707 100644 --- a/src/com/upc/pbe/upcnews/Parser.java +++ b/src/com/upc/pbe/upcnews/Parser.java @@ -17,6 +17,15 @@ public class Parser private boolean expectList = false; private Descarrega download; + /* + * TO-DO: + * RECICLAR ZILLONES DE CÓDIGO REPETIDO + * LIMPIAR Y DOCUMENTAR + * DOWNLOAD REPEATED + * MEDIA'S NOT WORKING + */ + + public Parser() { currentLine = 0; @@ -42,7 +51,7 @@ public class Parser { if(lines[i].endsWith("\\")) { - lines[i] = lines[i].substring(0, lines[i].indexOf("\\")-1) + lines[++i]; + lines[++i] = lines[i-1].substring(0, lines[i-1].indexOf("\\")-1) + lines[i]; } try { @@ -133,12 +142,13 @@ public class Parser else { ParentList ppls = lists.get(currentList); //VIVA HONDURAS!!! - List pls = ppls.getLists().get(ppls.getCurrentQuality()); - if(!pls.getValidated()) + int b = ppls.getLists().size(); + List pls = ppls.getLists().get(ppls.getLists().size()-1); + if(!ppls.getValidated()) { if(line.equals(STARTWORD)) { - pls.setValidated(true); + ppls.setValidated(true); } else { @@ -228,7 +238,7 @@ public class Parser throw new ErrorException("Playlist on line " + currentLine + " has missing arguments"); } - if(!programID.equals(ppls.getID())) + if(!programID.equals(ppls.getID())) //Si el programID no coincide, crea o busca la parentlist que toca { if(ppls.getID().equals("")) { @@ -236,7 +246,7 @@ public class Parser * Este caso se da cuando no se ha creado ninguna lista. * Hay que sustituir la por defecto por una lista real. */ - lists.get(0).setID(programID); + lists.get(0).setID(programID); } else { @@ -244,18 +254,22 @@ public class Parser if(currentList == -1) { lists.add(new ParentList(programID)); - currentList = lists.size()+1; /* * ppls y pls se actualizan en la siguiente linea procesada */ + currentList = lists.size() + 1; } - else - { - ppls = lists.get(currentList); - ppls.getLists().add(new List(bandwidth)); - } + ppls = lists.get(currentList); + pls = ppls.getLists().get(ppls.getLists().size()-1); + } } + // Ahora crea la lista adecuada dentro de la parentlist + int a = ppls.getLists().size(); + if((ppls.getLists().size() == 1) && (pls.getQuality() == -1) && pls.getSegments().isEmpty()) + { + pls.setQuality(bandwidth); + } else { ppls.getLists().add(new List(bandwidth)); @@ -339,6 +353,9 @@ public class Parser * Este caso se da cuando no se ha creado ninguna lista. * Hay que sustituir la por defecto por una lista real. */ + ppls.setDefault(Default); + ppls.setName(Name); + ppls.setType(Type); lists.add(0,pl); } else @@ -403,7 +420,11 @@ public class Parser { expectList = false; Parser p = new Parser(); - p.parseFile(download.doInBackground(line)); + ArrayList newLists = p.parseFile(download.doInBackground(line)); + for(int i = 0; i < newLists.get(0).getLists().get(0).getSegments().size(); i++) + { + pls.getSegments().add(newLists.get(0).getLists().get(0).getSegments().get(i)); + } } else { -- libgit2 0.22.2