Author: jerome
Date: 2009-04-08 13:41:25 +0200 (Wed, 08 Apr 2009)
New Revision: 4411
Modified:
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
Log:
* Dynamic getter for channel url ( handle link changes from website ).
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:36:06 UTC (rev 4410)
+++
software_suite_v2/software/gadgets/tuxdroid-gadget-programsTV/trunk/tuxdroid-gadget-programsTV/src/com/kysoh/tvPrograms/programs/SimplePrograms.java
2009-04-08 11:41:25 UTC (rev 4411)
@@ -46,15 +46,14 @@
private static final int AFTERNOON = 1;
private static final int EVENING = 2;
- public static final String BEFR = "scripts/gridbefr.htm";
- public static final String BEDU = "scripts/gridbedu.htm";
- public static final String FR = "scripts/gridfrall.htm";
- public static final String SP = "scripts/gridsp.htm";
- public static final String Nl = "scripts/gridnl.htm";
- public static final String UK = "scripts/griduk.htm";
- public static final String GE = "scripts/gridge.htm";
- public static final String LU = "scripts/gridlu.htm";
- public static final String IT = "scripts/gridit.htm";
+ public static final String BEFR = "All Belgian French</a>";
+ public static final String BEDU = "All Belgian Dutch</a>";
+ public static final String FR = "France<p><a href";
+ public static final String UK = "U.K.<p><a href";
+ public static final String GE = "Germany<p><a href";
+ public static final String Nl = "The Netherlands<p><a href";
+ public static final String SP = "Spain<p><a href";
+
public static final String US = null;
//The complete program.
@@ -75,9 +74,19 @@
String availables =
HTMLUtils.getPage("http://www.eurotv.com/scripts/eutvprog.cfm", "");
availables =
availables.substring(availables.indexOf("Alphabetical list </A> of all
channels") +
"Alphabetical
list </A> of all channels".length());
+
channelsMap = this.getChannelsLinkByCountry(country,
availables);
- this.triggerLoaded();
+ program = this.parseProgramsForChannel(this.channel);
+
+ if(program.size() > 0)
+ {
+ this.triggerLoaded();
+ }
+ else
+ {
+ this.triggerError();
+ }
}
else
{
@@ -118,9 +127,31 @@
*/
private Hashtable<String, String> getChannelsLinkByCountry(final String
country, String page)
{
- Hashtable hash = new Hashtable<String, String>();
- System.out.println(page);
+ Hashtable<String, String> hash = new Hashtable<String,
String>();
+ String tmp = page.substring(page.indexOf(country) +
country.length());
+
+ String[] split = tmp.split("</a>");
+ Vector<String> spl = new Vector<String>();
+ for(String str : split)
+ {
+ if(!str.contains("<p>"))
+ {
+ spl.add(str);
+ }
+ else
+ {
+ break;
+ }
+ }
+
+ for(String str : spl)
+ {
+ String chan = str.substring(str.indexOf("\">") + 2);
+ String link = str.substring(str.indexOf("HREF=\"") +
"HREF=\"".length(), str.indexOf("\">") - 2);
+
+ hash.put(chan, link);
+ }
return hash;
}
@@ -129,9 +160,19 @@
* Parse retreived page.
* @param text
*/
- private void parsePage(String text)
+ private Vector<Program> parseProgramsForChannel(String channel)
{
- System.out.println(text);
+ Vector<Program> programs = new Vector<Program>();
+
+ if((this.channelsMap.size() <= 0) ||
(!this.channelsMap.containsKey(channel)))
+ {
+ this.triggerError();
+ return null;
+ }
+
+ String page = HTMLUtils.getPage(this.url, channel);
+
+ return programs;
}
------------------------------------------------------------------------------
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