The branch, dharma has been updated
via 1fd0a130e851a546578d29eccae52b852f91ea3e (commit)
from 267f3b7945e53bf57c8e635a01f9159c088cadb2 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=1fd0a130e851a546578d29eccae52b852f91ea3e
commit 1fd0a130e851a546578d29eccae52b852f91ea3e
Author: spiff <[email protected]>
Date: Mon Sep 19 18:17:17 2011 +0200
[plugin.video.drnu] updated to version 1.4.1
diff --git a/plugin.video.drnu/addon.py b/plugin.video.drnu/addon.py
index 8a525b8..f588d9e 100644
--- a/plugin.video.drnu/addon.py
+++ b/plugin.video.drnu/addon.py
@@ -20,16 +20,23 @@ class NuAddon(object):
# load favorites
self.favorites = list()
if os.path.exists(FAVORITES_PATH):
- self.favorites = pickle.load(open(FAVORITES_PATH, 'rb'))
+ try:
+ self.favorites = pickle.load(open(FAVORITES_PATH, 'rb'))
+ except Exception:
+ pass
# load recently watched
self.recentlyWatched = list()
if os.path.exists(RECENT_PATH):
- self.recentlyWatched = pickle.load(open(RECENT_PATH, 'rb'))
+ try:
+ self.recentlyWatched = pickle.load(open(RECENT_PATH, 'rb'))
+ except Exception:
+ pass
def _save(self):
# save favorites
+ self.favorites.sort()
pickle.dump(self.favorites, open(FAVORITES_PATH, 'wb'))
self.recentlyWatched = self.recentlyWatched[0:10] # Limit to ten items
@@ -58,6 +65,10 @@ class NuAddon(object):
item = xbmcgui.ListItem(ADDON.getLocalizedString(30002),
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons',
'star.png'))
item.setProperty('Fanart_Image', fanartImage)
xbmcplugin.addDirectoryItem(HANDLE, PATH + '?show=spotlight', item,
isFolder = True)
+ # Last chance
+ item = xbmcgui.ListItem(ADDON.getLocalizedString(30014),
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons',
'clock.png'))
+ item.setProperty('Fanart_Image', fanartImage)
+ xbmcplugin.addDirectoryItem(HANDLE, PATH + '?show=lastChance', item,
isFolder = True)
# Search videos
item = xbmcgui.ListItem(ADDON.getLocalizedString(30003),
iconImage=os.path.join(ADDON.getAddonInfo('path'), 'resources', 'icons',
'search.png'))
item.setProperty('Fanart_Image', fanartImage)
@@ -85,6 +96,9 @@ class NuAddon(object):
def showMostViewedVideos(self):
self.listVideos(self.api.getMostViewedVideos())
+ def showLastChanceVideos(self):
+ self.listVideos(self.api.getLastChanceVideos())
+
def showFavorites(self):
nuAddon.showProgramSeries(self.favorites, False)
@@ -168,18 +182,7 @@ class NuAddon(object):
keyboard.doModal()
if keyboard.isConfirmed():
keyword = keyboard.getText()
- if len(keyword) > 3:
- videos = self.api.getAllVideos()
- for idx in range(len(videos)-1, -1, -1):
- video = videos[idx]
- # simplistic search for title
- if video['title'].lower().find(keyword.lower()) == -1:
- del videos[idx]
-
- if not len(videos):
- xbmcgui.Dialog().ok(ADDON.getLocalizedString(30003),
ADDON.getLocalizedString(30005))
- else:
- self.listVideos(videos)
+ self.listVideos(self.api.search(keyword))
def listVideos(self, videos):
@@ -204,7 +207,7 @@ class NuAddon(object):
infoLabels['studio'] = video['broadcastChannel']
if video.has_key('broadcastTime') and video['broadcastTime'] is
not None:
broadcastTime = self.parseDate(video['broadcastTime'])
- infoLabels['plotoutline'] = 'Sendt: %s' %
broadcastTime.strftime('%d. %b %Y kl. %H:%M')
+ infoLabels['plotoutline'] = ADDON.getLocalizedString(30015) %
broadcastTime.strftime('%d. %b %Y kl. %H:%M')
infoLabels['date'] = broadcastTime.strftime('%d.%m.%Y')
infoLabels['aired'] = broadcastTime.strftime('%Y-%m-%d')
infoLabels['year'] = int(broadcastTime.strftime('%Y'))
@@ -219,7 +222,9 @@ class NuAddon(object):
infoLabels['tvshowtitle'] = serie['title']
else:
tvShowTitles[video['programSerieSlug']] = None
-
+ if video.has_key('expireTime') and video['expireTime'] is not None:
+ expireTime = self.parseDate(video['expireTime'])
+ infoLabels['plot'] += '[CR][CR]' +
ADDON.getLocalizedString(30016) % expireTime.strftime('%d. %b %Y kl. %H:%M')
iconImage = self.api.getVideoImageUrl(str(video['id']), 256)
thumbnailImage = self.api.getVideoImageUrl(str(video['id']), 512)
@@ -304,6 +309,8 @@ if __name__ == '__main__':
nuAddon.showSpotlightVideos()
elif PARAMS['show'][0] == 'mostViewed':
nuAddon.showMostViewedVideos()
+ elif PARAMS['show'][0] == 'lastChance':
+ nuAddon.showLastChanceVideos()
elif PARAMS['show'][0] == 'search':
nuAddon.searchVideos()
elif PARAMS['show'][0] == 'favorites':
diff --git a/plugin.video.drnu/addon.xml b/plugin.video.drnu/addon.xml
index 2060257..c3440ca 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="1.4.0" name="DR NU Player"
provider-name="InKaKiLLeR, twinther [[email protected]]">
+<addon id="plugin.video.drnu" version="1.4.1" name="DR NU Player"
provider-name="InKaKiLLeR, twinther [[email protected]]">
<requires>
<import addon="xbmc.python" version="1.0"/>
<import addon="script.module.simplejson" version="2.0.10"/>
@@ -10,12 +10,12 @@
<extension point="xbmc.addon.metadata">
<summary lang="en">DR NU</summary>
<summary lang="da">DR NU</summary>
- <description lang="en">Watch the latest shows from DR.dk/nu[BR][BR]
-All programs that DR has the rights to show on the internet is available in DR
NU. The typically means DR's own programs, news, sports and magazine - but not
movies and some international tv-shows.[BR][BR]
+ <description lang="en">Watch the latest shows from DR.dk/nu[CR][CR]
+All programs that DR has the rights to show on the internet is available in DR
NU. The typically means DR's own programs, news, sports and magazine - but not
movies and some international tv-shows.[CR][CR]
You can added program series to favorites using the context menu.
</description>
- <description lang="da">Se de seneste udsendelser fra DR.dk/nu[BR][BR]
-Alle de programmer, DR har rettigheder til at vise på nettet, vil være at
finde i DR NU. Dette gælder typisk DR's egne programmer, nyheder, sport og
magasiner - men ikke film eller visse udenlandske tv-serier.[BR][BR]
+ <description lang="da">Se de seneste udsendelser fra DR.dk/nu[CR][CR]
+Alle de programmer, DR har rettigheder til at vise på nettet, vil være at
finde i DR NU. Dette gælder typisk DR's egne programmer, nyheder, sport og
magasiner - men ikke film eller visse udenlandske tv-serier.[CR][CR]
Du kan tilføje programmer til foretrukne ved brug af højreklik-menuen.
</description>
<disclaimer lang="en">Some parts of this addon may not be legal in
your country of residence - please check with your local laws.</disclaimer>
diff --git a/plugin.video.drnu/changelog.txt b/plugin.video.drnu/changelog.txt
index 65fabf2..e62091a 100644
--- a/plugin.video.drnu/changelog.txt
+++ b/plugin.video.drnu/changelog.txt
@@ -1,3 +1,8 @@
+[B]Version 1.4.1 - 2011-09-19[/B]
+- Changed search to use new search API call
+- Added 'Last Chance' videos that will expire soon
+- Sort favorites
+
[B]Version 1.4.0[/B]
- Refactored API
- New graphics
diff --git a/plugin.video.drnu/nuapi.py b/plugin.video.drnu/nuapi.py
index a530c82..8c8565b 100644
--- a/plugin.video.drnu/nuapi.py
+++ b/plugin.video.drnu/nuapi.py
@@ -59,23 +59,29 @@ class DrNuApi(object):
def getAllVideos(self):
- return self._call_api('videos/all', 'all.json')
+ return self._call_api('videos/all', 'all.json') or list()
def getNewestVideos(self):
- return self._call_api('videos/newest', 'newest.json')
+ return self._call_api('videos/newest', 'newest.json') or list()
+
+ def getLastChanceVideos(self):
+ return self._call_api('videos/lastchance', 'lastchance.json') or list()
def getMostViewedVideos(self):
- return self._call_api('videos/mostviewed', 'mostviewed.json')
+ return self._call_api('videos/mostviewed', 'mostviewed.json') or list()
def getSpotlightVideos(self):
- return self._call_api('videos/spot', 'spot.json')
+ return self._call_api('videos/spot', 'spot.json') or list()
def getProgramSeriesVideos(self, programSeriesSlug):
- return self._call_api('programseries/%s/videos' % programSeriesSlug,
'programseries-%s.json' % programSeriesSlug)
+ return self._call_api('programseries/%s/videos' % programSeriesSlug,
'programseries-%s.json' % programSeriesSlug) or list()
def getVideoById(self, id):
return self._call_api('videos/%s' % id, 'videobyid-%s.json' % id)
+ def search(self, term):
+ return self._call_api('search/%s' % term) or list()
+
def getProgramSeriesImageUrl(self, programSlug, width, height = None):
if height is None:
height = width
@@ -91,40 +97,49 @@ class DrNuApi(object):
height = width
return API_URL % ('chapters/%s/images/%dx%d.jpg' % (id, width, height))
-
- def _call_api(self, path, cacheFilename):
+ def _call_api(self, path, cacheFilename = None):
print "Calling API: " + API_URL % path
- cachePath = os.path.join(self.cachePath, cacheFilename)
- try:
- cachedOn = os.path.getmtime(cachePath)
- except OSError: # File not found
- cachedOn = 0
-
- if time.time() - self.cacheMinutes * 60 >= cachedOn:
- # Cache expired or miss
+ if cacheFilename:
+ cachePath = os.path.join(self.cachePath, cacheFilename)
try:
- u = urllib2.urlopen(API_URL % path)
- content = u.read()
- u.close()
-
- f = open(cachePath, 'w')
- f.write(content)
+ cachedOn = os.path.getmtime(cachePath)
+ except OSError: # File not found
+ cachedOn = 0
+
+ if time.time() - self.cacheMinutes * 60 >= cachedOn:
+ # Cache expired or miss
+ content = self._http_request(path)
+
+ if content:
+ f = open(cachePath, 'w')
+ f.write(content)
+ f.close()
+
+ else:
+ f = open(cachePath)
+ content = f.read()
f.close()
- except urllib2.HTTPError, ex:
- print "HTTPError: " + str(ex.msg)
- content = None
else:
- f = open(cachePath)
- content = f.read()
- f.close()
+ content = self._http_request(path)
if content is not None:
return simplejson.loads(content)
else:
return None
+ def _http_request(self, path):
+ try:
+ u = urllib2.urlopen(API_URL % path)
+ content = u.read()
+ u.close()
+ except urllib2.HTTPError, ex:
+ print "HTTPError: " + str(ex.msg)
+ content = None
+ return content
+
+
if __name__ == '__main__':
api = DrNuApi('/tmp', 0)
json = api.getProgramSeriesLabels()
diff --git a/plugin.video.drnu/resources/icons/icons.xcf
b/plugin.video.drnu/resources/icons/icons.xcf
index d5c8202..decf193 100644
Binary files a/plugin.video.drnu/resources/icons/icons.xcf and
b/plugin.video.drnu/resources/icons/icons.xcf differ
diff --git a/plugin.video.drnu/resources/language/Danish/strings.xml
b/plugin.video.drnu/resources/language/Danish/strings.xml
index 03897a1..3245aa8 100644
--- a/plugin.video.drnu/resources/language/Danish/strings.xml
+++ b/plugin.video.drnu/resources/language/Danish/strings.xml
@@ -14,6 +14,9 @@
<string id="30011">Mest sete videoer på DR.dk</string>
<string id="30012">Progammer efter område</string>
<string id="30013">Listen er tom</string>
+ <string id="30014">Udløber snart</string>
+ <string id="30015">Sendt: %s</string>
+ <string id="30016">Udløber: %s</string>
<string id="30100">Videoen er ikke tilgængelig</string>
<string id="30101">DR har slettet den videofil du forsøger at
afspille,</string>
@@ -21,4 +24,5 @@
<string id="30200">Tilføj til foretrukne programmer</string>
<string id="30201">Fjern fra foretrukne programmer</string>
+
</strings>
diff --git a/plugin.video.drnu/resources/language/English/strings.xml
b/plugin.video.drnu/resources/language/English/strings.xml
index eeda584..5cca318 100644
--- a/plugin.video.drnu/resources/language/English/strings.xml
+++ b/plugin.video.drnu/resources/language/English/strings.xml
@@ -14,6 +14,9 @@
<string id="30011">Most watched videos on DR.dk</string>
<string id="30012">Programs by area</string>
<string id="30013">The list is empty</string>
+ <string id="30014">Expires soon</string>
+ <string id="30015">Aired: %s</string>
+ <string id="30016">Expires on: %s</string>
<string id="30100">Video is not available</string>
<string id="30101">DR has deleted the video file you want to
watch,</string>
-----------------------------------------------------------------------
Summary of changes:
plugin.video.drnu/addon.py | 39 +++++++-----
plugin.video.drnu/addon.xml | 10 ++--
plugin.video.drnu/changelog.txt | 5 ++
plugin.video.drnu/nuapi.py | 69 ++++++++++++--------
plugin.video.drnu/resources/icons/clock.png | Bin 0 -> 7588 bytes
plugin.video.drnu/resources/icons/icons.xcf | Bin 35264 -> 42329 bytes
.../resources/language/Danish/strings.xml | 4 +
.../resources/language/English/strings.xml | 3 +
8 files changed, 82 insertions(+), 48 deletions(-)
create mode 100644 plugin.video.drnu/resources/icons/clock.png
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
Learn about the latest advances in developing for the
BlackBerry® mobile platform with sessions, labs & more.
See new tools and technologies. Register for BlackBerry® DevCon today!
http://p.sf.net/sfu/rim-devcon-copy1
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons