def SimpleStreams(): oc = ObjectContainer() Log.Debug('SimpleStreams menu: Source is ' + str(Dict['source'])) #oc = ObjectContainer(title2 = "Channels") Log.Info(str(PLUGIN_VERSION) + ' SimpleStreams') channelsDict = Dict['channelsDict'] currentTime = SmoothUtils.getCurrentTimeNative() for i in range(1, 5): if not channelsDict is None: break Log.Info('sleeping 500ms for async schedule details to return') Thread.Sleep(0.5) for channelNum in range(1, int(Prefs['numChannels']) + 1): if not channelsDict is None and str(channelNum) in channelsDict: channelItem = channelsDict[str(channelNum)] channelName = channelItem.name.replace("720P", "HD") nowPlaying = channelItem.NowPlaying() upcoming = channelItem.Upcoming() if not upcoming is None and len(upcoming) > 0: upcoming = upcoming[0] if nowPlaying is None: titleText = formatShowText(channelItem, nowPlaying, currentTime, "#{ch} {chname}") category = "" tagLine = "" else: titleText = formatShowText(channelItem, nowPlaying, currentTime, "#{ch} {chname} {title} {qual} {lang} {time} ({cat})") category = nowPlaying['category'] tagLine = nowPlaying['description'] if upcoming is None or len(upcoming) == 0: summaryText = "" else: summaryText = formatShowText(channelItem, upcoming, currentTime, "{when} {title} {qual} {lang} {time} ({cat})") thumbV = SmoothUtils.GetChannelThumb(chanNum = int(channelNum), chanName = channelName, category = category, large = True) #, chanFirst = True oc.add( CreateVideoClipObject( url = SmoothUtils.GetFullUrlFromChannelNumber(channelNum), title = SmoothUtils.fix_text(titleText), tagline = SmoothUtils.fix_text(tagLine), summary = SmoothUtils.fix_text(summaryText), studio = channelName, thumb = thumbV, optimized_for_streaming=True, include_container=False #True before though... ) ) # Preferences oc.add(PrefsObject(title="Preferences", thumb=R("icon-prefs.png"))) return oc
def PlaylistReloader(): while True: if not Dict['last_playlist_load_datetime']: PlaylistReload() else: current_datetime = datetime.datetime.utcnow() cur_utc_hr = datetime.datetime.utcnow().replace(microsecond=0, second=0, minute=0).hour target_utc_hr = (cur_utc_hr // 4) * 4 target_utc_datetime = datetime.datetime.utcnow().replace( microsecond=0, second=0, minute=0, hour=target_utc_hr) if current_datetime > target_utc_datetime and target_utc_datetime > Dict[ 'last_playlist_load_datetime']: PlaylistReload() Thread.Sleep(10)
def CategoriesMenu(): Log.Info(str(PLUGIN_VERSION) + " CategoriesMenu") oc = ObjectContainer(title2 = "Categories") Log.Info('Categories') categoryDict = Dict['genres']['sports'] for i in range(1, 5): if not categoryDict is None and not categoryDict is None: break Log.Info('sleeping 500ms for async schedule details to return') Thread.Sleep(0.5) Log.Info(categoryDict) for category in sorted(categoryDict): thumb = SmoothUtils.GetChannelThumb(category = category, large = False) oc.add(DirectoryObject(key=Callback(SearchListItems, query="genre,%s" % category), title=category, thumb=thumb)) return oc