Author: jerome
Date: 2009-04-08 14:44:39 +0200 (Wed, 08 Apr 2009)
New Revision: 4414
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
Log:
* Getting righ day on the program page.
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
===================================================================
---
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
2009-04-08 11:46:19 UTC (rev 4413)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
2009-04-08 12:44:39 UTC (rev 4414)
@@ -170,12 +170,90 @@
return null;
}
- String page = HTMLUtils.getPage(this.url,
this.channelsMap.get(channel));
+ String page =
this.getPageForCurrentDay(HTMLUtils.getPage(this.url,
this.channelsMap.get(channel)));
+ if(page != null)
+ {
+ programs = this.parseProgramOfTheDay(page);
+ }
+
+ else
+ {
+ this.triggerError();
+ }
+
return programs;
}
+
+ /**
+ * Return the page for this channel and for the current day.
+ * @return
+ */
+ private String getPageForCurrentDay(String dayPage)
+ {
+ dayPage = dayPage.substring(dayPage.indexOf("<A HREF=\""));
+ String[] split = dayPage.split("<A HREF=\"");
+ Vector<String> spl = new Vector<String>();
+
+ int currentNDay =
Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
+
+ //Getting right page.
+ for(String str : split)
+ {
+ if((!str.contains("Film</A>")) &&
(!str.contains(";rie</A>")) && (!str.contains("Emission</A")) &&
(!str.contains("/Musique</A>")))
+ {
+ if(str.contains("</A>"))
+ {
+ str = str.substring(0,
str.indexOf("</A>"));
+ }
+
+ spl.add(str);
+ }
+ }
+
+ //Getting web link.
+ for (String str : spl)
+ {
+ if(str.length() > 0)
+ {
+ String day = str.substring(str.indexOf("\">") +
2, str.indexOf(" "));
+ String dMonth = str.substring(str.indexOf(day)
+ day.length() + 1);
+ dMonth = dMonth.substring(0, dMonth.indexOf("
"));
+
+ if(Integer.valueOf(dMonth).intValue() ==
currentNDay)
+ {
+ try
+ {
+ return
HTMLUtils.getPage(this.url, str.substring(0, str.indexOf("\">")));
+ }
+ catch(StringIndexOutOfBoundsException
error)
+ {
+ ;
+ }
+ }
+ }
+ }
+
+ return null;
+ }
+
+
+ /**
+ * Parse selected program page.
+ * @param page
+ * @return
+ */
+ private Vector<Program> parseProgramOfTheDay(String page)
+ {
+ Vector<Program> def = new Vector<Program>();
+
+ System.out.println(page);
+ return def;
+ }
+
+
/*********************************************************************/
/*********** User functions *********************/
------------------------------------------------------------------------------
This SF.net email is sponsored by:
High Quality Requirements in a Collaborative Environment.
Download a free trial of Rational Requirements Composer Now!
http://p.sf.net/sfu/www-ibm-com
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn