The branch, eden-pre has been updated
       via  464c86272d555ecee4f1131967d75824e6f967e0 (commit)
      from  ec206c06076724c3c0c12c450f835652f854be65 (commit)

- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=464c86272d555ecee4f1131967d75824e6f967e0

commit 464c86272d555ecee4f1131967d75824e6f967e0
Author: amet <[email protected]>
Date:   Sat Jan 28 00:55:01 2012 +0400

    [script.tvguide] -v 1.2.1
    
    - Added option to load channel icons from a folder when using XMLTV as 
source
      Logos must be png's and named <channel name>.png
    - Added support for loading XMLTV files from network shares
      Add your shares in XBMC's File manager
    - Fixed a number of small annoying bugs

diff --git a/script.tvguide/addon.py b/script.tvguide/addon.py
index fef0d87..2fb3a29 100644
--- a/script.tvguide/addon.py
+++ b/script.tvguide/addon.py
@@ -38,6 +38,7 @@ try:
     SETTINGS = {
         'cache.path' : xbmc.translatePath(ADDON.getAddonInfo('profile')),
         'xmltv.file' : ADDON.getSetting('xmltv.file'),
+        'xmltv.logo.folder' : ADDON.getSetting('xmltv.logo.folder'),
         'youseetv.category' : ADDON.getSetting('youseetv.category'),
         'youseewebtv.playback' : ADDON.getSetting('youseewebtv.playback'),
         'danishlivetv.playback' : ADDON.getSetting('danishlivetv.playback'),
diff --git a/script.tvguide/addon.xml b/script.tvguide/addon.xml
index 924a0b0..cd4f25e 100644
--- a/script.tvguide/addon.xml
+++ b/script.tvguide/addon.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.tvguide" name="TV Guide" version="1.2.0" 
provider-name="twinther [[email protected]]">
+<addon id="script.tvguide" name="TV Guide" version="1.2.1" 
provider-name="twinther [[email protected]]">
     <requires>
         <import addon="xbmc.python" version="2.0"/>
         <import addon="script.module.simplejson" version="2.0.10"/>
diff --git a/script.tvguide/changelog.txt b/script.tvguide/changelog.txt
index 00fb1c6..749c541 100644
--- a/script.tvguide/changelog.txt
+++ b/script.tvguide/changelog.txt
@@ -1,3 +1,10 @@
+[B]Version 1.2.1 - 2012-01-27[/B]
+- Added option to load channel icons from a folder when using XMLTV as source
+  Logos must be png's and named <channel name>.png
+- Added support for loading XMLTV files from network shares
+  Add your shares in XBMC's File manager
+- Fixed a number of small annoying bugs
+
 [B]Version 1.2.0 - 2012-01-19[/B]
 - Fixed a rendering problem when the source contains more than one day of 
programs
 - Improved handling of programs in the future
diff --git a/script.tvguide/gui.py b/script.tvguide/gui.py
index b3432f3..e656bbc 100644
--- a/script.tvguide/gui.py
+++ b/script.tvguide/gui.py
@@ -63,6 +63,7 @@ class TVGuide(xbmcgui.WindowXML):
     C_MAIN_TIME = 4021
     C_MAIN_DESCRIPTION = 4022
     C_MAIN_IMAGE = 4023
+    C_MAIN_LOGO = 4024
     C_MAIN_LOADING = 4200
     C_MAIN_LOADING_PROGRESS = 4201
     C_MAIN_BACKGROUND = 4600
@@ -79,7 +80,7 @@ class TVGuide(xbmcgui.WindowXML):
         super(TVGuide, self).__init__()
         self.source = source
         self.notification = notification
-        self.controlToProgramMap = {}
+        self.controlToProgramMap = dict()
         self.focusX = 0
         self.page = 0
 
@@ -96,7 +97,7 @@ class TVGuide(xbmcgui.WindowXML):
 
     def onAction(self, action):
         try:
-            if action.getId() in [ACTION_PARENT_DIR, ACTION_PREVIOUS_MENU, 
KEY_NAV_BACK]:
+            if action.getId() in [ACTION_PARENT_DIR, KEY_NAV_BACK]:
                 self.close()
                 return
 
@@ -127,9 +128,10 @@ class TVGuide(xbmcgui.WindowXML):
                 control = self._pageUp()
             elif action.getId() == ACTION_PAGE_DOWN:
                 control = self._pageDown()
-            elif action.getId() == KEY_CONTEXT_MENU and controlInFocus is not 
None:
-                program = self.controlToProgramMap[controlInFocus.getId()]
-                self._showContextMenu(program, controlInFocus)
+            elif action.getId() in [KEY_CONTEXT_MENU, ACTION_PREVIOUS_MENU] 
and controlInFocus is not None:
+                program = self._getProgramFromControlId(controlInFocus.getId())
+                if program is not None:
+                    self._showContextMenu(program, controlInFocus)
 
             if control is not None:
                 self.setFocus(control)
@@ -140,7 +142,10 @@ class TVGuide(xbmcgui.WindowXML):
 
     def onClick(self, controlId):
         try:
-            program = self.controlToProgramMap[controlId]
+            program = self._getProgramFromControlId(controlId)
+            if program is None:
+                return
+
             if self.source.isPlayable(program.channel):
                 self.source.play(program.channel)
             else:
@@ -151,7 +156,7 @@ class TVGuide(xbmcgui.WindowXML):
     def _showContextMenu(self, program, control):
         isNotificationRequiredForProgram = 
self.notification.isNotificationRequiredForProgram(program)
 
-        d = PopupMenu(self.source, program, not 
isNotificationRequiredForProgram, self.source.hasChannelIcons())
+        d = PopupMenu(self.source, program, not 
isNotificationRequiredForProgram)
         d.doModal()
         buttonClicked = d.buttonClicked
         del d
@@ -184,16 +189,21 @@ class TVGuide(xbmcgui.WindowXML):
             except TypeError:
                 return
 
+            program = self._getProgramFromControlId(controlId)
+            if program is None:
+                return
+
             (left, top) = controlInFocus.getPosition()
             if left > self.focusX or left + controlInFocus.getWidth() < 
self.focusX:
                 self.focusX = left
 
-            program = self.controlToProgramMap[controlId]
-
             self.getControl(self.C_MAIN_TITLE).setLabel('[B]%s[/B]' % 
program.title)
             self.getControl(self.C_MAIN_TIME).setLabel('[B]%s - %s[/B]' % 
(program.startDate.strftime('%H:%M'), program.endDate.strftime('%H:%M')))
             
self.getControl(self.C_MAIN_DESCRIPTION).setText(program.description)
 
+            if program.channel.logo is not None:
+                
self.getControl(self.C_MAIN_LOGO).setImage(program.channel.logo)
+
             if program.imageSmall is not None:
                 self.getControl(self.C_MAIN_IMAGE).setImage(program.imageSmall)
 
@@ -264,7 +274,7 @@ class TVGuide(xbmcgui.WindowXML):
         self.controlToProgramMap.clear()
 
         progressControl = self.getControl(self.C_MAIN_LOADING_PROGRESS)
-        progressControl.setPercent(1)
+        progressControl.setPercent(0.1)
         self.getControl(self.C_MAIN_LOADING).setVisible(True)
 
         # move timebar to current time
@@ -273,9 +283,6 @@ class TVGuide(xbmcgui.WindowXML):
         (x, y) = c.getPosition()
         c.setPosition(self._secondsToXposition(timeDelta.seconds), y)
 
-        self.getControl(4500).setVisible(not(self.source.hasChannelIcons()))
-        self.getControl(4501).setVisible(self.source.hasChannelIcons())
-
         # date and time row
         self.getControl(4000).setLabel(self.viewStartDate.strftime('%a, %d. 
%b'))
         for col in range(1, 5):
@@ -286,9 +293,8 @@ class TVGuide(xbmcgui.WindowXML):
         try:
             channels = self.source.getChannelList()
         except source.SourceException as ex:
-            print ex
             self.onEPGLoadError()
-            return
+            return page
 
         totalPages = len(channels) / CHANNELS_PER_PAGE
         if not len(channels) % CHANNELS_PER_PAGE:
@@ -319,13 +325,12 @@ class TVGuide(xbmcgui.WindowXML):
                     if programList:
                         programs += programList
             except source.SourceException as ex:
-                print ex
                 self.onEPGLoadError()
-                return
+                return page
 
             if programs is None:
                 self.onEPGLoadError()
-                return
+                return page
 
             for program in programs:
                 if program.endDate <= self.viewStartDate or program.startDate 
>= viewEndDate:
@@ -380,7 +385,7 @@ class TVGuide(xbmcgui.WindowXML):
             self.getFocus()
         except TypeError:
             if len(self.controlToProgramMap.keys()) > 0 and autoChangeFocus:
-                
self.setFocus(self.getControl(self.controlToProgramMap.keys()[0]))
+                self.setFocusId(self.controlToProgramMap.keys()[0])
 
         self.getControl(self.C_MAIN_LOADING).setVisible(False)
 
@@ -392,10 +397,11 @@ class TVGuide(xbmcgui.WindowXML):
                 self.getControl(4010 + idx).setLabel('')
             else:
                 channel = channelsToShow[idx]
-                if self.source.hasChannelIcons() and channel.logo is not None:
+                self.getControl(4010 + idx).setLabel(channel.title)
+                if channel.logo is not None:
                     self.getControl(4110 + idx).setImage(channel.logo)
                 else:
-                    self.getControl(4010 + idx).setLabel(channel.title)
+                    self.getControl(4110 + idx).setImage('')
 
         return page
 
@@ -476,6 +482,10 @@ class TVGuide(xbmcgui.WindowXML):
 
         return nearestControl
 
+    def _getProgramFromControlId(self, controlId):
+        if self.controlToProgramMap.has_key(controlId):
+            return self.controlToProgramMap[controlId]
+        return None
 
 
 class PopupMenu(xbmcgui.WindowXMLDialog):
@@ -486,10 +496,10 @@ class PopupMenu(xbmcgui.WindowXMLDialog):
     C_POPUP_CHANNEL_TITLE = 4101
     C_POPUP_PROGRAM_TITLE = 4102
 
-    def __new__(cls, source, program, showRemind, hasChannelIcon):
+    def __new__(cls, source, program, showRemind):
         return super(PopupMenu, cls).__new__(cls, 'script-tvguide-menu.xml', 
ADDON.getAddonInfo('path'))
 
-    def __init__(self, source, program, showRemind, hasChannelIcon):
+    def __init__(self, source, program, showRemind):
         """
 
         @type source: source.Source
@@ -502,7 +512,6 @@ class PopupMenu(xbmcgui.WindowXMLDialog):
         self.program = program
         self.showRemind = showRemind
         self.buttonClicked = None
-        self.hasChannelIcon = hasChannelIcon
 
     def onInit(self):
         try:
@@ -520,7 +529,7 @@ class PopupMenu(xbmcgui.WindowXMLDialog):
                 chooseStrmControl = self.getControl(self.C_POPUP_CHOOSE_STRM)
                 chooseStrmControl.setLabel(strings(REMOVE_STRM_FILE))
 
-            if self.hasChannelIcon:
+            if self.program.channel.logo is not None:
                 channelLogoControl.setImage(self.program.channel.logo)
                 channelTitleControl.setVisible(False)
             else:
diff --git a/script.tvguide/resources/language/Danish/strings.xml 
b/script.tvguide/resources/language/Danish/strings.xml
index dc0acda..2c7372a 100644
--- a/script.tvguide/resources/language/Danish/strings.xml
+++ b/script.tvguide/resources/language/Danish/strings.xml
@@ -19,6 +19,7 @@
     <string id="30113">Afspil kanaler via Danish Live TV addon</string>
     <string id="30114">Opstart</string>
     <string id="30115">- slet midlertidige filer først</string>
+    <string id="30116">Søg efter kanal logoer i</string>
 
     <string id="30150">Ups, det er pinligt!</string>
     <string id="30151">Det var ikke muligt at indlæse program data,</string>
diff --git a/script.tvguide/resources/language/English/strings.xml 
b/script.tvguide/resources/language/English/strings.xml
index 6ee1ba6..a1184f0 100644
--- a/script.tvguide/resources/language/English/strings.xml
+++ b/script.tvguide/resources/language/English/strings.xml
@@ -19,6 +19,7 @@
     <string id="30113">Play channels using the Danish Live TV addon</string>
     <string id="30114">Startup</string>
     <string id="30115">- clear cache first</string>
+    <string id="30116">Search for channel logos in</string>
 
     <string id="30150">Oops, sorry about that!</string>
     <string id="30151">It was not possible to load program data,</string>
diff --git a/script.tvguide/resources/settings.xml 
b/script.tvguide/resources/settings.xml
index 146ad15..0f6f0ea 100644
--- a/script.tvguide/resources/settings.xml
+++ b/script.tvguide/resources/settings.xml
@@ -15,7 +15,7 @@
         <setting id="program.background.enabled" label="30107" type="bool" 
default="true" visible="eq(-4,0)"/>
 
         <setting id="xmltv.file" label="30103" type="file" visible="eq(-5,3)" 
/>
-
+        <setting id="xmltv.logo.folder" label="30116" type="folder" 
visible="eq(-6,3)"/>
 
         <setting type="sep" />
         <setting type="lsep" label="30109" />
diff --git 
a/script.tvguide/resources/skins/Default/720p/script-tvguide-main.xml 
b/script.tvguide/resources/skins/Default/720p/script-tvguide-main.xml
index 806aa54..89f0e2b 100644
--- a/script.tvguide/resources/skins/Default/720p/script-tvguide-main.xml
+++ b/script.tvguide/resources/skins/Default/720p/script-tvguide-main.xml
@@ -92,14 +92,15 @@
                 </control>
             </control>
 
-            <!-- Channels text column -->
-            <control type="group" id="4500">
+            <!-- Channels column -->
+            <control type="group">
                 <posx>0</posx>
                 <posy>60</posy>
                 <width>180</width>
                 <height>400</height>
                 <visible>true</visible>
 
+                <!-- text labels -->
                 <control type="label" id="4010">
                     <description>1st channel</description>
                     <posx>0</posx>
@@ -109,6 +110,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4110),)</visible>
                 </control>
                 <control type="label" id="4011">
                     <description>2nd channel</description>
@@ -119,6 +121,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4111),)</visible>
                 </control>
                 <control type="label" id="4012">
                     <description>3rd channel</description>
@@ -129,6 +132,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4112),)</visible>
                 </control>
                 <control type="label" id="4013">
                     <description>4th channel</description>
@@ -139,6 +143,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4113),)</visible>
                 </control>
                 <control type="label" id="4014">
                     <description>5th channel</description>
@@ -149,6 +154,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4114),)</visible>
                 </control>
                 <control type="label" id="4015">
                     <description>6th channel</description>
@@ -159,6 +165,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4115),)</visible>
                 </control>
                 <control type="label" id="4016">
                     <description>7th channel</description>
@@ -169,6 +176,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4116),)</visible>
                 </control>
                 <control type="label" id="4017">
                     <description>8th channel</description>
@@ -179,6 +187,7 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4117),)</visible>
                 </control>
                 <control type="label" id="4018">
                     <description>9th channel</description>
@@ -189,17 +198,10 @@
                     <textcolor>ffffffff</textcolor>
                     <font>font13</font>
                     <align>center</align>
+                    <visible>StringCompare(Control.GetLabel(4118),)</visible>
                 </control>
-            </control><!-- end group -->
-
-            <!-- Channels icon column -->
-            <control type="group" id="4501">
-                <posx>0</posx>
-                <posy>60</posy>
-                <width>180</width>
-                <height>400</height>
-                <visible>true</visible>
 
+                <!-- logo images -->
                 <control type="image" id="4110">
                     <description>1st channel</description>
                     <posx>10</posx>
@@ -208,6 +210,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4110),)</visible>
                 </control>
                 <control type="image" id="4111">
                     <description>2nd channel</description>
@@ -217,6 +220,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4111),)</visible>
                 </control>
                 <control type="image" id="4112">
                     <description>3rd channel</description>
@@ -226,6 +230,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4112),)</visible>
                 </control>
                 <control type="image" id="4113">
                     <description>4th channel</description>
@@ -235,6 +240,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4113),)</visible>
                 </control>
                 <control type="image" id="4114">
                     <description>5th channel</description>
@@ -244,6 +250,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4114),)</visible>
                 </control>
                 <control type="image" id="4115">
                     <description>6th channel</description>
@@ -253,6 +260,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4115),)</visible>
                 </control>
                 <control type="image" id="4116">
                     <description>7th channel</description>
@@ -262,6 +270,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4116),)</visible>
                 </control>
                 <control type="image" id="4117">
                     <description>8th channel</description>
@@ -271,6 +280,7 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4117),)</visible>
                 </control>
                 <control type="image" id="4118">
                     <description>9th channel</description>
@@ -280,18 +290,10 @@
                     <height>45</height>
                     <aspectratio>keep</aspectratio>
                     <fadetime>500</fadetime>
+                    <visible>!StringCompare(Control.GetLabel(4118),)</visible>
                 </control>
-            </control><!-- end group -->
+            </control>
 
-            <!-- Program description -->
-            <!--<control type="image" id="4117">-->
-                <!--<description>glasspane</description>-->
-                <!--<posx>0</posx>-->
-                <!--<posy>500</posy>-->
-                <!--<width>1280</width>-->
-                <!--<height>220</height>-->
-                <!--<texture>tvguide-glasspane.png</texture>-->
-            <!--</control>-->
             <control type="label" id="4020">
                 <description>Program title</description>
                 <posx>30</posx>
@@ -303,6 +305,16 @@
                 <aligny>center</aligny>
                 <visible>!Control.IsVisible(4200)</visible>
             </control>
+            <control type="image" id="4024">
+                <description>Channel logo</description>
+                <posx>640</posx>
+                <posy>518</posy>
+                <width>80</width>
+                <height>40</height>
+                <aspectratio>keep</aspectratio>
+                <fadetime>500</fadetime>
+                <visible>!Control.IsVisible(4200)</visible>
+            </control>
             <control type="label" id="4021">
                 <description>Program time</description>
                 <posx>900</posx>
diff --git a/script.tvguide/source.py b/script.tvguide/source.py
index 82f4889..51b10d6 100644
--- a/script.tvguide/source.py
+++ b/script.tvguide/source.py
@@ -28,6 +28,7 @@ import ysapi
 
 import xbmc
 import xbmcgui
+import xbmcvfs
 import pickle
 from sqlite3 import dbapi2 as sqlite3
 
@@ -88,8 +89,7 @@ class Source(object):
     STREAMS = {}
     SOURCE_DB = 'source.db'
 
-    def __init__(self, settings, hasChannelIcons):
-        self.channelIcons = hasChannelIcons
+    def __init__(self, settings):
         self.cachePath = settings['cache.path']
         self.playbackUsingDanishLiveTV = False
 
@@ -109,9 +109,6 @@ class Source(object):
     def __del__(self):
         self.conn.close()
 
-    def hasChannelIcons(self):
-        return self.channelIcons
-
     def updateChannelAndProgramListCaches(self):
         xbmc.log("[script.tvguide] Updating channel list caches...", 
xbmc.LOGDEBUG)
         channelList = self.getChannelList()
@@ -141,7 +138,7 @@ class Source(object):
                 xbmc.log('[script.tvguide] Exception while loading cached 
channel list')
 
         if not cacheHit or not channelList:
-            xbmc.log('[script.tvguide] Caching channel list...')
+            xbmc.log('[script.tvguide] Caching channel list...', xbmc.LOGDEBUG)
             try:
                 channelList = self._getChannelList()
             except Exception as ex:
@@ -162,19 +159,23 @@ class Source(object):
         return None
 
     def getProgramList(self, channel, date):
-        id = str(channel.id).replace('/', '')
+        if type(channel.id) in [str, unicode]:
+            id = channel.id.encode('utf-8', errors='ignore')
+        else:
+            id = str(channel.id)
+
         dateString = date.strftime('%Y%m%d')
-        cacheFile = os.path.join(self.cachePath, '%s-%s-%s.programlist' % 
(self.KEY, id, dateString))
+        cacheFile = os.path.join(self.cachePath, '%s-%s-%s.programlist' % 
(self.KEY, id.replace('/', ''), dateString))
 
         programList = None
         if os.path.exists(cacheFile):
             try:
                 programList = pickle.load(open(cacheFile))
             except Exception:
-                xbmc.log('[script.tvguide] Exception while loading cached 
program list for channel %s' % channel.id)
+                xbmc.log('[script.tvguide] Exception while loading cached 
program list for channel %s' % id)
 
         if not programList:
-            xbmc.log('[script.tvguide] Caching program list for channel %s...' 
% channel.id)
+            xbmc.log('[script.tvguide] Caching program list for channel %s...' 
% id, xbmc.LOGDEBUG)
             try:
                 programList = self._getProgramList(channel, date)
                 pickle.dump(programList, open(cacheFile, 'w'))
@@ -252,7 +253,7 @@ class DrDkSource(Source):
     }
 
     def __init__(self, settings):
-        Source.__init__(self, settings, False)
+        Source.__init__(self, settings)
 
     def _getChannelList(self):
         jsonChannels = simplejson.loads(self._downloadUrl(self.CHANNELS_URL))
@@ -297,7 +298,7 @@ class YouSeeTvSource(Source):
     }
 
     def __init__(self, settings):
-        Source.__init__(self, settings, True)
+        Source.__init__(self, settings)
         self.date = datetime.datetime.today()
         self.channelCategory = settings['youseetv.category']
         self.ysApi = ysapi.YouSeeTVGuideApi()
@@ -349,7 +350,6 @@ class YouSeeTvSource(Source):
 
 
 class TvTidSource(Source):
-    # http://tvtid.tv2.dk/js/fetch.js.php/from-1291057200.js
     KEY = 'tvtiddk'
 
     BASE_URL = 'http://tvtid.tv2.dk%s'
@@ -366,7 +366,7 @@ class TvTidSource(Source):
     }
 
     def __init__(self, settings):
-        Source.__init__(self, settings, True)
+        Source.__init__(self, settings)
 
     def _getChannelList(self):
         response = self._downloadUrl(self.CHANNELS_URL)
@@ -389,13 +389,18 @@ class TvTidSource(Source):
         @return:
         """
         dateString = date.strftime('%Y%m%d')
-        cacheFile = os.path.join(self.cachePath, '%s-%s-%s.programlist.source' 
% (self.KEY, id, dateString))
-        if not os.path.exists(cacheFile):
+        cacheFile = os.path.join(self.cachePath, '%s-%s-%s.programlist.source' 
% (self.KEY, channel.id, dateString))
+        json = None
+        if os.path.exists(cacheFile):
+            try:
+                json = pickle.load(open(cacheFile))
+            except Exception:
+                pass
+
+        if not os.path.exists(cacheFile) or json is None:
             response = self._downloadUrl(self.PROGRAMS_URL % 
date.strftime('%Y%m%d'))
             json = simplejson.loads(response)
             pickle.dump(json, open(cacheFile, 'w'))
-        else:
-            json = pickle.load(open(cacheFile))
 
 
         # assume we always find a channel
@@ -420,15 +425,15 @@ class XMLTVSource(Source):
     }
 
     def __init__(self, settings):
-        self.xmlTvFile = settings['xmltv.file']
+        self.logoFolder = settings['xmltv.logo.folder']
         self.time = time.time()
-        try:
-            doc = self._loadXml()
-            hasChannelIcons = doc.find('channel/icon') is not None
-        except Exception:
-            hasChannelIcons = False
 
-        super(XMLTVSource, self).__init__(settings, hasChannelIcons)
+        super(XMLTVSource, self).__init__(settings)
+
+        self.xmlTvFile = os.path.join(self.cachePath, '%s.xmltv' % self.KEY)
+        if xbmcvfs.exists(settings['xmltv.file']):
+            xbmc.log('[script.tvguide] Caching XMLTV file...')
+            xbmcvfs.copy(settings['xmltv.file'], self.xmlTvFile)
 
         # calculate nearest hour
         self.time -= self.time % 3600
@@ -437,10 +442,15 @@ class XMLTVSource(Source):
         doc = self._loadXml()
         channelList = list()
         for channel in doc.findall('channel'):
+            title = channel.findtext('display-name')
             logo = None
+            if self.logoFolder:
+                logoFile = os.path.join(self.logoFolder, title + '.png')
+                if xbmcvfs.exists(logoFile):
+                    logo = logoFile
             if channel.find('icon'):
                 logo = channel.find('icon').get('src')
-            c = Channel(id = channel.get('id'), title = 
channel.findtext('display-name'), logo = logo)
+            c = Channel(id = channel.get('id'), title = title, logo = logo)
             channelList.append(c)
 
         return channelList

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

Summary of changes:
 script.tvguide/addon.py                            |    1 +
 script.tvguide/addon.xml                           |    2 +-
 script.tvguide/changelog.txt                       |    7 ++
 script.tvguide/gui.py                              |   59 +++++++++++--------
 .../resources/language/Danish/strings.xml          |    1 +
 .../resources/language/English/strings.xml         |    1 +
 script.tvguide/resources/settings.xml              |    2 +-
 .../skins/Default/720p/script-tvguide-main.xml     |   54 ++++++++++-------
 script.tvguide/source.py                           |   62 +++++++++++--------
 9 files changed, 115 insertions(+), 74 deletions(-)


hooks/post-receive
-- 
Scripts

------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to