def showInfoWindow(detailurl, showWindow=True): writeLog('Set details to home/info screen', level=xbmc.LOGDEBUG) data = TVDScraper() details = getUnicodePage(detailurl) if details: data.scrapeDetailPage(details, 'div id="main-content" class="clearfix"') blob = searchBlob('popup', detailurl) broadcastinfo = '%s: %s - %s' % (blob['pvrchannel'], blob['time'], data.endtime) writeLog('', level=xbmc.LOGDEBUG) writeLog('Title: %s' % (blob['title']), level=xbmc.LOGDEBUG) writeLog('Thumb: %s' % (blob['thumb']), level=xbmc.LOGDEBUG) writeLog('Channel (TVD): %s' % (blob['channel']), level=xbmc.LOGDEBUG) writeLog('Channel (PVR): %s' % (blob['pvrchannel']), level=xbmc.LOGDEBUG) writeLog('ChannelID: %s' % (blob['pvrid']), level=xbmc.LOGDEBUG) writeLog('Start Time: %s' % (blob['time']), level=xbmc.LOGDEBUG) writeLog('End Time: %s' % (data.endtime), level=xbmc.LOGDEBUG) writeLog('Rating Value: %s' % (data.ratingValue), level=xbmc.LOGDEBUG) writeLog('Best Rating: %s' % (data.bestRating), level=xbmc.LOGDEBUG) writeLog('Description: %s' % (data.plot or __LS__(30140)), level=xbmc.LOGDEBUG) writeLog('Keywords: %s' % (data.keywords), level=xbmc.LOGDEBUG) writeLog('Rating Data: %s' % (data.ratingdata), level=xbmc.LOGDEBUG) writeLog('Broadcast Flags: %s' % (data.broadcastflags), level=xbmc.LOGDEBUG) writeLog('', level=xbmc.LOGDEBUG) clearInfoProperties() WINDOW.setProperty("TVHighlightsToday.Info.isInFuture", "") WINDOW.setProperty("TVHighlightsToday.Info.isRunning", "") now = datetime.datetime.now() _st = '%s.%s.%s %s' % (now.day, now.month, now.year, blob['time']) try: _date = time.strftime(getDateFormat(), time.strptime(_st, '%d.%m.%Y %H:%M')) timestamp = date2timeStamp(_st, '%d.%m.%Y %H:%M') if timestamp >= int(time.time()): writeLog( 'Start time of title \'%s\' is @%s, enable switchtimer button' % (blob['title'], blob['time']), level=xbmc.LOGDEBUG) WINDOW.setProperty("TVHighlightsToday.Info.isInFuture", "yes") elif timestamp < int( time.time()) < timestamp + 60 * int(blob['runtime']): writeLog( 'Title \'%s\' is currently running, enable switch button' % (blob['title']), level=xbmc.LOGDEBUG) WINDOW.setProperty("TVHighlightsToday.Info.isRunning", "yes") except ImportError: writeLog('Could not make time conversion, strptime locked', level=xbmc.LOGERROR) _date = '' WINDOW.setProperty("TVHighlightsToday.Info.Title", blob['title']) WINDOW.setProperty("TVHighlightsToday.Info.Picture", blob['thumb']) WINDOW.setProperty("TVHighlightsToday.Info.Subtitle", blob['outline']) WINDOW.setProperty("TVHighlightsToday.Info.Description", data.plot or __LS__(30140)) WINDOW.setProperty("TVHighlightsToday.Info.Broadcastdetails", broadcastinfo) WINDOW.setProperty("TVHighlightsToday.Info.Channel", blob['pvrchannel']) WINDOW.setProperty("TVHighlightsToday.Info.ChannelID", blob['pvrid']) WINDOW.setProperty("TVHighlightsToday.Info.Logo", blob['logo']) WINDOW.setProperty("TVHighlightsToday.Info.Date", _date) WINDOW.setProperty("TVHighlightsToday.Info.StartTime", blob['time']) WINDOW.setProperty("TVHighlightsToday.Info.RunTime", blob['runtime']) WINDOW.setProperty("TVHighlightsToday.Info.EndTime", data.endtime) WINDOW.setProperty("TVHighlightsToday.Info.Keywords", blob['genre']) # Ratings i = 1 for r in data.ratingdata: WINDOW.setProperty("TVHighlightsToday.Info.RatingType.%s" % (i), r['ratingtype']) WINDOW.setProperty("TVHighlightsToday.Info.Rating.%s" % (i), r['rating'][0]) i += 1 if showWindow: Popup = xbmcgui.WindowXMLDialog('script-GTO-InfoWindow.xml', __path__, 'Default', '720p') # Popup = xbmcgui.WindowXMLDialog('script-TVHighlights-DialogWindow.xml', __path__, 'Default', '720p') Popup.doModal() else: notifyOSD(__LS__(30010), __LS__(30140))
def showInfoWindow(detailurl, showWindow=True): writeLog('Set details to home/info screen', level=xbmc.LOGDEBUG) data = TVDScraper() details = getUnicodePage(detailurl) if details: data.scrapeDetailPage(details, 'div id="main-content" class="clearfix"') blob = searchBlob('popup', detailurl) broadcastinfo = '%s: %s - %s' % (blob['pvrchannel'], blob['time'], data.endtime) writeLog('', level=xbmc.LOGDEBUG) writeLog('Title: %s' % (blob['title']), level=xbmc.LOGDEBUG) writeLog('Thumb: %s' % (blob['thumb']), level=xbmc.LOGDEBUG) writeLog('Channel (TVD): %s' % (blob['channel']), level=xbmc.LOGDEBUG) writeLog('Channel (PVR): %s' % (blob['pvrchannel']), level=xbmc.LOGDEBUG) writeLog('ChannelID: %s' % (blob['pvrid']), level=xbmc.LOGDEBUG) writeLog('Start Time: %s' % (blob['time']), level=xbmc.LOGDEBUG) writeLog('End Time: %s' % (data.endtime), level=xbmc.LOGDEBUG) writeLog('Rating Value: %s' % (data.ratingValue), level=xbmc.LOGDEBUG) writeLog('Best Rating: %s' % (data.bestRating), level=xbmc.LOGDEBUG) writeLog('Description: %s' % (data.plot or __LS__(30140)), level=xbmc.LOGDEBUG) writeLog('Keywords: %s' % (data.keywords), level=xbmc.LOGDEBUG) writeLog('Rating Data: %s' % (data.ratingdata), level=xbmc.LOGDEBUG) writeLog('Broadcast Flags: %s' % (data.broadcastflags), level=xbmc.LOGDEBUG) writeLog('', level=xbmc.LOGDEBUG) clearInfoProperties() WINDOW.setProperty("TVHighlightsToday.Info.isInFuture", "") WINDOW.setProperty("TVHighlightsToday.Info.isRunning", "") now = datetime.datetime.now() _st = '%s.%s.%s %s' % (now.day, now.month, now.year, blob['time']) try: _date = time.strftime(getDateFormat(), time.strptime(_st, '%d.%m.%Y %H:%M')) timestamp = date2timeStamp(_st, '%d.%m.%Y %H:%M') if timestamp >= int(time.time()): writeLog('Start time of title \'%s\' is @%s, enable switchtimer button' % (blob['title'], blob['time']), level=xbmc.LOGDEBUG) WINDOW.setProperty("TVHighlightsToday.Info.isInFuture", "yes") elif timestamp < int(time.time()) < timestamp + 60 * int(blob['runtime']): writeLog('Title \'%s\' is currently running, enable switch button' % (blob['title']), level=xbmc.LOGDEBUG) WINDOW.setProperty("TVHighlightsToday.Info.isRunning", "yes") except ImportError: writeLog('Could not make time conversion, strptime locked', level=xbmc.LOGERROR) _date = '' WINDOW.setProperty("TVHighlightsToday.Info.Title", blob['title']) WINDOW.setProperty("TVHighlightsToday.Info.Picture", blob['thumb']) WINDOW.setProperty("TVHighlightsToday.Info.Subtitle", blob['outline']) WINDOW.setProperty("TVHighlightsToday.Info.Description", data.plot or __LS__(30140)) WINDOW.setProperty("TVHighlightsToday.Info.Broadcastdetails", broadcastinfo) WINDOW.setProperty("TVHighlightsToday.Info.Channel", blob['pvrchannel']) WINDOW.setProperty("TVHighlightsToday.Info.ChannelID", blob['pvrid']) WINDOW.setProperty("TVHighlightsToday.Info.Logo", blob['logo']) WINDOW.setProperty("TVHighlightsToday.Info.Date", _date) WINDOW.setProperty("TVHighlightsToday.Info.StartTime", blob['time']) WINDOW.setProperty("TVHighlightsToday.Info.RunTime", blob['runtime']) WINDOW.setProperty("TVHighlightsToday.Info.EndTime", data.endtime) WINDOW.setProperty("TVHighlightsToday.Info.Keywords", blob['genre']) # Ratings i = 1 for r in data.ratingdata: WINDOW.setProperty( "TVHighlightsToday.Info.RatingType.%s" %(i), r['ratingtype'] ) WINDOW.setProperty( "TVHighlightsToday.Info.Rating.%s" %(i), r['rating'][0] ) i += 1 if showWindow: Popup = xbmcgui.WindowXMLDialog('script-GTO-InfoWindow.xml', __path__, 'Default', '720p') # Popup = xbmcgui.WindowXMLDialog('script-TVHighlights-DialogWindow.xml', __path__, 'Default', '720p') Popup.doModal() else: notifyOSD(__LS__(30010), __LS__(30140))
def scrapeTVDPage(category): url = '%s%s/' % (TVDURL, category) writeLog('Start scraping category %s from %s' % (category, url), level=xbmc.LOGDEBUG) content = getUnicodePage(url, container='class="highlight-container"') i = 1 content.pop(0) blobs = WINDOW.getProperty('TVD.%s.blobs' % (category)) if blobs != '': for idx in range(1, int(blobs) + 1, 1): WINDOW.clearProperty('TVD.%s.%s' % (category, idx)) for container in content: data = TVDScraper() data.scrapeHighlights(container) pvrchannelID = channelName2channelId(data.channel) if not pvrchannelID: writeLog("TVHighlights: Channel %s is not in PVR, discard entry" % (data.channel), level=xbmc.LOGDEBUG) continue logoURL = pvrchannelid2logo(pvrchannelID) channel = pvrchannelid2channelname(pvrchannelID) writeLog('', level=xbmc.LOGDEBUG) writeLog('ID: TVD.%s.%s' % (category, i), level=xbmc.LOGDEBUG) writeLog('Title: %s' % (data.title), level=xbmc.LOGDEBUG) writeLog('Thumb: %s' % (data.thumb), level=xbmc.LOGDEBUG) writeLog('Start time: %s' % (data.starttime), level=xbmc.LOGDEBUG) writeLog('Running Time: %s' % (data.runtime), level=xbmc.LOGDEBUG) writeLog('Channel (TVD): %s' % (data.channel), level=xbmc.LOGDEBUG) writeLog('Channel (PVR): %s' % (channel), level=xbmc.LOGDEBUG) writeLog('ChannelID (PVR): %s' % (pvrchannelID), level=xbmc.LOGDEBUG) writeLog('Channel logo: %s' % (logoURL), level=xbmc.LOGDEBUG) writeLog('Genre: %s' % (data.genre), level=xbmc.LOGDEBUG) writeLog('Outline: %s' % (data.outline), level=xbmc.LOGDEBUG) writeLog('Extrainfos: %s' % (data.extrainfos), level=xbmc.LOGDEBUG) writeLog('Popup: %s' % (data.detailURL), level=xbmc.LOGDEBUG) writeLog('Watchtype: %s' % (category), level=xbmc.LOGDEBUG) writeLog('', level=xbmc.LOGDEBUG) blob = { 'id': unicode('TVD.%s.%s' % (i, category)), 'title': unicode(data.title), 'thumb': unicode(data.thumb), 'time': unicode(data.starttime), 'runtime': unicode(data.runtime), 'endtime': unicode(data.endtime), 'channel': unicode(data.channel), 'pvrchannel': unicode(channel), 'pvrid': unicode(pvrchannelID), 'logo': unicode(logoURL), 'genre': unicode(data.genre), 'outline': unicode(unicode(data.outline)), 'extrainfos': unicode(data.extrainfos), 'popup': unicode(data.detailURL), 'category': unicode(category), } WINDOW.setProperty('TVD.%s.%s' % (category, i), str(blob)) i += 1 WINDOW.setProperty('TVD.%s.blobs' % (category), str(i - 1))
def scrapeTVDPage(category): url = '%s%s/' % (TVDURL, category) writeLog('Start scraping category %s from %s' % (category, url), level=xbmc.LOGDEBUG) content = getUnicodePage(url, container='class="highlight-container"') i = 1 content.pop(0) blobs = WINDOW.getProperty('TVD.%s.blobs' % (category)) if blobs != '': for idx in range(1, int(blobs) + 1, 1): WINDOW.clearProperty('TVD.%s.%s' % (category, idx)) for container in content: data = TVDScraper() data.scrapeHighlights(container) pvrchannelID = channelName2channelId(data.channel) if not pvrchannelID: writeLog("TVHighlights: Channel %s is not in PVR, discard entry" % (data.channel), level=xbmc.LOGDEBUG) continue logoURL = pvrchannelid2logo(pvrchannelID) channel = pvrchannelid2channelname(pvrchannelID) writeLog('', level=xbmc.LOGDEBUG) writeLog('ID: TVD.%s.%s' %(category, i), level=xbmc.LOGDEBUG) writeLog('Title: %s' % (data.title), level=xbmc.LOGDEBUG) writeLog('Thumb: %s' % (data.thumb), level=xbmc.LOGDEBUG) writeLog('Start time: %s' % (data.starttime), level=xbmc.LOGDEBUG) writeLog('Running Time: %s' % (data.runtime), level=xbmc.LOGDEBUG) writeLog('Channel (TVD): %s' % (data.channel), level=xbmc.LOGDEBUG) writeLog('Channel (PVR): %s' % (channel), level=xbmc.LOGDEBUG) writeLog('ChannelID (PVR): %s' % (pvrchannelID), level=xbmc.LOGDEBUG) writeLog('Channel logo: %s' % (logoURL), level=xbmc.LOGDEBUG) writeLog('Genre: %s' % (data.genre), level=xbmc.LOGDEBUG) writeLog('Outline: %s' % (data.outline), level=xbmc.LOGDEBUG) writeLog('Extrainfos: %s' % (data.extrainfos), level=xbmc.LOGDEBUG) writeLog('Popup: %s' % (data.detailURL), level=xbmc.LOGDEBUG) writeLog('Watchtype: %s' % (category), level=xbmc.LOGDEBUG) writeLog('', level=xbmc.LOGDEBUG) blob = { 'id': unicode('TVD.%s.%s' % (i, category)), 'title': unicode(data.title), 'thumb': unicode(data.thumb), 'time': unicode(data.starttime), 'runtime': unicode(data.runtime), 'endtime': unicode(data.endtime), 'channel': unicode(data.channel), 'pvrchannel': unicode(channel), 'pvrid': unicode(pvrchannelID), 'logo': unicode(logoURL), 'genre': unicode(data.genre), 'outline': unicode(unicode(data.outline)), 'extrainfos': unicode(data.extrainfos), 'popup': unicode(data.detailURL), 'category': unicode(category), } WINDOW.setProperty('TVD.%s.%s' % (category, i), str(blob)) i += 1 WINDOW.setProperty('TVD.%s.blobs' % (category), str(i - 1))