The branch, eden has been updated
via 55c9a4bdb781308893bcb2b823a58527a081c31f (commit)
from bdf075d309c55ae7e2adfe747178df769d62838d (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=55c9a4bdb781308893bcb2b823a58527a081c31f
commit 55c9a4bdb781308893bcb2b823a58527a081c31f
Author: beenje <[email protected]>
Date: Fri Apr 5 22:16:17 2013 +0200
[plugin.video.news.tv2.dk] updated to version 1.1.0
diff --git a/plugin.video.news.tv2.dk/addon.py
b/plugin.video.news.tv2.dk/addon.py
index 40dc610..d4ac2ca 100644
--- a/plugin.video.news.tv2.dk/addon.py
+++ b/plugin.video.news.tv2.dk/addon.py
@@ -1,5 +1,5 @@
#
-# Copyright (C) 2012 Tommy Winther
+# Copyright (C) 2013 Tommy Winther
# http://tommy.winther.nu
#
# This Program is free software; you can redistribute it and/or modify
@@ -17,6 +17,7 @@
# the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
# http://www.gnu.org/copyleft/gpl.html
#
+from htmlentitydefs import name2codepoint
import os
import sys
import urlparse
@@ -26,89 +27,139 @@ import buggalo
import xbmcgui
import xbmcaddon
import xbmcplugin
-import random
+import simplejson
+import datetime
+
+# http://nyhederne.tv2.dk/video/data/tag/nyheder/
+#
http://nyhederne.tv2.dk/video/data/tag/nyh0600/day/0/staticjsonp/staticjsonp_148f9/
+
+TAGS = ['nyheder', 'most-viewed', 'nyh0600', 'nyh0900', 'nyh1700', 'nyh1900',
'nyh2200', 'station2', 'newsmagasiner']
+
+VIDEO_DATA_URL = "http://nyhederne.tv2.dk/video/data/tag/%s/"
+PLAYLIST_URL =
'http://common.tv2.dk/mpx/player.php/adtech_alias-player_nyhederne/adtech_group-441/autoplay-1/guid-%s/player_id-video_nyhederne.html'
+FLASH_PLAYLIST_URL =
'http://common.tv2.dk/flashplayer/playlist.xml.php/clipid-%s.xml'
-VIDEO_LIST_URL = 'http://news.tv2.dk/js/video-list.js.php/video.js'
-PLAYLIST_URL =
'http://common-dyn.tv2.dk/flashplayer/playlist.xml.php/alias-player_news/autoplay-1/clipid-%s/keys-NEWS,PLAYER.xml'
class TV2NewsAddon(object):
- def listCategories(self):
- data = self._loadJson()
- if data:
- m = re.match('.*sections: \[(.*?)\]', data, re.DOTALL)
- for idx, m in enumerate(re.finditer('title: "([^"]+)"',
m.group(1))):
- title = m.group(1)
-
- item = xbmcgui.ListItem(title, iconImage = ICON)
- item.setProperty('Fanart_Image', FANART)
- url = PATH + '?idx=' + str(idx)
- xbmcplugin.addDirectoryItem(HANDLE, url, item, isFolder = True)
-
- xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_LABEL)
-
- xbmcplugin.endOfDirectory(HANDLE, succeeded=data is not None)
-
- def listCategory(self, idx):
- data = self._loadJson()
- if data:
- clips = list()
- for m in re.finditer('sources: \[(.*?)\] \}', data, re.DOTALL):
- clips.append(m.group(1))
-
- for m in re.finditer('id:
([0-9]+),\s+title:"(.*?)",\s+image:"([^"]+)",\s+description:
"(.*?)",\s+.*?date: "([^"]+)"', clips[idx], re.DOTALL):
- id = m.group(1)
- title = m.group(2).replace("\\'", "'").replace('\\"', '"')
- image = m.group(3)
- description = m.group(4)
- date = m.group(5)
-
- item = xbmcgui.ListItem(title, iconImage = image)
- item.setInfo('video', {
- 'title' : title,
- 'studio' : ADDON.getAddonInfo('name'),
- 'plot' : description,
- 'date' : date[6:].replace('-', '.')
- })
- item.setProperty('IsPlayable', 'true')
- item.setProperty('Fanart_Image', FANART)
- url = PATH + '?clip=' + str(id)
- xbmcplugin.addDirectoryItem(HANDLE, url, item)
-
- xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
- xbmcplugin.endOfDirectory(HANDLE, succeeded=data is not None)
- def playClip(self, clipId):
+ def listTags(self):
+ for idx, tag in enumerate(TAGS):
+ title = ADDON.getLocalizedString(30000 + idx)
+
+ item = xbmcgui.ListItem(title, iconImage=ICON)
+ item.setProperty('Fanart_Image', FANART)
+ url = PATH + '?tag=' + tag
+ xbmcplugin.addDirectoryItem(HANDLE, url, item, isFolder=True)
+
+ xbmcplugin.endOfDirectory(HANDLE)
+
+ def listClips(self, tag):
try:
- u = urllib2.urlopen(PLAYLIST_URL % clipId)
- playlist = u.read()
+ u = urllib2.urlopen(VIDEO_DATA_URL % tag)
+ data = u.read()
u.close()
+ clips = simplejson.loads(data.decode('iso-8859-1'))
except Exception as ex:
- heading = ADDON.getLocalizedString(random.randint(99980, 99985))
+ heading = buggalo.getRandomHeading()
line1 = ADDON.getLocalizedString(30900)
line2 = ADDON.getLocalizedString(30901)
xbmcgui.Dialog().ok(heading, line1, line2, str(ex))
-
- xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
return
- m = re.match('.*video="([^"]+)" splash="([^"]+)"', playlist, re.DOTALL)
- if m:
- item = xbmcgui.ListItem(path = m.group(1),
thumbnailImage=m.group(2))
- xbmcplugin.setResolvedUrl(HANDLE, True, item)
+ for clip in clips:
+ if 'section' in clip:
+ title = self._decodeHtmlEntities('%s: %s' % (clip['section'],
clip['title']))
+ else:
+ title = self._decodeHtmlEntities(clip['title'])
+ date = datetime.date.fromtimestamp(clip['created'])
+
+ item = xbmcgui.ListItem(title, iconImage=clip['img'])
+ item.setInfo('video', {
+ 'title': title,
+ 'studio': ADDON.getAddonInfo('name'),
+ 'plot': self._decodeHtmlEntities(clip['description']),
+ 'date': date.strftime('%d.%m.%Y')
+ })
+
+ item.setProperty('IsPlayable', 'true')
+ item.setProperty('Fanart_Image', FANART)
+ url = PATH + '?id=' + str(clip['id'])
+ xbmcplugin.addDirectoryItem(HANDLE, url, item)
+
+ xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_UNSORTED)
+ xbmcplugin.addSortMethod(HANDLE, xbmcplugin.SORT_METHOD_DATE)
+ xbmcplugin.endOfDirectory(HANDLE)
- def _loadJson(self):
+ def playClip(self, clipId):
try:
- u = urllib2.urlopen(VIDEO_LIST_URL)
- data = u.read()
+ u = urllib2.urlopen(PLAYLIST_URL % clipId)
+ html = u.read()
u.close()
- return data.decode('iso-8859-1')
+
+ m = re.match(".*var releaseUrl = '([^']+)'", html, re.DOTALL)
+ if m: # new style playlist
+ u = urllib2.urlopen(m.group(1))
+ playlist = u.read()
+ u.close()
+
+ m = re.match('.*<video src="([^"]+)"', playlist, re.DOTALL)
+ url = m.group(1)
+ else: # flash playlist
+ u = urllib2.urlopen(FLASH_PLAYLIST_URL % clipId)
+ xml = u.read()
+ u.close()
+
+ m = re.match('.*video="([^"]+)"', xml, re.DOTALL)
+ url = m.group(1)
+
except Exception as ex:
- heading = ADDON.getLocalizedString(random.randint(99980, 99985))
+ heading = buggalo.getRandomHeading()
line1 = ADDON.getLocalizedString(30900)
line2 = ADDON.getLocalizedString(30901)
xbmcgui.Dialog().ok(heading, line1, line2, str(ex))
- return None
+ xbmcplugin.setResolvedUrl(HANDLE, False, xbmcgui.ListItem())
+ return
+
+ item = xbmcgui.ListItem(thumbnailImage=ICON)
+ if url:
+ item.setPath(url)
+
+ xbmcplugin.setResolvedUrl(HANDLE, succeeded=url is not None,
listitem=item)
+
+ def _decodeHtmlEntities(self, string):
+ """Decodes the HTML entities found in the string and returns the
modified string.
+
+ Both decimal (�) and hexadecimal (&x00;) are supported as well as
HTML entities,
+ such as æ
+
+ Keyword arguments:
+ string -- the string with HTML entities
+
+ """
+ if type(string) not in [str, unicode]:
+ return string
+
+ def substituteEntity(match):
+ ent = match.group(3)
+ if match.group(1) == "#":
+ # decoding by number
+ if match.group(2) == '':
+ # number is in decimal
+ return unichr(int(ent))
+ elif match.group(2) == 'x':
+ # number is in hex
+ return unichr(int('0x'+ent, 16))
+ else:
+ # they were using a name
+ cp = name2codepoint.get(ent)
+ if cp:
+ return unichr(cp)
+ else:
+ return match.group()
+
+ entity_re = re.compile(r'&(#?)(x?)(\w+);')
+ return entity_re.subn(substituteEntity, string)[0]
if __name__ == '__main__':
@@ -120,13 +171,14 @@ if __name__ == '__main__':
FANART = os.path.join(ADDON.getAddonInfo('path'), 'fanart.jpg')
ICON = os.path.join(ADDON.getAddonInfo('path'), 'icon.png')
+ buggalo.SUBMIT_URL = 'http://tommy.winther.nu/exception/submit.php'
try:
tv2News = TV2NewsAddon()
- if PARAMS.has_key('idx'):
- tv2News.listCategory(int(PARAMS['idx'][0]))
- elif PARAMS.has_key('clip'):
- tv2News.playClip(PARAMS['clip'][0])
+ if 'tag' in PARAMS:
+ tv2News.listClips(PARAMS['tag'][0])
+ elif 'id' in PARAMS:
+ tv2News.playClip(PARAMS['id'][0])
else:
- tv2News.listCategories()
+ tv2News.listTags()
except Exception:
- buggalo.onExceptionRaised()
+ buggalo.onExceptionRaised()
\ No newline at end of file
diff --git a/plugin.video.news.tv2.dk/addon.xml
b/plugin.video.news.tv2.dk/addon.xml
index e147d81..b28fb07 100644
--- a/plugin.video.news.tv2.dk/addon.xml
+++ b/plugin.video.news.tv2.dk/addon.xml
@@ -1,18 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
-<addon id="plugin.video.news.tv2.dk" version="1.0.2" name="TV2 NEWS"
provider-name="twinther [[email protected]]">
+<addon id="plugin.video.news.tv2.dk" version="1.1.0" name="TV2 NEWS"
provider-name="twinther">
<requires>
<import addon="xbmc.python" version="2.0"/>
<import addon="script.module.simplejson" version="2.0.10"/>
+ <import addon="script.module.buggalo" version="1.1.2"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
</extension>
<extension point="xbmc.addon.metadata">
<summary lang="en">TV2 NEWS</summary>
- <summary lang="da">TV2 NEWS</summary>
- <description lang="en">Watch TV2 NEWS's programs such as Mogensen
& Kristiansen and Presselogen.[CR][CR]If you have comments or suggestions
for this addon, please feel free to participate in the debate on my blog at
http://tommy.winther.nu</description>
- <description lang="da">Se eller gense TV2 NEWS's programmer så som
Mogensen & Kristiansen og Presselogen.[CR][CR]Har du kommentarer, ris eller
ros til denne addon er du velkommen til at deltage i debatten på min blog på
http://tommy.winther.nu</description>
+ <summary lang="da">TV2 Nyhederne</summary>
+ <description lang="en">Watch latest news and news magazines from TV2
NEWS.[CR][CR]If you have comments or suggestions for this addon, please feel
free to participate in the debate on my blog at
http://tommy.winther.nu</description>
+ <description lang="da">Se seneste nyheder og newsmagasiner fra TV2
NEWS.[CR][CR]Har du kommentarer, ris eller ros til denne addon er du velkommen
til at deltage i debatten på min blog på http://tommy.winther.nu</description>
<license>GPL 2.0</license>
<platform>all</platform>
+ <website>http://tommy.winther.nu</website>
+
<source>https://github.com/xbmc-danish-addons/plugin.video.news.tv2.dk</source>
+ <email>[email protected]</email>
+ <language>da</language>
</extension>
</addon>
diff --git a/plugin.video.news.tv2.dk/changelog.txt
b/plugin.video.news.tv2.dk/changelog.txt
index aeb9b5b..2eec15b 100644
--- a/plugin.video.news.tv2.dk/changelog.txt
+++ b/plugin.video.news.tv2.dk/changelog.txt
@@ -1,3 +1,6 @@
+[B]Version 1.1.0 - 2013-04-03[/B]
+- Rewrite due to site changes
+
[B]Version 1.0.2 - 2012-01-31[/B]
- First version submitted for official repository
- Improved error handling with option for the user to submit exceptions/bugs
diff --git a/plugin.video.news.tv2.dk/resources/language/Danish/strings.xml
b/plugin.video.news.tv2.dk/resources/language/Danish/strings.xml
index d25d6a5..20835ee 100644
--- a/plugin.video.news.tv2.dk/resources/language/Danish/strings.xml
+++ b/plugin.video.news.tv2.dk/resources/language/Danish/strings.xml
@@ -1,19 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
+ <string id="30000">Seneste nyheder</string>
+ <string id="30001">Mest sete</string>
+ <string id="30002">06:00</string>
+ <string id="30003">09:00</string>
+ <string id="30004">17:00</string>
+ <string id="30005">19:00</string>
+ <string id="30006">22:00</string>
+ <string id="30007">Station 2</string>
+ <string id="30008">Newsmagasiner</string>
+
<string id="30900">Der er sket en fejl i kommunikationen med TV2
NEWS.</string>
<string id="30901">Prøv igen senere. Fejlen er:</string>
-
- <string id="99980">Game over, man! [I]Game over![/I]</string>
- <string id="99981">You can't handle the truth!</string>
- <string id="99982">Danger Will Robinson</string>
- <string id="99983">Why does it cry, Sméagol?</string>
- <string id="99984">Houston, we have a problem...</string>
- <string id="99985">E.T. phone home</string>
-
- <string id="99990">Der er desværre opstået en fejl i addon'en.</string>
- <string id="99991">Du kan hjælpe med at løse fejlen ved at indsende
en</string>
- <string id="99992">fejlrapport. Der sendes ikke personlige
oplysninger.</string>
- <string id="99993">Indsend fejlrapport</string>
- <string id="99994">Indsend ikke</string>
- <string id="99995">Tak!</string>
</strings>
diff --git a/plugin.video.news.tv2.dk/resources/language/English/strings.xml
b/plugin.video.news.tv2.dk/resources/language/English/strings.xml
index 010a6d4..e1d185f 100644
--- a/plugin.video.news.tv2.dk/resources/language/English/strings.xml
+++ b/plugin.video.news.tv2.dk/resources/language/English/strings.xml
@@ -1,19 +1,15 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<strings>
+ <string id="30000">Latest news</string>
+ <string id="30001">Most watched</string>
+ <string id="30002">06:00</string>
+ <string id="30003">09:00</string>
+ <string id="30004">17:00</string>
+ <string id="30005">19:00</string>
+ <string id="30006">22:00</string>
+ <string id="30007">Station 2</string>
+ <string id="30008">News magazines</string>
+
<string id="30900">There was an error while communication with
TV2.</string>
<string id="30901">Please try again later. Error message is:</string>
-
- <string id="99980">Game over, man! [I]Game over![/I]</string>
- <string id="99981">You can't handle the truth!</string>
- <string id="99982">Danger Will Robinson</string>
- <string id="99983">Why does it cry, Sméagol?</string>
- <string id="99984">Houston, we have a problem...</string>
- <string id="99985">E.T. phone home</string>
-
- <string id="99990">Unfortunately an error occurred in the addon.</string>
- <string id="99991">You can help with fixing the problem by
submitting</string>
- <string id="99992">an error report. No personal information is
sent.</string>
- <string id="99993">Submit error report</string>
- <string id="99994">Don't submit</string>
- <string id="99995">Thank you!</string>
</strings>
-----------------------------------------------------------------------
Summary of changes:
plugin.video.news.tv2.dk/addon.py | 192 +++++++++++++-------
plugin.video.news.tv2.dk/addon.xml | 13 +-
plugin.video.news.tv2.dk/buggalo.py | 117 ------------
plugin.video.news.tv2.dk/changelog.txt | 3 +
.../resources/language/Danish/strings.xml | 24 +--
.../resources/language/English/strings.xml | 24 +--
6 files changed, 154 insertions(+), 219 deletions(-)
delete mode 100644 plugin.video.news.tv2.dk/buggalo.py
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons