The branch, frodo has been updated
       via  ec64194e3b348dc95f37e5b4fda36ae9307dad4d (commit)
      from  f9d0ef3bee778002b7e25994503227a32bcbe1ad (commit)

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

commit ec64194e3b348dc95f37e5b4fda36ae9307dad4d
Author: Martijn Kaijser <[email protected]>
Date:   Tue Oct 7 17:16:04 2014 +0200

    [plugin.video.drnu] 5.0.6

diff --git a/plugin.video.drnu/addon.py b/plugin.video.drnu/addon.py
index 7bf5e78..c9e0f9b 100644
--- a/plugin.video.drnu/addon.py
+++ b/plugin.video.drnu/addon.py
@@ -30,6 +30,7 @@ import xbmcaddon
 import xbmcplugin
 
 import tvapi
+import tvgui
 import buggalo
 
 
@@ -39,6 +40,11 @@ class DrDkTvAddon(object):
         self.favorites = list()
         self.recentlyWatched = list()
 
+        self.menuItems = list()
+        runScript = "RunAddon(plugin.video.drnu,?show=areaselector&random=%d)" 
% HANDLE
+        self.menuItems.append((ADDON.getLocalizedString(30511), runScript))
+
+
     def _save(self):
         # save favorites
         self.favorites.sort()
@@ -62,47 +68,76 @@ class DrDkTvAddon(object):
             except Exception:
                 pass
 
+    def showAreaSelector(self):
+        gui = tvgui.AreaSelectorDialog()
+        gui.doModal()
+        areaSelected = gui.areaSelected
+        del gui
+
+        if areaSelected == 'none':
+            pass
+        elif areaSelected == 'drtv':
+            self.showMainMenu()
+        else:
+            items = self.api.getChildrenFrontItems('dr-' + areaSelected)
+            #xbmc.executebuiltin('Container.SetViewMode(500)')
+            self.listSeries(items)
+
     def showMainMenu(self):
         items = list()
         # Live TV
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30027), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'livetv.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?show=liveTV', item, True))
 
         # A-Z Program Series
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30000), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'all.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?show=listAZ', item, True))
 
+        # Latest
+        item = xbmcgui.ListItem(ADDON.getLocalizedString(30001), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'all.png'))
+        item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
+        items.append((PATH + '?show=latest', item, True))
+
         # Premiere
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30025), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'new.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?listVideos=%s' % tvapi.SLUG_PREMIERES, item, 
True))
 
         # Most viewed
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30011), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'eye.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?show=mostViewed', item, True))
 
         # Spotlight
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30002), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'star.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?show=highlights', item, True))
 
         # Search videos
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30003), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'search.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?show=search', item, True))
 
         # Recently watched Program Series
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30007), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'eye-star.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
+        item.addContextMenuItems(self.menuItems, False)
         items.append((PATH + '?show=recentlyWatched', item, True))
 
         # Favorite Program Series
         item = xbmcgui.ListItem(ADDON.getLocalizedString(30008), 
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons', 
'plusone.png'))
         item.setProperty('Fanart_Image', FANART_IMAGE)
         items.append((PATH + '?show=favorites', item, True))
+        item.addContextMenuItems(self.menuItems, False)
 
         xbmcplugin.addDirectoryItems(HANDLE, items)
         xbmcplugin.endOfDirectory(HANDLE)
@@ -122,11 +157,15 @@ class DrDkTvAddon(object):
         self._load()
         videos = list()
         for slug in self.recentlyWatched:
-            item = self.api.getEpisode(slug)
-            if item is None:
+            try:
+                item = self.api.getEpisode(slug)
+                if item is None:
+                    self.recentlyWatched.remove(slug)
+                else:
+                    videos.append(item)
+            except tvapi.ApiException:
+                # probably a 404 - non-existent slug
                 self.recentlyWatched.remove(slug)
-            else:
-                videos.append(item)
 
         self._save()
         if not videos:
@@ -152,6 +191,7 @@ class DrDkTvAddon(object):
 
             item = xbmcgui.ListItem(channel['Title'], 
iconImage=channel['PrimaryImageUri'])
             item.setProperty('Fanart_Image', channel['PrimaryImageUri'])
+            item.addContextMenuItems(self.menuItems, False)
 
             url = server['Server'] + '/' + 
server['Qualities'][0]['Streams'][0]['Stream']
             items.append((url, item, False))
@@ -169,6 +209,7 @@ class DrDkTvAddon(object):
         for programIndex in self.api.getProgramIndexes():
             item = xbmcgui.ListItem(programIndex['Title'], iconImage=iconImage)
             item.setProperty('Fanart_Image', FANART_IMAGE)
+            item.addContextMenuItems(self.menuItems, False)
 
             url = PATH + '?listProgramSeriesByLetter=' + programIndex['_Param']
             items.append((url, item, True))
@@ -194,7 +235,8 @@ class DrDkTvAddon(object):
         else:
             directoryItems = list()
             for item in items:
-                menuItems = list()
+                menuItems = list(self.menuItems)
+
                 if self.favorites.count(item['SeriesTitle']) > 0:
                     runScript = 
"XBMC.RunPlugin(plugin://plugin.video.drnu/?delfavorite=%s)" % 
item['SeriesTitle'].replace('&', '%26')
                     menuItems.append((ADDON.getLocalizedString(30201), 
runScript))
@@ -214,7 +256,7 @@ class DrDkTvAddon(object):
             xbmcplugin.addDirectoryItems(HANDLE, directoryItems)
             xbmcplugin.endOfDirectory(HANDLE)
 
-    def listEpisodes(self, items):
+    def listEpisodes(self, items, addSortMethods=True):
         directoryItems = list()
         for item in items:
             if 'PrimaryAsset' not in item or 'Uri' not in item['PrimaryAsset'] 
or not item['PrimaryAsset']['Uri']:
@@ -236,18 +278,24 @@ class DrDkTvAddon(object):
             listItem.setProperty('Fanart_Image', iconImage)
             url = PATH + '?playVideo=' + item['Slug']
             listItem.setProperty('IsPlayable', 'true')
+            listItem.addContextMenuItems(self.menuItems, False)
             directoryItems.append((url, listItem))
 
         xbmcplugin.addDirectoryItems(HANDLE, directoryItems)
-        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
-        xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_TITLE)
+        if addSortMethods:
+            xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
+            xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_TITLE)
         xbmcplugin.endOfDirectory(HANDLE)
 
     def playVideo(self, slug):
         self.updateRecentlyWatched(slug)
         item = self.api.getEpisode(slug)
-        video = self.api.getVideoUrl(item['PrimaryAsset']['Uri'])
 
+        if not 'PrimaryAsset' in item:
+            self.displayError(ADDON.getLocalizedString(30904))
+            return
+
+        video = self.api.getVideoUrl(item['PrimaryAsset']['Uri'])
         item = xbmcgui.ListItem(path=video['Uri'])
         xbmcplugin.setResolvedUrl(HANDLE, video['Uri'] is not None, item)
 
@@ -276,18 +324,18 @@ class DrDkTvAddon(object):
         else:
             return None
 
-    def addFavorite(self, title):
+    def addFavorite(self, key):
         self._load()
-        if not self.favorites.count(title):
-            self.favorites.append(title)
+        if not self.favorites.count(key):
+            self.favorites.append(key)
         self._save()
 
         xbmcgui.Dialog().ok(ADDON.getLocalizedString(30008), 
ADDON.getLocalizedString(30009))
 
-    def delFavorite(self, title):
+    def delFavorite(self, key):
         self._load()
-        if self.favorites.count(title):
-            self.favorites.remove(title)
+        if self.favorites.count(key):
+            self.favorites.remove(key)
         self._save()
         xbmcgui.Dialog().ok(ADDON.getLocalizedString(30008), 
ADDON.getLocalizedString(30010))
 
@@ -334,6 +382,8 @@ if __name__ == '__main__':
                 drDkTvAddon.showLiveTV()
             elif PARAMS['show'][0] == 'listAZ':
                 drDkTvAddon.showAZ()
+            elif PARAMS['show'][0] == 'latest':
+                drDkTvAddon.listEpisodes(drDkTvAddon.api.getLatestPrograms(), 
addSortMethods=False)
             elif PARAMS['show'][0] == 'mostViewed':
                 drDkTvAddon.listEpisodes(drDkTvAddon.api.getMostViewed())
             elif PARAMS['show'][0] == 'highlights':
@@ -344,6 +394,8 @@ if __name__ == '__main__':
                 drDkTvAddon.showFavorites()
             elif PARAMS['show'][0] == 'recentlyWatched':
                 drDkTvAddon.showRecentlyWatched()
+            elif PARAMS['show'][0] == 'areaselector':
+                drDkTvAddon.showAreaSelector()
 
         elif 'listProgramSeriesByLetter' in PARAMS:
             
drDkTvAddon.listSeries(drDkTvAddon.api.getSeries(PARAMS['listProgramSeriesByLetter'][0]))
@@ -361,7 +413,21 @@ if __name__ == '__main__':
             drDkTvAddon.delFavorite(PARAMS['delfavorite'][0])
 
         else:
-            drDkTvAddon.showMainMenu()
+            try:
+                area = int(ADDON.getSetting('area'))
+            except:
+                area = 0
+
+            if area == 0:
+                drDkTvAddon.showAreaSelector()
+            elif area == 1:
+                drDkTvAddon.showMainMenu()
+            elif area == 2:
+                items = drDkTvAddon.api.getChildrenFrontItems('dr-ramasjang')
+                drDkTvAddon.listSeries(items)
+            elif area == 3:
+                items = drDkTvAddon.api.getChildrenFrontItems('dr-ultra')
+                drDkTvAddon.listSeries(items)
 
     except tvapi.ApiException, ex:
         drDkTvAddon.displayError(str(ex))
diff --git a/plugin.video.drnu/addon.xml b/plugin.video.drnu/addon.xml
index e221e0b..a738dec 100644
--- a/plugin.video.drnu/addon.xml
+++ b/plugin.video.drnu/addon.xml
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<addon id="plugin.video.drnu" version="5.0.1" name="DR TV" 
provider-name="twinther">
+<addon id="plugin.video.drnu" version="5.0.6" name="DR TV" 
provider-name="twinther">
     <requires>
         <import addon="xbmc.python" version="2.1.0"/>
         <import addon="script.module.simplejson" version="2.0.10"/>
diff --git a/plugin.video.drnu/changelog.txt b/plugin.video.drnu/changelog.txt
index d346fd6..dd24bd9 100644
--- a/plugin.video.drnu/changelog.txt
+++ b/plugin.video.drnu/changelog.txt
@@ -1,3 +1,22 @@
+[B]Version 5.0.6 - 2014-10-05[/B]
+- Gracefully handle error when videoclip is no longer available for playback
+
+[B]Version 5.0.5 - 2014-10-02[/B]
+- Changed cache period of latest programs to five minutes (instead of a full 
day)
+
+[B]Version 5.0.4 - 2014-09-16[/B]
+- Fixed favorite program series
+- Added "Clear favorite program series" in the settings to fix broken 
favorites list
+- Re-added latest programs
+
+[B]Version 5.0.3 - 2014-09-02[/B]
+- Added 'Show area chooser' to context menu
+- Fixed problem with recently watched when the slug no longer exists on the 
server
+
+[B]Version 5.0.2 - 2014-07-29[/B]
+- Added optional area chooser
+  Set default area in addon settings
+
 [B]Version 5.0.1 - 2014-06-02[/B]
 - Fixed problem parsing certain dates
 
diff --git a/plugin.video.drnu/resources/language/Danish/strings.xml 
b/plugin.video.drnu/resources/language/Danish/strings.xml
index 691df21..0db1047 100644
--- a/plugin.video.drnu/resources/language/Danish/strings.xml
+++ b/plugin.video.drnu/resources/language/Danish/strings.xml
@@ -12,19 +12,32 @@
     <string id="30013">Listen er tom.</string>
     <string id="30018">Du kan tilføje programmer til foretrukne ved 
brug</string>
     <string id="30019">af højreklik-menuen.</string>
-    <string id="30020">De videoer du sidst har set tilføjest 
automatisk.</string>
+    <string id="30020">De videoer du sidst har set tilføjes 
automatisk.</string>
     <string id="30025">Forpremiere</string>
     <string id="30027">Live TV</string>
 
+    <string id="30100">DR TV Univers</string>
+    <string id="30101">Vælg område</string>
+
     <string id="30200">Tilføj til foretrukne programmer</string>
     <string id="30201">Fjern fra foretrukne programmer</string>
+    <string id="30202">Foretrukne programmer blev nulstillet</string>
 
     <string id="30500">Generelt</string>
     <string id="30503">Vis undertekster (hvis tilgængelige)</string>
+    <string id="30504">Nulstil listen med foretrukne programmer</string>
+
+    <string id="30510">Start i område</string>
+    <string id="30511">Vis områdevælger</string>
+    <string id="30512">DR TV</string>
+    <string id="30513">Ramasjang</string>
+    <string id="30514">Ultra</string>
 
     <string id="30900">Der er sket en fejl i kommunikationen med DR 
NU.</string>
     <string id="30901">Prøv igen senere. Fejlen er:</string>
 
     <string id="30902">Det var ikke muligt at gemme midlertidige data</string>
     <string id="30903">lokalt på disken. Fejlen er:</string>
+
+    <string id="30904">Videoen er ikke længere tilgængelig og kan ikke 
afspilles.</string>
 </strings>
diff --git a/plugin.video.drnu/resources/language/English/strings.xml 
b/plugin.video.drnu/resources/language/English/strings.xml
index 564cc0b..3bf36a0 100644
--- a/plugin.video.drnu/resources/language/English/strings.xml
+++ b/plugin.video.drnu/resources/language/English/strings.xml
@@ -17,15 +17,29 @@
     <string id="30025">Premiere videos</string>
     <string id="30027">Live TV</string>
 
+    <string id="30100">DR TV Universe</string>
+    <string id="30101">Choose area</string>
+
     <string id="30200">Add to favorite program series</string>
     <string id="30201">Remove from favorite program series</string>
+    <string id="30202">Favorite program series cleared</string>
 
     <string id="30500">General</string>
     <string id="30503">Enable subtitles (if available)</string>
+    <string id="30504">Clear the favorite programs list</string>
+
+    <string id="30510">Start in area</string>
+    <string id="30511">Show area chooser</string>
+    <string id="30512">DR TV</string>
+    <string id="30513">Ramasjang</string>
+    <string id="30514">Ultra</string>
 
-    <string id="30900">There was an error while communication with DR 
NU.</string>
+    <string id="30900">There was an error while communicating with DR 
NU.</string>
     <string id="30901">Please try again later. Error message is:</string>
 
     <string id="30902">There was an error while writing temporary data</string>
     <string id="30903">to the local disk. The error message is:</string>
+
+    <string id="30904">The video is no longer available and playback is not 
possible.</string>
+
 </strings>
diff --git a/plugin.video.drnu/resources/settings.xml 
b/plugin.video.drnu/resources/settings.xml
index 5a93d18..b9d666a 100644
--- a/plugin.video.drnu/resources/settings.xml
+++ b/plugin.video.drnu/resources/settings.xml
@@ -1,7 +1,9 @@
 <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
 <settings>
        <category label="30500">
+        <setting id="area" label="30510" type="enum" default="0" 
lvalues="30511|30512|30513|30514" />
         <setting id="enable.subtitles" label="30503" type="bool" 
default="true" />
+        <setting label="30504" type="action" 
action="RunScript($CWD/clearfavorites.py)" />
        </category>
 </settings>
 
diff --git a/plugin.video.drnu/tvapi.py b/plugin.video.drnu/tvapi.py
index 3500cca..fcf8623 100644
--- a/plugin.video.drnu/tvapi.py
+++ b/plugin.video.drnu/tvapi.py
@@ -31,7 +31,7 @@ SLUG_PREMIERES='forpremierer'
 
 
 class Api(object):
-    API_URL = 'http://www.dr.dk/mu-online/api/1.0'
+    API_URL = 'http://www.dr.dk/mu-online/api/1.1'
 
     def __init__(self, cachePath):
         self.cachePath = cachePath
@@ -39,6 +39,18 @@ class Api(object):
     def getLiveTV(self):
         return self._http_request('/channel/all-active-dr-tv-channels')
 
+    def getChildrenFrontItems(self, channel):
+        childrenFront = self._http_request('/page/tv/children/front/%s' % 
channel)
+        return self._handle_paging(childrenFront['Programs'])
+
+    def getLatestPrograms(self):
+        result = self._http_request('/page/tv/programs', {
+            'index': '*',
+            'orderBy': 'LastPrimaryBroadcastWithPublicAsset',
+            'orderDescending': 'true'
+        }, cacheMinutes=5)
+        return result['Programs']['Items']
+
     def getProgramIndexes(self):
         result = self._http_request('/page/tv/programs')
         if 'Indexes' in result:
@@ -55,7 +67,8 @@ class Api(object):
         return self._handle_paging(result)
 
     def searchSeries(self, query):
-        result = 
self._http_request('/search/tv/programcards-latest-episode-with-asset/series-title/%s'
 % query)
+        # Remove & as it makes the API puke
+        result = 
self._http_request('/search/tv/programcards-latest-episode-with-asset/series-title/%s'
 % query.replace('&', ''))
         return self._handle_paging(result)
 
     def getEpisodes(self, slug):
@@ -101,10 +114,10 @@ class Api(object):
             items.extend(result['Items'])
         return items
 
-    def _http_request(self, url, params=None):
+    def _http_request(self, url, params=None, cacheMinutes = 720):
         try:
             if not url.startswith('http://'):
-                url = self.API_URL + url
+                url = self.API_URL + urllib.quote(url, '/')
 
             if params:
                 url = url + '?' + urllib.urlencode(params, doseq=True)
@@ -116,8 +129,8 @@ class Api(object):
 
             urlCachePath = os.path.join(self.cachePath, 
hashlib.md5(url).hexdigest() + '.cache')
 
-            oneDayAgo = datetime.datetime.now() - datetime.timedelta(days=1)
-            if not os.path.exists(urlCachePath) or 
datetime.datetime.fromtimestamp(os.path.getmtime(urlCachePath)) < oneDayAgo:
+            cacheUntil = datetime.datetime.now() - 
datetime.timedelta(minutes=cacheMinutes)
+            if not os.path.exists(urlCachePath) or 
datetime.datetime.fromtimestamp(os.path.getmtime(urlCachePath)) < cacheUntil:
                 u = urllib2.urlopen(url, timeout=30)
                 content = u.read()
                 u.close()

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

Summary of changes:
 plugin.video.drnu/addon.py                         |   98 ++++++++++++++++---
 plugin.video.drnu/addon.xml                        |    2 +-
 plugin.video.drnu/changelog.txt                    |   19 ++++
 plugin.video.drnu/clearfavorites.py                |   37 ++++++++
 plugin.video.drnu/resources/button-drtv-focus.png  |  Bin 0 -> 6774 bytes
 plugin.video.drnu/resources/button-drtv.png        |  Bin 0 -> 4177 bytes
 .../resources/button-ramasjang-focus.png           |  Bin 0 -> 90837 bytes
 plugin.video.drnu/resources/button-ramasjang.png   |  Bin 0 -> 77621 bytes
 plugin.video.drnu/resources/button-ultra-focus.png |  Bin 0 -> 100020 bytes
 plugin.video.drnu/resources/button-ultra.png       |  Bin 0 -> 86068 bytes
 .../resources/language/Danish/strings.xml          |   15 +++-
 .../resources/language/English/strings.xml         |   16 +++-
 plugin.video.drnu/resources/settings.xml           |    2 +
 plugin.video.drnu/tvapi.py                         |   25 ++++-
 plugin.video.drnu/tvgui.py                         |   71 ++++++++++++++
 15 files changed, 260 insertions(+), 25 deletions(-)
 create mode 100644 plugin.video.drnu/clearfavorites.py
 create mode 100644 plugin.video.drnu/resources/button-drtv-focus.png
 create mode 100644 plugin.video.drnu/resources/button-drtv.png
 create mode 100644 plugin.video.drnu/resources/button-ramasjang-focus.png
 create mode 100644 plugin.video.drnu/resources/button-ramasjang.png
 create mode 100644 plugin.video.drnu/resources/button-ultra-focus.png
 create mode 100644 plugin.video.drnu/resources/button-ultra.png
 create mode 100644 plugin.video.drnu/tvgui.py


hooks/post-receive
-- 
Plugins

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons

Reply via email to