The branch, dharma has been updated
via 9d9afe6c219a9619da5e8a1ee61be0a61fd465b2 (commit)
from bc6bcf910998cbbe503a9ddd9e4da2e15d713ec4 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=9d9afe6c219a9619da5e8a1ee61be0a61fd465b2
commit 9d9afe6c219a9619da5e8a1ee61be0a61fd465b2
Author: spiff <[email protected]>
Date: Wed Jun 15 18:14:47 2011 +0200
[plugin.video.classiccinema] updated to version 0.8
diff --git a/plugin.video.classiccinema/addon.py
b/plugin.video.classiccinema/addon.py
index 1a7c3f3..604800b 100755
--- a/plugin.video.classiccinema/addon.py
+++ b/plugin.video.classiccinema/addon.py
@@ -13,182 +13,79 @@
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-'''
-Classic Cinema XBMC Plugin
-Watch movies found on http://www.classiccinemaonline.com
-
-author: Jonathan Beluch
-project url: https://github.com/jbeluch/xbmc-classic-cinema
-git url: git://github.com/jbeluch/xbmc-classic-cinema.git
-version: 0.7.1
-
-Please report any issues at
https://github.com/jbeluch/xbmc-classic-cinema/issues
-'''
-
-from resources.lib.xbmcvideoplugin import XBMCVideoPlugin,
XBMCVideoPluginHandler
-from resources.lib.xbmccommon import (urlread, async_urlread, DialogProgress,
- parse_url_qs, XBMCVideoPluginException)
-from urllib import urlencode
+from resources.lib.xbmcswift.plugin import XBMCSwiftPlugin
+from resources.lib.xbmcswift.common import download_page
+from resources.lib.xbmcswift.getflashvideo import get_flashvideo_url
from BeautifulSoup import BeautifulSoup as BS, SoupStrainer as SS
-import resources.lib.googlevideo as gv
+from urlparse import urljoin
import re
-import urlparse
-try:
- import json
-except ImportError:
- import simplejson as json
-
-PLUGIN_NAME = 'Classic Cinema'
-PLUGIN_ID = 'plugin.video.classiccinema'
-
-class BasePluginHandler(XBMCVideoPluginHandler):
- base_url = 'http://www.classiccinemaonline.com'
- genres_url = 'http://www.classiccinemaonline.com/1/index.php'
-
- def urljoin(self, path):
- return urlparse.urljoin(self.base_url, path)
-
-
-class DisplayGenresHandler(BasePluginHandler):
- '''Handler for parsing genres from
http://www.classiccinemaonline.com/1/index.php'''
- def run(self):
- src = urlread(self.genres_url)
- #fix terrible html so beautiful soup doesn't barf
- src = src.replace('</font color>', '</font>')
- src = src.replace(r'<ol class=\"latestnews \">', '<ol
class="latestnews">')
-
- div_tag = BS(src, parseOnlyThese=SS('div', {'id': 'rightcol'}))
- dirs = [{'name': a.span.string.replace('&', '&'),
- 'url': self.urljoin(a['href']).replace('&', '&'),
- 'mode': '1'}
- for a in div_tag.find('div', {'class': 'moduletable'})('a')]
- app.add_dirs(dirs)
-
-
-class DisplayMoviesHandler(BasePluginHandler):
- '''Handler for parsing movies from a genre page.
-
- Example genre url:
-
http://www.classiccinemaonline.com/1/index.php?option=com_content&view=category&id=88&Itemid=760
- '''
- def run(self):
- # Initialize the progress dialog right away. If we wait too long, then
- # the auto generated popup shows and it has the caption of 'Retrieving
items....'
- self.dp = DialogProgress(app.getls(30010))
-
- # By default, classiccinema shows only 10 movies, so must send a POST
request
- # to the same url, but include the id and limit parameters
- #POST data, limit=0 returns all items
- params = parse_url_qs(self.args['url'])
- data = {'id': params['id'], 'limit': '0'}
- src = urlread(self.args['url'], urlencode(data))
-
- tr_tags = BS(src, parseOnlyThese=SS('tr', {'class':
re.compile('sectiontableentry')}))
-
- #urls for each of the movies pages
- urls = [self.urljoin(tr.a['href']) for tr in tr_tags]
-
- #get scraped info for each of the movie pages
- infos = self.parse_movie_pages(urls)
-
- #build dirs for sending to add_dirs()
- dirs = [{'name': info['info']['title'],
- 'url': url.replace('&', '&'),
- 'tn': info.get('tn', ''),
- 'mode': '2',
- 'info': info['info']} for url, info in zip(urls, infos)]
-
- #filter dirs which don't have a url
- dirs = filter(lambda d: d['url'] != None, dirs)
-
- #sort dirs by name and add to UI
- sorted_dirs = sorted(dirs, key=lambda d: d['name'])
- app.add_resolvable_dirs(sorted_dirs)
-
- def parse_movie_pages(self, urls):
- self.dp.set_num_items(len(urls))
- srcs = async_urlread(urls, self.dp)
- return map(self.parse_movie_page, srcs)
-
- def parse_movie_page(self, src):
- '''Scrapes a movie page and returns a dict with info'''
- #results dict
- res = {'info': {}}
-
- #get <meta> tags and parse title and description
- meta_tags = BS(src, parseOnlyThese=SS('meta'))
-
- #set default title so the UI listitem isn't blank if we don't match
anything
- res['info']['title'] = app.getls(30011)
-
- #attempt to parse title and year if it exists
- title_year = meta_tags.find('meta', {'name': 'title'})
- if title_year:
- #set title to the entire content attribute of the meta tag in case
- #we don't match a title and a year below
- res['info']['title'] = title_year['content']
-
- #attempt to match a title and a year:
- # 'The Lone Ranger (2004)'
- p = r'(?P<title>.+?)\((?P<year>\d+)\)'
- m = re.match(p, title_year['content'])
- if m:
- res['info']['title'] = m.group('title')
- res['info']['year'] = int(m.group('year'))
-
- #attempt to parse the description meta tag if it exists
- description = meta_tags.find('meta', {'name': 'description'})
- if description:
- res['info']['plot'] = description['content']
-
- #get the poster image to use as thumbnail if available on page
- img_tags = BS(src, parseOnlyThese=SS('img', {'src':
re.compile('/posters/')}))
- if len(img_tags) > 0:
- res['tn'] = self.urljoin(img_tags.find('img')['src'])
-
- return res
-
-class PlayMovieHandler(BasePluginHandler):
- '''Handles playing of movies. The site contains movies embedded from
- google video and archive.org.
- '''
- def get_googlevideo_url(self, src):
- embed_tags = BS(src, parseOnlyThese=SS('embed'))
- url = gv.get_flv_url(url=embed_tags.find('embed')['src'])
- if not url:
- raise XBMCVideoPluginException(app.getls(30013))
- return url
-
- def get_archive_url(self, src):
- embed_tags = BS(src, parseOnlyThese=SS('embed'))
- flashvars = embed_tags.find('embed')['flashvars']
- obj = json.loads(flashvars.split('=', 1)[1].replace("'", '"'))
- base_url = obj['clip']['baseUrl']
- path = obj['playlist'][1]['url']
- return urlparse.urljoin(base_url, path)
+from urllib import urlencode
- def run(self):
- src = urlread(self.args['url'])
+__plugin__ = 'Classic Cinema'
+__plugin_id__ = 'plugin.video.classiccinema'
+
+plugin = XBMCSwiftPlugin(__plugin__, __plugin_id__)
+#plugin.settings(plugin_cache=False, http_cache=False)
+
+BASE_URL = 'http://www.classiccinemaonline.com'
+def full_url(path):
+ return urljoin(BASE_URL, path)
+
[email protected]('/', default=True)
+def show_browse_methods():
+ '''Default view. Displays the different ways to browse the site.'''
+ items = [
+ {'label': 'Movies', 'url': plugin.url_for('show_movie_genres')},
+ {'label': 'Silent Films', 'url': plugin.url_for('show_silent_genres')},
+ {'label': 'Serials', 'url': plugin.url_for('show_serials')},
+ ]
+ return plugin.add_items(items)
+
[email protected]('/movies/', name='show_movie_genres',
path='index.php/movie-billboards')
[email protected]('/silents/', name='show_silent_genres',
path='index.php/silent-films-menu')
[email protected]('/serials/', name='show_serials', path='index.php/serials')
+def show_genres(path):
+ '''For movies and silent films, will display genres. For serials, will
display serial names.'''
+ src = download_page(full_url(path))
+ html = BS(src)
+
+ a_tags = html.findAll('a', {'class': 'category'})
+ items = [{'label': a.string,
+ 'url': plugin.url_for('show_movies', url=full_url(a['href'])),
+ } for a in a_tags]
+ return plugin.add_items(items)
+
[email protected]('/movies/<url>/')
+def show_movies(url):
+ '''Displays available movies for a given url.'''
+ # Need to POST to url in order to get back all results and not be limited
to 10.
+ # Currently can hack using only the 'limit=0' querystring, other params
aren't needed.
+ data = {'limit': '0'}
+ src = download_page(url, urlencode(data))
+ html = BS(src)
+
+ trs = html.findAll('tr', {'class': lambda c: c in ['even', 'odd']})
+
+ items = [{'label': tr.a.string,
+ 'url': plugin.url_for('show_movie', url=full_url(tr.a['href'])),
+ 'is_folder': False,
+ 'is_playable': True,
+ 'info': {'title': tr.a.string, },
+ } for tr in trs]
+ return plugin.add_items(items)
+
[email protected]('/watch/<url>/')
+def show_movie(url):
+ '''Show the video.'''
+ src = download_page(url)
+ url = get_flashvideo_url(src)
+ return plugin.set_resolved_url(url)
- #there are 2 kinds of videos on the site, google video and archive.org
- if src.find('googleplayer') > 0:
- url = self.get_googlevideo_url(src)
- elif src.find('flowplayer') > 0:
- url = self.get_archive_url(src)
- else:
- raise XBMCVideoPluginException(app.getls(30012))
+if __name__ == '__main__':
+ plugin.run()
- app.set_resolved_url(url)
+ # For testing
+ #plugin.interactive()
+ #plugin.crawl()
-if __name__ == '__main__':
- settings = {'default_handler': DisplayGenresHandler,
- 'plugin_id': PLUGIN_ID,
- 'plugin_name': PLUGIN_NAME}
- app = XBMCVideoPlugin(
- [('0', DisplayGenresHandler),
- ('1', DisplayMoviesHandler),
- ('2', PlayMovieHandler),
- ], **settings
- )
- app.run()
diff --git a/plugin.video.classiccinema/addon.xml
b/plugin.video.classiccinema/addon.xml
index 2275828..ca21a51 100644
--- a/plugin.video.classiccinema/addon.xml
+++ b/plugin.video.classiccinema/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.classiccinema" name="Classic Cinema" version="0.7.1"
provider-name="jbel">
+<addon id="plugin.video.classiccinema" name="Classic Cinema" version="0.8"
provider-name="jbel">
<requires>
<import addon="xbmc.python" version="1.0"/>
<import addon="script.module.beautifulsoup" version="3.0.8"/>
@@ -12,6 +12,5 @@
<summary>Classic Cinema Video Addon</summary>
<description>Watch online video movies found at
http://www.classiccinemaonline.com. The site aggregates old movies and tv
shows found on google video and archive.org.</description>
<disclaimer/>
- <broken>Site changes</broken>
</extension>
</addon>
diff --git a/plugin.video.classiccinema/resources/language/English/strings.xml
b/plugin.video.classiccinema/resources/language/English/strings.xml
index 105aa7b..8c5279c 100644
--- a/plugin.video.classiccinema/resources/language/English/strings.xml
+++ b/plugin.video.classiccinema/resources/language/English/strings.xml
@@ -1,8 +1,8 @@
-<?xml version="1.0" encoding="utf-8" standalone="yes"?>
-<strings>
- <!--<string id="30000">Classic Cinema Online</string>-->
- <string id="30010">Parsing movie information</string>
- <string id="30011">UNKNOWN TITLE</string>
- <string id="30012">This video is not currently supported.</string>
- <string id="30013">Error getting video from Google Video.</string>
-</strings>
+<?xml version="1.0" encoding="utf-8" standalone="yes"?>
+<strings>
+ <!--<string id="30000">Classic Cinema Online</string>-->
+ <string id="30010">Parsing movie information</string>
+ <string id="30011">UNKNOWN TITLE</string>
+ <string id="30012">This video is not currently supported.</string>
+ <string id="30013">Error getting video from Google Video.</string>
+</strings>
-----------------------------------------------------------------------
Summary of changes:
plugin.video.classiccinema/addon.py | 241 ++++---------
plugin.video.classiccinema/addon.xml | 3 +-
.../resources/language/English/strings.xml | 16 +-
.../resources/lib/googlevideo.py | 47 ---
.../resources/lib/xbmcswift}/__init__.py | 0
.../lib/{xbmccommon.py => xbmcswift/common.py} | 7 +
.../resources/lib/xbmcswift/extra.py | 107 ++++++
.../resources/lib/xbmcswift/getflashvideo.py | 102 ++++++
.../resources/lib/xbmcswift/plugin.py | 376 ++++++++++++++++++++
.../resources/lib/xbmcvideoplugin.py | 176 ---------
10 files changed, 670 insertions(+), 405 deletions(-)
delete mode 100644 plugin.video.classiccinema/resources/lib/googlevideo.py
copy {plugin.audio.soundcloud/oauth2/clients =>
plugin.video.classiccinema/resources/lib/xbmcswift}/__init__.py (100%)
rename plugin.video.classiccinema/resources/lib/{xbmccommon.py =>
xbmcswift/common.py} (97%)
create mode 100644 plugin.video.classiccinema/resources/lib/xbmcswift/extra.py
create mode 100644
plugin.video.classiccinema/resources/lib/xbmcswift/getflashvideo.py
create mode 100644 plugin.video.classiccinema/resources/lib/xbmcswift/plugin.py
delete mode 100644 plugin.video.classiccinema/resources/lib/xbmcvideoplugin.py
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons