def getNextRace(): data = tools.getUrl('http://www.fiaformulae.com') matches = re.compile('<div id="startTime">(.*?)</div>.*?<div id="countdown">[^<]+<p>([^<]+)', re.DOTALL).findall(data) for date, location in matches: date = tools.cleanText(date) color = 'green' if date<3600 else 'red' days = int(date)/86400 hours = (int(date)/3600) - (int(days)*24) return '[COLOR '+color+']'+translation(30000)+' ['+location+'] ('+str(days)+' '+translation(30008)+' & '+str(hours)+' '+translation(30009)+' '+translation(30010)+')[/COLOR]'
def listVideos(url, pattern): data = tools.getUrl(url) matches = re.compile(pattern, re.DOTALL).findall(data) for match in matches: tools.log("listVideos->match: "+str(match)) for scrapedurl, scrapedthumbnail, scrapedtitle, scrapeddate in matches: scrapedtitle = tools.cleanText(scrapedtitle) scrapeddate = scrapeddate.replace('<span class="dateseparator">|</span>\r\n ', ' | ').strip() tools.addLink(scrapedtitle+" ["+scrapeddate+"]", scrapedurl, 'playVideo', scrapedthumbnail) xbmcplugin.endOfDirectory(pluginhandle) if forceViewMode: tools.set_view(viewMode)