The branch, frodo has been updated
via ddc416326d10a673ae3772e2aaf674b72f47afd0 (commit)
from 6a66640cd4eb800df5d121fd9dc6ca494bace2ef (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=ddc416326d10a673ae3772e2aaf674b72f47afd0
commit ddc416326d10a673ae3772e2aaf674b72f47afd0
Author: Martijn Kaijser <[email protected]>
Date: Sun Oct 13 14:58:53 2013 +0200
[plugin.video.itunes_trailers] 0.2.1
diff --git a/plugin.video.itunes_trailers/addon.py
b/plugin.video.itunes_trailers/addon.py
index d3210d0..df608f5 100644
--- a/plugin.video.itunes_trailers/addon.py
+++ b/plugin.video.itunes_trailers/addon.py
@@ -72,7 +72,7 @@ def show_trailers(movie_title, location):
movie_title, location, play_resolution, download_resolution
)
finish_kwargs = {
- 'sort_methods': ['date', 'playlist_order']
+ 'sort_methods': ['playlist_order']
}
if plugin.get_setting('force_viewmode_trailers', bool):
finish_kwargs['view_mode'] = 'thumbnail'
@@ -191,8 +191,8 @@ def get_trailers(movie_title, location, resolution_play,
resolution_download):
downloads = plugin.get_storage('downloads')
items = []
for i, trailer in enumerate(trailers):
- title = '%s - %s (%s) ' % (
- movie_title, trailer['title'], trailer['duration']
+ title = '%s - %s' % (
+ movie_title, trailer['title']
)
play_url = get_url(trailer['urls'], resolution_play)
download_url = get_url(trailer['urls'], resolution_download)
@@ -205,11 +205,13 @@ def get_trailers(movie_title, location, resolution_play,
resolution_download):
'label': title,
'info': {
'count': i,
- 'date': trailer['date'],
},
'properties': {
'fanart_image': trailer['background'],
},
+ 'stream_info': {
+ 'video': {'duration': trailer['duration']},
+ },
'context_menu': [
(_('download_trailer'), 'XBMC.RunPlugin(%s)' % plugin.url_for(
endpoint='download_trailer',
diff --git a/plugin.video.itunes_trailers/addon.xml
b/plugin.video.itunes_trailers/addon.xml
index 678a060..dd56f23 100644
--- a/plugin.video.itunes_trailers/addon.xml
+++ b/plugin.video.itunes_trailers/addon.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.itunes_trailers" name="Apple iTunes Trailers"
version="0.2.0" provider-name="Tristan Fischer ([email protected])">
+<addon id="plugin.video.itunes_trailers" name="Apple iTunes Trailers"
version="0.2.1" provider-name="Tristan Fischer ([email protected])">
<requires>
<import addon="xbmc.python" version="2.1.0"/>
<import addon="script.module.xbmcswift2" version="2.4.0"/>
diff --git a/plugin.video.itunes_trailers/changelog.txt
b/plugin.video.itunes_trailers/changelog.txt
index a120da7..0ea2f58 100644
--- a/plugin.video.itunes_trailers/changelog.txt
+++ b/plugin.video.itunes_trailers/changelog.txt
@@ -1,3 +1,6 @@
+0.2.1 (13.10.2013)
+- fixed/rewrote TrailerScraper
+
0.2.0 (15.09.2013)
- added plots to (most) movies
- updated translations
diff --git a/plugin.video.itunes_trailers/resources/lib/scraper.py
b/plugin.video.itunes_trailers/resources/lib/scraper.py
index 2dcd5fc..732fd0c 100644
--- a/plugin.video.itunes_trailers/resources/lib/scraper.py
+++ b/plugin.video.itunes_trailers/resources/lib/scraper.py
@@ -114,7 +114,11 @@ class TrailerScraper(object):
TRAILERS_URL = BASE_URL + '/%s/includes/playlists/web.inc'
BACKGROUND_URL = BASE_URL + '/%s/images/background.jpg'
- OVERLAY_URL = BASE_URL + '/%s/includes/%s/extralarge.html'
+ PLAY_LIST_URL = BASE_URL + '/%s/itsxml/26-%s.xml'
+ RE_URL = '<key>URL</key><string>(.+?)</string>'
+ RE_DURATION = '<key>duration</key><integer>(.+?)</integer>'
+
+
def get_trailers(self, location):
@@ -123,54 +127,37 @@ class TrailerScraper(object):
url = COVER_BASE_URL + url
return url
+ def __trailer_urls(trailer_url):
+ return [trailer_url.replace('h720p', res)
+ for res in ('h480p', 'h720p', 'h1080p')]
+
tree = self.__get_tree(self.TRAILERS_URL % location)
- trailer_re = re.compile('trailer')
- for li in tree.findAll('li', {'class': trailer_re}):
- p_list = li.find('p').contents
- date_str, duration_str = p_list[0].strip(), p_list[-1].strip()
- if li.find('a', {'class': 'target-quicktimeplayer'}):
- section = li
- else:
- section = tree
- trailer_url_section = section.findAll(
- 'a', {'class': 'target-quicktimeplayer'}
- )
- if trailer_url_section:
- trailer_urls = [
- a['href'] for a in
- trailer_url_section
- ]
- else:
- # This is hacky but also done by js on website...
- tname = li.find('h3').string.replace(' ', '').replace('-', '')
- trailer_tree = self.__get_tree(
- self.OVERLAY_URL % (location, tname.lower())
- )
- resolution_gen_url = trailer_tree.find(
- 'a', {'class': 'movieLink'}
- )['href'].split('?')[0]
- trailer_urls = [
- resolution_gen_url.replace('720p', res)
- for res in ('h480p', 'h720p', 'h1080p')
- ]
- m, d, y = date_str.split()[1].split('/')
+ for li in tree.findAll('li', {'class': re.compile('trailer')}):
+ slug = li.find('h3').string.replace(' ', '').replace('-',
'').lower()
+ playlist = self.__get_url(self.PLAY_LIST_URL % (location, slug))
+ trailer_url = re.search(self.RE_URL, playlist).group(1)
+ duration = int(re.search(self.RE_DURATION, playlist).group(1)) /
1000
trailer = {
'title': li.find('h3').string,
- 'date': '%s.%s.20%s' % (d, m, y),
- 'duration': duration_str.split('Runtime:')[-1].strip(),
+ 'date': '',
+ 'duration': duration,
'thumb': __thumb(li.find('img')['src']),
'background': self.BACKGROUND_URL % location,
- 'urls': trailer_urls
+ 'urls': __trailer_urls(trailer_url)
}
yield trailer
def __get_tree(self, url):
+ return BeautifulSoup(self.__get_url(url))
+
+ def __get_url(self, url):
headers = {'User-Agent': USER_AGENT}
req = urllib2.Request(url, None, headers)
print 'Opening URL: %s' % url
try:
- return BeautifulSoup(urllib2.urlopen(req).read())
+ return urllib2.urlopen(req).read()
except urllib2.HTTPError, error:
+ print error
raise NetworkError('HTTPError: %s' % error)
-----------------------------------------------------------------------
Summary of changes:
plugin.video.itunes_trailers/addon.py | 10 ++--
plugin.video.itunes_trailers/addon.xml | 2 +-
plugin.video.itunes_trailers/changelog.txt | 3 +
.../resources/lib/scraper.py | 57 ++++++++------------
4 files changed, 32 insertions(+), 40 deletions(-)
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons