def loadFromCache(murl, channel, cacheFilePath): channels = jsonutil.readJson(cacheFilePath)['channels'] channelData = channels[channel] tvShows = channelData['currentTVShows'] for tvShow in tvShows: main.addTVInfo(tvShow['name'], tvShow['url'], constants.DESIRULEZ_LISTEPISODES, tvShow['iconimage'], tvShow['name'], '') if not re.search('past', murl, re.I): main.addTVInfo('[COLOR red]' + channel + ' Past Shows[/COLOR]', channelData['pastTVShowURL'], constants.DESIRULEZ_LISTSHOWS, '', 'Past Shows', '')
def loadFromCache(murl, channel, cacheFilePath): channels = jsonutil.readJson(cacheFilePath)["channels"] channelData = channels[channel] tvShows = channelData["currentTVShows"] for tvShow in tvShows: main.addTVInfo( tvShow["name"], tvShow["url"], constants.DESIRULEZ_LISTEPISODES, tvShow["iconimage"], tvShow["name"], "" ) if not re.search("past", murl, re.I): main.addTVInfo( "[COLOR red]" + channel + " Past Shows[/COLOR]", channelData["pastTVShowURL"], constants.DESIRULEZ_LISTSHOWS, "", "Past Shows", "", )
def checkCache(murl, channel, cacheFilePath): refreshCache = True if not os.path.exists(cacheFilePath): jsonutil.createBlankChannelCache(cacheFilePath) else: lastModifiedTime = fileutil.lastModifiedTime(cacheFilePath) diffTime = long((time.time() - lastModifiedTime) / 3600) if diffTime < 720: try: jsonChannelData = jsonutil.readJson(cacheFilePath) if jsonChannelData["channels"][channel]: if re.search("past", murl, re.I): if jsonChannelData["channels"][channel]["pastTVShows"]: refreshCache = False elif jsonChannelData["channels"][channel]["currentTVShows"]: refreshCache = False except Exception, e: refreshCache = True
def checkCache(murl, channel, cacheFilePath): refreshCache = True if not os.path.exists(cacheFilePath): jsonutil.createBlankChannelCache(cacheFilePath) else: lastModifiedTime = fileutil.lastModifiedTime(cacheFilePath) diffTime = long((time.time() - lastModifiedTime) / 3600) if diffTime < 720: try: jsonChannelData = jsonutil.readJson(cacheFilePath) if jsonChannelData['channels'][channel]: if re.search('past', murl, re.I): if jsonChannelData['channels'][channel]['pastTVShows']: refreshCache = False elif jsonChannelData['channels'][channel][ 'currentTVShows']: refreshCache = False except Exception, e: refreshCache = True
def buildCache(murl, channel, cacheFilePath, index): channels = {} channelDict = {} channelData = {} tvShows = [] tvShow = {} pastTVShowURL = "" link = main.OPENURL(murl) link = link.decode("iso-8859-1").encode("utf-8") result = common.parseDOM(link, "h2", attrs={"class": "forumtitle"}) label = "TV Shows" if len(result) <= 0: label = "Movies" result = common.parseDOM(link, "h3", attrs={"class": "threadtitle"}) dialogWait = xbmcgui.DialogProgress() ret = dialogWait.create("Please wait until " + label + " Show list is cached.") totalLinks = len(result) loadedLinks = 0 remaining_display = label + " loaded :: [B]" + str(loadedLinks) + " / " + str(totalLinks) + "[/B]." dialogWait.update(0, "[B]Will load instantly from now on[/B]", remaining_display) xbmc.executebuiltin("XBMC.Dialog.Close(busydialog,true)") for item in result: name = common.parseDOM(item, "a", attrs={"class": "title threadtitle_unread"}) if not name: name = common.parseDOM(item, "a", attrs={"class": "title"}) if name: name = name[0] else: name = common.parseDOM(item, "a") if len(name) > 1: name = name[1] else: name = name[0] elif len(name) > 1: name = name[1] else: name = name[0] url = common.parseDOM(item, "a", attrs={"class": "title threadtitle_unread"}, ret="href") url = common.parseDOM(item, "a", ret="href") if not url: url = common.parseDOM(item, "a", attrs={"class": "title"}, ret="href") if url: url = url[0] elif len(url) > 1: url = url[1] else: url = url[0] if "color" in name: name = name.replace("<b><font color=red>", "[COLOR red]").replace("</font></b>", "[/COLOR]") name = name.replace('<b><font color="red">', "[COLOR red]").replace("</font></b>", "[/COLOR]") pastTVShowURL = MainUrl + url elif label == "Movies": name = name.replace("Watch Online / Download", "") main.addDirX(name, MainUrl + url, constants.DESIRULEZ_VIDEOLINKS, "", searchMeta=True, metaType="Movies") else: tvShow["url"] = MainUrl + url tvShow["iconimage"] = getShowImage(channel, name, 2) tvShow["name"] = name tvShows.append(tvShow) tvShow = {} loadedLinks = loadedLinks + 1 percent = (loadedLinks * 100) / totalLinks remaining_display = label + " loaded :: [B]" + str(loadedLinks) + " / " + str(totalLinks) + "[/B]." dialogWait.update(percent, "[B]Will load instantly from now on[/B]", remaining_display) if dialogWait.iscanceled(): return False dialogWait.close() del dialogWait # Writing data to JSON File jsonChannelData = jsonutil.readJson(cacheFilePath) channels = jsonChannelData["channels"] try: channelData = channels[channel] except Exception, e: print "exception"
def buildCache(murl, channel, cacheFilePath, index): channels = {} channelDict = {} channelData = {} tvShows = [] tvShow = {} pastTVShowURL = '' link = main.OPENURL(murl) link = link.decode('iso-8859-1').encode('utf-8') result = common.parseDOM(link, "h2", attrs={"class": "forumtitle"}) label = 'TV Shows' if len(result) <= 0: label = 'Movies' result = common.parseDOM(link, "h3", attrs={"class": "threadtitle"}) dialogWait = xbmcgui.DialogProgress() ret = dialogWait.create('Please wait until ' + label + ' Show list is cached.') totalLinks = len(result) loadedLinks = 0 remaining_display = label + ' loaded :: [B]' + str( loadedLinks) + ' / ' + str(totalLinks) + '[/B].' dialogWait.update(0, '[B]Will load instantly from now on[/B]', remaining_display) xbmc.executebuiltin("XBMC.Dialog.Close(busydialog,true)") for item in result: name = common.parseDOM(item, "a", attrs={"class": "title threadtitle_unread"}) if not name: name = common.parseDOM(item, "a", attrs={"class": "title"}) if name: name = name[0] else: name = common.parseDOM(item, "a") if len(name) > 1: name = name[1] else: name = name[0] elif len(name) > 1: name = name[1] else: name = name[0] url = common.parseDOM(item, "a", attrs={"class": "title threadtitle_unread"}, ret="href") url = common.parseDOM(item, "a", ret="href") if not url: url = common.parseDOM(item, "a", attrs={"class": "title"}, ret="href") if url: url = url[0] elif len(url) > 1: url = url[1] else: url = url[0] if "color" in name: name = name.replace('<b><font color=red>', '[COLOR red]').replace('</font></b>', '[/COLOR]') name = name.replace('<b><font color="red">', '[COLOR red]').replace('</font></b>', '[/COLOR]') pastTVShowURL = MainUrl + url elif label == 'Movies': name = name.replace('Watch Online / Download', '') main.addDirX(name, MainUrl + url, constants.DESIRULEZ_VIDEOLINKS, '', searchMeta=True, metaType='Movies') else: tvShow['url'] = MainUrl + url tvShow['iconimage'] = getShowImage(channel, name, 2) tvShow['name'] = name tvShows.append(tvShow) tvShow = {} loadedLinks = loadedLinks + 1 percent = (loadedLinks * 100) / totalLinks remaining_display = label + ' loaded :: [B]' + str( loadedLinks) + ' / ' + str(totalLinks) + '[/B].' dialogWait.update(percent, '[B]Will load instantly from now on[/B]', remaining_display) if dialogWait.iscanceled(): return False dialogWait.close() del dialogWait # Writing data to JSON File jsonChannelData = jsonutil.readJson(cacheFilePath) channels = jsonChannelData['channels'] try: channelData = channels[channel] except Exception, e: print 'exception'