The branch, eden has been updated
via 8625033fed365f5101a4a7df211b4e87cc25dafb (commit)
from 0767ff3b7f3d2bb74b161f09b9cea3221fce791d (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=8625033fed365f5101a4a7df211b4e87cc25dafb
commit 8625033fed365f5101a4a7df211b4e87cc25dafb
Author: spiff <[email protected]>
Date: Thu Mar 29 19:21:10 2012 +0200
[plugin.video.academicearth] updated to version 1.2.1
diff --git a/plugin.video.academicearth/addon.py
b/plugin.video.academicearth/addon.py
index ae510c2..0a5766c 100755
--- a/plugin.video.academicearth/addon.py
+++ b/plugin.video.academicearth/addon.py
@@ -1,22 +1,22 @@
#!/usr/bin/env python
-# Copyright 2011 Jonathan Beluch.
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see <http://www.gnu.org/licenses/>.
+# Copyright 2011 Jonathan Beluch.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
from xbmcswift import Plugin, download_page
from BeautifulSoup import BeautifulSoup as BS, SoupStrainer as SS
from urlparse import urljoin
-from resources.lib.getflashvideo import YouTube
+from resources.lib.videohosts import resolve
import re
from resources.lib.favorites import favorites
@@ -33,7 +33,7 @@ def full_url(path):
return urljoin(BASE_URL, path)
def htmlify(url):
- return BS(download_page(url))
+ return BS(download_page(url), convertEntities=BS.HTML_ENTITIES)
def filter_free(items):
return filter(lambda item: not item['label'].startswith('Online'), items)
@@ -53,46 +53,63 @@ def show_index():
@plugin.route('/subjects/', url=full_url('subjects'))
def show_subjects(url):
html = htmlify(url)
- parent_div = html.find('div', {'class': 'institution-list'}).parent
- subjects = parent_div.findAll('li')
+ subjects = html.findAll('a', {'class': 'subj-links'})
items = [{
- 'label': subject.a.string,
- 'url': plugin.url_for('show_topics', url=full_url(subject.a['href'])),
+ 'label': subject.div.string.strip(),
+ 'url': plugin.url_for('show_topics', url=full_url(subject['href'])),
} for subject in subjects]
# Filter out non-free subjects
- items = filter(lambda item: not item['label'].startswith('Online'), items)
+ items = filter(lambda item: item['label'] != 'Courses for Credit', items)
return plugin.add_items(items)
@plugin.route('/universities/', url=full_url('universities'))
def show_universities(url):
html = htmlify(url)
- parent_div = html.find('div', {'class': 'institution-list'})
- universities = parent_div.findAll('a')
+ universities = html.findAll('a', {'class': 'subj-links'})
items = [{
- 'label': item.string,
+ 'label': item.div.string.strip(),
'url': plugin.url_for('show_topics', url=full_url(item['href'])),
} for item in universities]
return plugin.add_items(items)
[email protected]('/instructors/', url=full_url('speakers'))
-def show_instructors(url):
[email protected]('/instructors/', page='1')
[email protected]('/instructors/<page>/', name='show_instructors_page')
+def show_instructors(page):
+ def get_pagination(html):
+ items = []
+ previous = html.find('span', {'class': 'tab-nav-arrow
tab-nav-arrow-l'})
+ if int(page) > 1:
+ items.append({
+ 'label': '< Previous',
+ 'url': plugin.url_for('show_instructors_page',
page=str(int(page)-1)),
+ })
+
+ next = html.find('span', {'class': 'tab-nav-arrow tab-nav-arrow-r'})
+ if next:
+ items.append({
+ 'label': 'Next >',
+ 'url': plugin.url_for('show_instructors_page',
page=str(int(page)+1)),
+ })
+ return items
+
+ url = full_url('speakers/page:%s' % page)
html = htmlify(url)
- uls = html.findAll('ul', {'class': 'professors-list'})
- professors = uls[0].findAll('li') + uls[1].findAll('li')
+ speakers = html.findAll('div', {'class': 'blue-hover'})
items = [{
- 'label': item.a.string,
+ 'label': item.div.string,
'url': plugin.url_for('show_instructor_courses',
url=full_url(item.a['href'])),
- } for item in professors]
+ } for item in speakers]
- return plugin.add_items(items)
+ # Add pagination
+ return plugin.add_items(get_pagination(html) + items)
[email protected]('/instructors/top/', url=BASE_URL)
[email protected]('/topinstructors/', url=BASE_URL)
def show_top_instructors(url):
html = htmlify(url)
menu = html.find('ul', {'id': 'categories-accordion'})
@@ -117,7 +134,7 @@ def show_playlists(url):
} for item in playlists]
return plugin.add_items(items)
-
+
@plugin.route('/instructors/courses/<url>/')
@@ -147,21 +164,18 @@ def show_instructor_courses(url):
@plugin.route('/topics/<url>/')
def show_topics(url):
- # Filter our topcis taht start with 'Online'
- # if we only have one topic, redirect to teh courses/lectures page
html = htmlify(url)
- parent_div = html.find('div', {'class': 'results-side'})
- topics = parent_div.findAll('li')
+ topics = html.findAll('a', {'class': 'tab-details-link '})
items = [{
- 'label': topic.a.string,
- 'url': plugin.url_for('show_courses', url=full_url(topic.a['href'])),
+ 'label': topic.string,
+ 'url': plugin.url_for('show_courses', url=full_url(topic['href'])),
} for topic in topics]
# Filter out non free topics
items = filter_free(items)
- # If we only have one item, just redirect to the show_topics page,
+ # If we only have one item, just redirect to the show_topics page,
# there's no need to display a single item in the list
if len(items) == 1:
return plugin.redirect(items[0]['url'])
@@ -169,56 +183,48 @@ def show_topics(url):
return plugin.add_items(items)
@plugin.route('/courses/<url>/')
-def show_courses(url):
[email protected]('/courses/<url>/<page>/', name='show_courses_page')
+def show_courses(url, page='1'):
def get_pagination(html):
items = []
- pagination = html.find('ul', {'class': 'pagination'})
- if not pagination:
- return items
-
- previous = pagination.find(text='<')
- if previous:
+ if int(page) > 1:
items.append({
'label': '< Previous',
- 'url': plugin.url_for('show_courses',
url=full_url(previous.parent['href'])),
+ 'url': plugin.url_for('show_courses_page', url=url,
page=str(int(page)-1)),
})
- next = pagination.find(text='>')
+ next = html.find('span', {'class': 'tab-nav-arrow tab-nav-arrow-r'})
if next:
items.append({
'label': 'Next >',
- 'url': plugin.url_for('show_courses',
url=full_url(next.parent['href'])),
+ 'url': plugin.url_for('show_courses_page', url=url,
page=str(int(page)+1)),
})
return items
- html = htmlify(url)
- parent_div = html.find('div', {'class': 'video-results'})
-
- # Need to filter out <li>'s that are only used for spacing.
- # Spacing li's look like <li class="break">
- courses_lectures = parent_div.findAll('li', {'class': lambda c: c !=
'break'})
+ html = htmlify('%s/page:%s' % (url, page))
+ courses_lectures = html.findAll('div', {'class': 'thumb'})
# Some of the results can be a standalone lecture, not a link to a course
# page. We need to display these separately.
- courses = filter(lambda item: '/courses/' in item.h3.a['href'],
courses_lectures)
- lectures = filter(lambda item: '/lectures/' in item.h3.a['href'],
courses_lectures)
+ courses = filter(lambda item: '/courses/' in item.a['href'],
courses_lectures)
+ lectures = filter(lambda item: '/lectures/' in item.a['href'],
courses_lectures)
course_items = [{
- 'label': item.h3.a.string,
- 'url': plugin.url_for('show_lectures',
url=full_url(item.h3.a['href'])),
+ 'label': item.parent.find('a', {'class':
'editors-picks-title'}).string,
+ 'url': plugin.url_for('show_lectures', url=full_url(item.a['href'])),
'thumbnail': full_url(item.find('img', {'class': 'thumb-144'})['src']),
} for item in courses]
lecture_items = [{
- 'label': '%s: %s' % (plugin.get_string(30206),item.h3.a.string),
- 'url': plugin.url_for('watch_lecture',
url=full_url(item.h3.a['href'])),
+ 'label': '%s: %s' % (plugin.get_string(30206),
+ item.parent.find('a', {'class': 'editors-picks-title'}).string),
+ 'url': plugin.url_for('watch_lecture', url=full_url(item.a['href'])),
'thumbnail': full_url(item.find('img', {'class': 'thumb-144'})['src']),
'is_folder': False,
'is_playable': True,
} for item in lectures]
pagination_items = get_pagination(html)
-
return plugin.add_items(pagination_items + course_items + lecture_items)
@plugin.route('/lectures/<url>/')
@@ -237,7 +243,7 @@ def show_lectures(url):
url=full_url(path)['href']
))
return
-
+
html = htmlify(url)
parent_div = html.find('div', {'class': 'results-list'})
lectures = parent_div.findAll('li')
@@ -267,26 +273,20 @@ def show_lectures(url):
@plugin.route('/watch/<url>/')
def watch_lecture(url):
src = download_page(url)
- # There are 2 different hosts for lectures.
- # blip.tv and youtube.
-
- # Attempt to match blip.tv
- flv_ptn = re.compile(r'flashVars.flvURL = "(.+?)"')
- m = flv_ptn.search(src)
- if m:
- return plugin.set_resolved_url(m.group(1))
- # If we're still here attempt to match youtube
- #videoid_ptn =
- ytid_ptn = re.compile(r'flashVars.ytID = "(.+?)"')
- m = ytid_ptn.search(src)
+ # First attempt to look for easy flv urls
+ pattern = re.compile(r'flashVars.flvURL = "(.+?)"')
+ m = pattern.search(src)
if m:
- video_url = YouTube.get_flashvideo_url(videoid=m.group(1))
- return plugin.set_resolved_url(video_url)
+ resolved_url = m.group(1)
+ else:
+ resolved_url = resolve(src)
+ if resolved_url:
+ return plugin.set_resolved_url(resolved_url)
xbmcgui.Dialog().ok(plugin.get_string(30000), plugin.get_string(30400))
raise Exception, 'No video url found. Please alert plugin author.'
-if __name__ == '__main__':
+if __name__ == '__main__':
plugin.run()
diff --git a/plugin.video.academicearth/addon.xml
b/plugin.video.academicearth/addon.xml
index 56d4f7a..ec4a72f 100644
--- a/plugin.video.academicearth/addon.xml
+++ b/plugin.video.academicearth/addon.xml
@@ -1,9 +1,10 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.academicearth" name="Academic Earth" version="1.2.0"
provider-name="Jonathan Beluch (jbel)">
+<addon id="plugin.video.academicearth" name="Academic Earth" version="1.2.1"
provider-name="Jonathan Beluch (jbel)">
<requires>
<import addon="xbmc.python" version="2.0"/>
<import addon="script.module.beautifulsoup" version="3.0.8"/>
<import addon="script.module.xbmcswift" version="0.2.0"/>
+ <import addon="plugin.video.youtube" version="2.9.1"/>
</requires>
<extension point="xbmc.python.pluginsource" library="addon.py">
<provides>video</provides>
diff --git a/plugin.video.academicearth/changelog.txt
b/plugin.video.academicearth/changelog.txt
index 95de44a..308ac98 100644
--- a/plugin.video.academicearth/changelog.txt
+++ b/plugin.video.academicearth/changelog.txt
@@ -1,3 +1,7 @@
+Version 1.2.1
+* Update parsing code to reflect website changes.
+* Add youtube plugin as a requirement.
+
Version 1.2.0
* Updated required versions of xbmcswift and python for Eden.
diff --git a/plugin.video.academicearth/resources/lib/favorites.py
b/plugin.video.academicearth/resources/lib/favorites.py
index d228425..c39f6ec 100644
--- a/plugin.video.academicearth/resources/lib/favorites.py
+++ b/plugin.video.academicearth/resources/lib/favorites.py
@@ -126,7 +126,8 @@ def show_favorites(url):
],
} for item in videos]
- xbmcgui.Dialog().ok(favorites._plugin.get_string(30000),
favorites._plugin.get_string(30404))
+ if not items:
+ xbmcgui.Dialog().ok(favorites._plugin.get_string(30000),
favorites._plugin.get_string(30404))
return favorites.add_items(items)
-----------------------------------------------------------------------
Summary of changes:
plugin.video.academicearth/addon.py | 158 +++++++++---------
plugin.video.academicearth/addon.xml | 3 +-
plugin.video.academicearth/changelog.txt | 4 +
.../resources/lib/favorites.py | 3 +-
.../resources/lib/videohosts.py | 182 ++++++++++++++++++++
5 files changed, 269 insertions(+), 81 deletions(-)
create mode 100644 plugin.video.academicearth/resources/lib/videohosts.py
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