The branch, frodo has been updated
       via  262fd974e792cc38cea84f1e5fce05fb6214f054 (commit)
      from  0e0346812907cb540a09b5edb443ef503d8c1579 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=262fd974e792cc38cea84f1e5fce05fb6214f054

commit 262fd974e792cc38cea84f1e5fce05fb6214f054
Author: Martijn Kaijser <[email protected]>
Date:   Sat Dec 7 10:44:11 2013 +0100

    [plugin.video.mlslive] 1.0.4

diff --git a/plugin.video.mlslive/addon.xml b/plugin.video.mlslive/addon.xml
index db45ac9..8cfa62b 100644
--- a/plugin.video.mlslive/addon.xml
+++ b/plugin.video.mlslive/addon.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.mlslive" name="MLS Live" version="1.0.3" 
provider-name="Micah Galizia">
+<addon id="plugin.video.mlslive" name="MLS Live" version="1.0.4" 
provider-name="Micah Galizia">
   <requires>
     <import addon="xbmc.python"   version="2.1.0"/>
   </requires>
@@ -12,5 +12,9 @@
     <platform>all</platform>
     <language>en</language>
     <disclaimer>For bugs, requests or general questions visit the MLS Live 
thread on the XBMC forum.</disclaimer>
+    <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
+    <forum>http://forum.xbmc.org/showthread.php?tid=158142</forum>
+    <website>http://wiki.xbmc.org/index.php?title=Add-on:MLS_Live</website>
+    <source>https://github.com/micahg/plugin.video.mlslive</source>
   </extension>
 </addon>
diff --git a/plugin.video.mlslive/changelog.txt 
b/plugin.video.mlslive/changelog.txt
index 1001a41..3d411a6 100644
--- a/plugin.video.mlslive/changelog.txt
+++ b/plugin.video.mlslive/changelog.txt
@@ -1,3 +1,9 @@
+[B]Version 1.0.4[/B]
+
+- fix bug when there were no games played in a prior week
+- list weeks using the season bounds specified in the service configuration
+- improve speed of prior week menu (remove call to web request)
+
 [B]Version 1.0.3[/B]
 
 - fix crash with invalid home or away team abbreviations
diff --git a/plugin.video.mlslive/default.py b/plugin.video.mlslive/default.py
index 7b42411..cadcc71 100644
--- a/plugin.video.mlslive/default.py
+++ b/plugin.video.mlslive/default.py
@@ -116,9 +116,8 @@ def createWeekMenu(my_mls, values_string, final_only=True):
 
     # get the teams
     teams = my_mls.getTeams()
-    offset = int(values['week'])
 
-    for game in my_mls.getGames(offset):
+    for game in my_mls.getGames(values['week']):
 
         # if final == (live or upcoming) then don't use it 
         if final_only == (my_mls.isGameLive(game) or 
my_mls.isGameUpcoming(game)):
@@ -231,7 +230,7 @@ if my_mls == None:
 elif (len(sys.argv[2]) == 0):
     createMainMenu(my_mls)
 elif sys.argv[2] == '?id=live':
-    createWeekMenu(my_mls, "week=0", False)
+    createWeekMenu(my_mls, "week=" + my_mls.getCurrentWeekURI(), False)
 elif sys.argv[2] == '?id=replay':
     createWeeksMenu(my_mls)
 elif sys.argv[2] == '?id=channels':
diff --git a/plugin.video.mlslive/mlslive.py b/plugin.video.mlslive/mlslive.py
index d88ab17..2ace063 100644
--- a/plugin.video.mlslive/mlslive.py
+++ b/plugin.video.mlslive/mlslive.py
@@ -23,6 +23,7 @@ class MLSLive:
         """
         Initialize the MLSLive class.
         """
+        self.CED_CONFIG = 
'http://e2.cdnl3.neulion.com/mls/ced/2013/ced_config.xml'
         self.PUBLISH_POINT = 
'http://live.mlssoccer.com/mlsmdl/servlets/publishpoint'
         self.LOGIN_PAGE = 'https://live.mlssoccer.com/mlsmdl/secure/login'
         self.GAMES_PAGE_PREFIX = 
'http://mobile.cdn.mlssoccer.com/iphone/v5/prod/games_for_week_'
@@ -75,42 +76,67 @@ class MLSLive:
         
         return False
 
-    def getMonday(self, week_offset):
+
+    def getCurrentWeekURI(self):
+        """
+        Get the URI for the current games for the current week.
+        
+        @return a string containing the uri or None on error
+        """
+
+        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.jar))
+        try:
+            resp = opener.open(self.CED_CONFIG)
+        except:
+            print "Unable to get configuration"
+            return None
+
         today = datetime.date.today()
-        monday = today + datetime.timedelta(days=-today.weekday(), 
weeks=week_offset)
-        return monday
+
+        week = today + datetime.timedelta(days=-today.weekday())
+        return  self.GAMES_PAGE_PREFIX + week.strftime("%Y-%m-%d") + 
self.GAMES_PAGE_SUFFIX
 
 
     def getWeeks(self):
-        week_offset = 0
-        week_found = True
         weeks = {}
 
-        # work backwards through the weeks as long as there are games
-        while week_found:
-            games = self.getGames(week_offset)
-            if len(games) > 0:
-                weeks[week_offset] = self.getMonday(week_offset).strftime("%B 
%d, %Y")
-                week_offset = week_offset - 1
-            else:
-                week_found = False
+        opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.jar))
+        try:
+            resp = opener.open(self.CED_CONFIG)
+        except:
+            print "Unable to get configuration"
+            return False
 
-        # return the weeks
-        return weeks
+        resp_xml = resp.read()
+        dom = xml.dom.minidom.parseString(resp_xml)
 
+        result_node = dom.getElementsByTagName('result')[0]
+        first_day = 
result_node.getElementsByTagName('firstDayOfCurSeason')[0].firstChild.nodeValue.split('T')[0]
+        last_day = 
result_node.getElementsByTagName('lastDayOfCurSeason')[0].firstChild.nodeValue.split('T')[0]
+
+        # get first day of the season. use the time becasuse datetime.datetime
+        # doesn't work reliably without crashing
+        time_t = time.strptime(first_day, "%Y-%m-%d")
+        date_d = datetime.datetime.fromtimestamp(time.mktime(time_t))
+
+        # get the last day of the season
+        time_t = time.strptime(last_day, "%Y-%m-%d")
+        last_d = datetime.datetime.fromtimestamp(time.mktime(time_t))
 
-    def getGamesURI(self, week_offset): 
-        monday = self.getMonday(week_offset)
-        monday_str = monday.strftime("%Y-%m-%d")
-        return self.GAMES_PAGE_PREFIX + monday_str + self.GAMES_PAGE_SUFFIX
+        while date_d < datetime.datetime.today() and date_d < last_d:
+            week_str = self.GAMES_PAGE_PREFIX + date_d.strftime("%Y-%m-%d") + 
self.GAMES_PAGE_SUFFIX
+            weeks[week_str] = date_d.strftime("%B %d, %Y")
+            date_d = date_d + datetime.timedelta(weeks=1)
+
+        # return the weeks
+        return weeks
 
 
-    def getGames(self, week_offset):
+    def getGames(self, games_url):
         """
         Get the list of games.
         
-        @param week_offset the number of weeks to offset from the previous
-                           monday.
+        @param games_url the url of the weeks games
         @return json game data
 
         The list returned will contain dictionaries, each of which containing
@@ -128,7 +154,6 @@ class MLSLive:
         - gameStatus ("FINAL","UPCOMING", "LIVE - 50'"
         - visitorTeamName (pretty vistor team name)
         """
-        games_url = self.getGamesURI(week_offset)
         opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.jar))
         try:
             resp = opener.open(games_url)
diff --git a/plugin.video.mlslive/resources/language/English/strings.xml 
b/plugin.video.mlslive/resources/language/English/strings.xml
index 05afd93..11b4b25 100644
--- a/plugin.video.mlslive/resources/language/English/strings.xml
+++ b/plugin.video.mlslive/resources/language/English/strings.xml
@@ -14,4 +14,6 @@
   <string id="30010">Live Games</string>
   <string id="30011">Completed Games</string>
   <string id="30012">Video Channels</string>
+  <string id="30013">User Name</string>
+  <string id="30014">Password</string>
 </strings>
\ No newline at end of file
diff --git a/plugin.video.mlslive/resources/settings.xml 
b/plugin.video.mlslive/resources/settings.xml
index 8212dc1..6676231 100644
--- a/plugin.video.mlslive/resources/settings.xml
+++ b/plugin.video.mlslive/resources/settings.xml
@@ -1,4 +1,4 @@
 <settings>
-   <setting id="username" type="text" label="User Name"/>
-   <setting id="password" type="text" label="Password" option="hidden"/>
+   <setting id="username" type="text" label="30013"/>
+   <setting id="password" type="text" label="30014" option="hidden"/>
 </settings>
diff --git a/plugin.video.mlslive/test.py b/plugin.video.mlslive/test.py
index 865766a..3c8c5f5 100755
--- a/plugin.video.mlslive/test.py
+++ b/plugin.video.mlslive/test.py
@@ -74,7 +74,7 @@ if options.game != None:
 
     sys.exit(0)
 
-games = my_mls.getGames(options.offset)
+games = my_mls.getGames(my_mls.getCurrentWeekURI())
 teams = my_mls.getTeams()
 
 for game in games:

-----------------------------------------------------------------------

Summary of changes:
 plugin.video.mlslive/addon.xml                     |    6 ++-
 plugin.video.mlslive/changelog.txt                 |    6 ++
 plugin.video.mlslive/default.py                    |    5 +-
 plugin.video.mlslive/mlslive.py                    |   71 +++++++++++++------
 .../resources/language/English/strings.xml         |    2 +
 plugin.video.mlslive/resources/settings.xml        |    4 +-
 plugin.video.mlslive/test.py                       |    2 +-
 7 files changed, 66 insertions(+), 30 deletions(-)


hooks/post-receive
-- 
Plugins

------------------------------------------------------------------------------
Sponsored by Intel(R) XDK 
Develop, test and display web and hybrid apps with a single code base.
Download it for free now!
http://pubads.g.doubleclick.net/gampad/clk?id=111408631&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to