Created
July 20, 2011 18:10
-
-
Save jbeluch/1095519 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from xbmcswift import Plugin, download_page | |
from BeautifulSoup import BeautifulSoup as BS, SoupStrainer as SS | |
from urlparse import urljoin | |
import re | |
__plugin_name__ = 'Academic Earth' | |
__plugin_id__ = 'plugin.video.academicearth' | |
plugin = Plugin(__plugin_name__, __plugin_id__) | |
BASE_URL = 'http://academicearth.org' | |
def full_url(path): | |
return urljoin(BASE_URL, path) | |
# Default view | |
@plugin.route('/') | |
def show_lectures(): | |
COURSE_URL = 'http://academicearth.org/courses/introduction-to-computer-science-and-programming' | |
src = download_page(COURSE_URL) | |
html = BS(src) | |
parent_div = html.find('div', {'class': 'results-list'}) | |
lectures = parent_div.findAll('li') | |
items = [] | |
for lecture in lectures: | |
item = {} | |
item['label'] = lecture.h4.a.string | |
item['url'] = plugin.url_for('watch_lecture', url=full_url(lecture.h4.a['href'])) | |
item['thumbnail'] = full_url(lecture.find('img', {'class': 'thumb-144'})['src']) | |
item['info'] = {} | |
item['info']['plot'] = lecture.p.string | |
items.append(item) | |
from pprint import pprint | |
pprint(items) | |
@plugin.route('/watch/<url>') | |
def watch_lecture(url): | |
pass | |
if __name__ == '__main__': | |
plugin.run() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment