The branch, frodo has been updated
via da11002b22bab30c02ece608ad3df67b4d3583db (commit)
from bf5af8f37999415a1cd44b765a7b98be2cde6e3d (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/plugins;a=commit;h=da11002b22bab30c02ece608ad3df67b4d3583db
commit da11002b22bab30c02ece608ad3df67b4d3583db
Author: beenje <[email protected]>
Date: Mon Mar 4 23:03:15 2013 +0100
[plugin.video.nascar] updated to version 2.0.0
diff --git a/plugin.video.nascar/addon.xml b/plugin.video.nascar/addon.xml
index e1716a2..89cc8b9 100644
--- a/plugin.video.nascar/addon.xml
+++ b/plugin.video.nascar/addon.xml
@@ -1,18 +1,22 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="plugin.video.nascar"
- name="NascarX"
- version="1.0.0"
- provider-name="divingmule">
- <requires>
- <import addon="xbmc.python" version="2.0"/>
- </requires>
- <extension point="xbmc.python.pluginsource"
- library="default.py">
- <provides>video</provides>
- </extension>
- <extension point="xbmc.addon.metadata">
- <summary>Nascar Videos</summary>
- <description>Videos from nascar.com</description>
- <platform>all</platform>
- </extension>
-</addon>
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<addon id="plugin.video.nascar"
+ name="Nascar.com"
+ version="2.0.0"
+ provider-name="divingmule">
+ <requires>
+ <import addon="xbmc.python" version="2.1.0"/>
+ <import addon="script.module.pyamf" version="0.6.1"/>
+ <import addon="script.module.beautifulsoup" version="3.2.0"/>
+ </requires>
+ <extension point="xbmc.python.pluginsource" library="default.py">
+ <provides>video</provides>
+ </extension>
+ <extension point="xbmc.addon.metadata">
+ <summary>Nascar Videos</summary>
+ <description>Videos from nascar.com</description>
+ <platform>all</platform>
+ <language>en</language>
+ <license>GNU GENERAL PUBLIC LICENSE. Version 2, June 1991</license>
+ <source>https://code.google.com/p/xnascar/</source>
+ </extension>
+</addon>
diff --git a/plugin.video.nascar/changelog.txt
b/plugin.video.nascar/changelog.txt
index 0692f65..70ed883 100644
--- a/plugin.video.nascar/changelog.txt
+++ b/plugin.video.nascar/changelog.txt
@@ -1,6 +1,12 @@
-Version 1.0.0
-initial for eden-pre
-
-Version 1.2
-fix - video url's changed
+Version 2.0.0
+major version bump for frodo
+major update, the old video feed isn't updated anymore, now scrapping the
website
+added quality settings up to 720p
+added some filter settings
+
+Version 1.0.0
+initial for eden-pre
+
+Version 1.2
+fix - video url's changed
removed the directorys as they were not needed
\ No newline at end of file
diff --git a/plugin.video.nascar/default.py b/plugin.video.nascar/default.py
index 0ca7263..287618e 100644
--- a/plugin.video.nascar/default.py
+++ b/plugin.video.nascar/default.py
@@ -1,23 +1,185 @@
-import urllib,urllib2,re,xbmcplugin,xbmcgui,xbmcaddon
-
-__settings__ = xbmcaddon.Addon(id='plugin.video.nascar')
-
-
-def main():
- url =
'http://i.cdn.turner.com/nascar/feeds/partners/embeded_player/latest.xml'
- req = urllib2.Request(url)
- req.addheaders = [('Referer', 'http://www.nascar.com/videos'),
- ('Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.3)
Gecko/20100401 Firefox/3.6.3 ( .NET CLR 3.5.30729)')]
- response = urllib2.urlopen(req)
- link=response.read()
- response.close()
-
match=re.compile('<CATEGORY>.+?</CATEGORY>\n<TITLE>(.+?)</TITLE>\n<DESCRIPTION>.+?</DESCRIPTION>\n<URL
ID="(.+?)">\n<SITEURL>.+?</SITEURL>\n</URL>\n<IMAGE>(.+?)</IMAGE>').findall(link)
- for name,url,thumbnail in match:
- url = 'http://ht.cdn.turner.com/nascar/big/'+url+'.nascar_640x360.mp4'
- liz=xbmcgui.ListItem(name, iconImage="DefaultVideo.png",
thumbnailImage=thumbnail)
- liz.setInfo( type="Video", infoLabels={ "Title": name } )
-
xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=url,listitem=liz)
-
-main()
-
+import urllib
+import urllib2
+import httplib
+import re
+import os
+import xbmcplugin
+import xbmcgui
+import xbmcaddon
+from BeautifulSoup import BeautifulSoup
+from pyamf import remoting
+
+addon = xbmcaddon.Addon(id='plugin.video.nascar')
+home = xbmc.translatePath(addon.getAddonInfo('path'))
+icon = os.path.join(home, 'icon.png')
+fanart = os.path.join(home, 'fanart.jpg')
+addon_version = addon.getAddonInfo('version')
+debug = addon.getSetting('debug')
+
+
+def addon_log(string):
+ if debug == 'true':
+ xbmc.log("[addon.nascar-%s]: %s" %(addon_version, string))
+
+
+def make_request(url):
+ try:
+ headers = {
+ 'User-agent' : 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:19.0)
Gecko/20100101 Firefox/19.0',
+ 'Referer' :
'http://www.nascar.com/en_us/sprint-cup-series.html'
+ }
+ req = urllib2.Request(url,None,headers)
+ response = urllib2.urlopen(req)
+ if response.geturl() != url:
+ addon_log('Redirect URL: %s' %response.geturl())
+ data = response.read()
+ response.close()
+ except urllib2.URLError, e:
+ addon_log(('We failed to open "%s".' % url))
+ if hasattr(e, 'reason'):
+ addon_log(('We failed to reach a server.'))
+ addon_log(('Reason: %s' %e.reason))
+ if hasattr(e, 'code'):
+ addon_log(('We failed with error code - %s.' %e.code))
+ data = None
+ return data
+
+
+def get_video_items(url, featured=False):
+ data = make_request(url)
+ if data:
+ soup = BeautifulSoup(data,
convertEntities=BeautifulSoup.HTML_ENTITIES)
+ if featured:
+ items = soup.find('div', attrs={'class':
"featuredVideos"})('article')
+ else:
+ items = soup.find('div', attrs={'class':
"articlesList"})('article')
+ for i in items:
+ if featured:
+ title = re.findall('"linkText":"(.+?)"', str(i))[0]
+ item_id =
i.img['data-ajax-post-data'].split('=')[1].split('&')[0]
+ thumb = i.img['data-resp-url']
+ else:
+ title = i.img['alt']
+ item_id = i.img['data-ajax-post-data'].split('=')[1]
+ thumb = i.img['src']
+
u=sys.argv[0]+'?mode=resolve_url&url='+urllib.quote_plus(item_id)
+ liz=xbmcgui.ListItem(title, iconImage="DefaultVideo.png",
thumbnailImage=thumb)
+ liz.setInfo(type="Video", infoLabels={"Title": title})
+ liz.setProperty('IsPlayable', 'true')
+ liz.setProperty("Fanart_Image", fanart)
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u,
listitem=liz, isFolder=False)
+ load_more = soup.find('a', attrs={'title': 'LOAD MORE'})
+ if load_more:
+
u=sys.argv[0]+'?mode=page&url='+urllib.quote_plus('http://www.nascar.com'+load_more['data-href'])
+ liz=xbmcgui.ListItem('Load More',
iconImage="DefaultVideo.png", thumbnailImage=icon)
+ liz.setProperty("Fanart_Image", fanart)
+ xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u,
listitem=liz, isFolder=True)
+
+
+def resolve_url(item_id):
+ ## Credit to AddonScriptorDE for the bc code
+ ## https://github.com/AddonScriptorDE/plugin.video.redbull_tv
+ quality = int(addon.getSetting('quality'))
+ bc_playerID = 2033674580001
+ bc_publisherID = 1677257476001
+ bc_const = 'efa14670a843335eedd6c1e1acc8b2c4c4e342db'
+ conn = httplib.HTTPConnection("c.brightcove.com")
+ envelope = remoting.Envelope(amfVersion=3)
+ envelope.bodies.append(("/1", remoting.Request(
+
target="com.brightcove.player.runtime.PlayerMediaFacade.findMediaById",
+ body=[bc_const, bc_playerID, item_id, bc_publisherID],
+ envelope=envelope)))
+ conn.request("POST", "/services/messagebroker/amf?playerId=" +
str(bc_playerID),
+ str(remoting.encode(envelope).read()), {'content-type':
'application/x-amf'})
+ response = conn.getresponse().read()
+ response = remoting.decode(response).bodies[0][1].body
+ renditions = sorted(response['renditions'], key=lambda k:
int(k['encodingRate']), reverse=True)
+ q_type = None
+ for i in range(len(renditions)):
+ if quality > 0:
+ try:
+ ok = renditions[quality]['defaultURL']
+ if ok:
+ q_type = quality
+ else: raise
+ except:
+ quality = (quality -1)
+ addon_log('quality not avaliable')
+ if q_type:
+ break
+ else:
+ q_type = quality
+ break
+ path = renditions[q_type]['defaultURL'].split('&')[0]
+ path += ' playpath=%s' %renditions[q_type]['defaultURL'].split('&')[1]
+ item = xbmcgui.ListItem(path=path)
+ xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, item)
+
+
+def get_params():
+ param=[]
+ paramstring=sys.argv[2]
+ if len(paramstring)>=2:
+ params=sys.argv[2]
+ cleanedparams=params.replace('?','')
+ if (params[len(params)-1]=='/'):
+ params=params[0:len(params)-2]
+ pairsofparams=cleanedparams.split('&')
+ param={}
+ for i in range(len(pairsofparams)):
+ splitparams={}
+ splitparams=pairsofparams[i].split('=')
+ if (len(splitparams))==2:
+ param[splitparams[0]]=splitparams[1]
+ return param
+
+
+params=get_params()
+
+url=None
+mode=None
+
+try:
+ url=urllib.unquote_plus(params["url"])
+except:
+ pass
+try:
+ mode=urllib.unquote_plus(params["mode"])
+except:
+ pass
+
+addon_log('URL: %s' %url)
+addon_log('Mode: %s' %mode)
+
+if mode==None:
+ sort = {
+ 'series': ['', 'sprint-cup-series/', 'nationwide-series/',
'camping-world-truck-series/'],
+ 'time': ['365', '30', '7' ,'1'],
+ 'sort': ['recent', 'popular']
+ }
+ videos_url = (
+
'http://www.nascar.com/en_us/%snews-media.all.0.videos.all.all.%s.%s.html'
+ %(sort['series'][int(addon.getSetting('series'))],
+ sort['time'][int(addon.getSetting('time'))],
+ sort['sort'][int(addon.getSetting('sort'))])
+ )
+ if addon.getSetting('series') == '0':
+ base_url = 'http://www.nascar.com/en_us/sprint-cup-series.html'
+ else:
+ base_url = (
+ 'http://www.nascar.com/en_us/%s.html'
+ %sort['series'][int(addon.getSetting('series'))][:-1]
+ )
+ addon_log('base_url: '+base_url)
+ addon_log('videos_url: '+videos_url)
+ if addon.getSetting('featured') == 'true':
+ get_video_items(base_url, True)
+ get_video_items(videos_url)
+
+elif mode=="resolve_url":
+ resolve_url(url)
+
+elif mode=="page":
+ get_video_items(url)
+
xbmcplugin.endOfDirectory(int(sys.argv[1]))
\ No newline at end of file
diff --git a/plugin.video.nascar/fanart.jpg b/plugin.video.nascar/fanart.jpg
index 123c34b..b3c9a6c 100644
Binary files a/plugin.video.nascar/fanart.jpg and
b/plugin.video.nascar/fanart.jpg differ
diff --git a/plugin.video.nascar/icon.png b/plugin.video.nascar/icon.png
index e72da99..9e8706e 100644
Binary files a/plugin.video.nascar/icon.png and b/plugin.video.nascar/icon.png
differ
-----------------------------------------------------------------------
Summary of changes:
plugin.video.nascar/addon.xml | 40 ++--
plugin.video.nascar/changelog.txt | 16 +-
plugin.video.nascar/default.py | 206 +++++++++++++++++--
plugin.video.nascar/fanart.jpg | Bin 592074 -> 260280
bytes
plugin.video.nascar/icon.png | Bin 57165 -> 45334 bytes
.../resources/language/English/strings.xml | 29 +++
plugin.video.nascar/resources/settings.xml | 12 ++
7 files changed, 258 insertions(+), 45 deletions(-)
create mode 100644 plugin.video.nascar/resources/language/English/strings.xml
create mode 100644 plugin.video.nascar/resources/settings.xml
hooks/post-receive
--
Plugins
------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons