The branch, dharma has been updated
via 642b3f7a61dec0192fa6938f296b7e5c70c5d763 (commit)
from 0811569621439d46a0a5d878805ccd00df13c523 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=642b3f7a61dec0192fa6938f296b7e5c70c5d763
commit 642b3f7a61dec0192fa6938f296b7e5c70c5d763
Author: spiff <[email protected]>
Date: Thu Mar 29 19:15:02 2012 +0200
[plugin.video.khanacademy] updated to version 0.4.2
diff --git a/plugin.video.khanacademy/addon.py
b/plugin.video.khanacademy/addon.py
index 4bf91ee..0e851e8 100755
--- a/plugin.video.khanacademy/addon.py
+++ b/plugin.video.khanacademy/addon.py
@@ -25,6 +25,7 @@ from BeautifulSoup import BeautifulSoup as BS
from resources.lib.khan import KhanData, download_playlists_json
from resources.lib.cache import get_cached_data, put_cached_data
+
__plugin_name__ = 'Khan Academy'
__plugin_id__ = 'plugin.video.khanacademy'
plugin = Plugin(__plugin_name__, __plugin_id__, __file__)
@@ -37,6 +38,7 @@ BASE_URL = 'http://www.khanacademy.org'
def make_cache_dirs():
'''Make plugin_id and .cache dirs for the current plugin.'''
def make_if_not_exist(path):
+ print path
if not os.path.exists(path):
os.mkdir(path)
cache_root = xbmc.translatePath('special://profile/addon_data')
diff --git a/plugin.video.khanacademy/addon.xml
b/plugin.video.khanacademy/addon.xml
index 1934f3d..c8f59ed 100644
--- a/plugin.video.khanacademy/addon.xml
+++ b/plugin.video.khanacademy/addon.xml
@@ -1,10 +1,11 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.khanacademy" name="Khan Academy" version="0.4.1"
provider-name="Jonathan Beluch (jbel)">
+<addon id="plugin.video.khanacademy" name="Khan Academy" version="0.4.2"
provider-name="Jonathan Beluch (jbel)">
<requires>
<import addon="xbmc.python" version="1.0"/>
<import addon="script.module.beautifulsoup" version="3.0.8"/>
<import addon="script.module.xbmcswift" version="0.2.0"/>
<import addon="script.module.simplejson" version="2.0.10"/>
+ <inport addon="plugin.video.youtube" version="2.1.4"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
diff --git a/plugin.video.khanacademy/changelog.txt
b/plugin.video.khanacademy/changelog.txt
index ea4538a..2fabeca 100644
--- a/plugin.video.khanacademy/changelog.txt
+++ b/plugin.video.khanacademy/changelog.txt
@@ -1,3 +1,7 @@
+Version 0.4.2
+* Update plugin to reflect Khan API changes
+* Use youtube for playback when an mp4 isn't available
+
Version 0.4.1
* Fix syntax error
diff --git a/plugin.video.khanacademy/resources/lib/khan.py
b/plugin.video.khanacademy/resources/lib/khan.py
index 7c89197..cf70413 100644
--- a/plugin.video.khanacademy/resources/lib/khan.py
+++ b/plugin.video.khanacademy/resources/lib/khan.py
@@ -6,15 +6,9 @@ import time
import urllib
-def api_url():
- '''Returns the API url with a timestamp url paremeter set to
- int(time.time() * 1000)
- '''
- return ('http://www.khanacademy.org/api/v1/playlists/library/compact?v=%d'
%
- int(time.time() * 1000))
-
-
-API_URL = api_url()
+# Hierarchical list
+API_URL = 'http://www.khanacademy.org/api/v1/playlists/library'
+YOUTUBE_PLUGIN_PTN =
'plugin://plugin.video.youtube/?action=play_video&videoid=%s'
def download_playlists_json():
@@ -27,28 +21,53 @@ def download_playlists_json():
return resp
+def _try_parse(_json, *args):
+ '''Returns the parsed value or None if doesn't exist. The provided args
+ correspond to dictionary keys.
+
+ >>> _json = {'foo': {'bar': 'baz'}}
+ >>> _try_parse(_json, 'foo', 'bar')
+ baz
+ >>> _try_parse(_json, 'foo', 'missingkey')
+ None
+ '''
+ try:
+ for key in args:
+ _json = _json[key]
+ return _json
+ except TypeError:
+ return None
+
+
class Video(object):
def __init__(self, _json):
- self.key_id = _json['key_id']
+ #self.key_id = _json['key_id']
self.title = _json['title']
self.readable_id = _json['readable_id']
+ self.youtube_url = YOUTUBE_PLUGIN_PTN % _json['youtube_id']
+ self.mp4_url = _try_parse(_json, 'download_urls', 'mp4')
+ self.thumbnail = _try_parse(_json, 'download_urls', 'png')
+
def to_listitem(self, plugin):
'''Returns a dict suitable for passing to xbmcswift.plugin.add_items'''
- return {
+ item = {
'label': self.title,
- 'url': plugin.url_for('play_video', video_slug=self.readable_id),
+ 'url': self.mp4_url or self.youtube_url,
'is_playable': True,
'is_folder': False,
}
+ if self.thumbnail:
+ item['thumbnail'] = self.thumbnail
+ return item
class Playlist(object):
def __init__(self, _json):
- self.slugged_title = _json['slugged_title']
self.title = _json['title']
+ self.description = _json['description']
self.videos = [Video(item) for item in _json['videos']]
def __iter__(self):
@@ -59,6 +78,7 @@ class Playlist(object):
return {
'label': self.title,
'url': plugin.url_for('show_category', category=self.title),
+ 'info': {'plot': self.description},
}
-----------------------------------------------------------------------
Summary of changes:
plugin.video.khanacademy/addon.py | 2 +
plugin.video.khanacademy/addon.xml | 3 +-
plugin.video.khanacademy/changelog.txt | 4 ++
plugin.video.khanacademy/resources/lib/khan.py | 46 +++++++++++++++++-------
4 files changed, 41 insertions(+), 14 deletions(-)
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
This SF email is sponsosred by:
Try Windows Azure free for 90 days Click Here
http://p.sf.net/sfu/sfd2d-msazure
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons