def add_program_vod(self, listcontainersort): for program in var.ChannelsDataJsonSeriesKids['resultObj'][ 'containers']: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata( program) #Check if there are search results if var.SearchFilterTerm != '': searchMatch = func.search_filter_string(ProgramName) searchResultFound = var.SearchFilterTerm in searchMatch if searchResultFound == False: continue #Load program details PictureUrl = metadatainfo.pictureUrl_from_json_metadata( program) ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramStarRating = metadatainfo.programstarrating_from_json_metadata( program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata( program) #Combine program details stringJoin = [ProgramYear, ProgramStarRating, ProgramAgeRating] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' ProgramDetails = '[COLOR gray]' + ProgramDetails + '[/COLOR]' #Add vod program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'load_episodes_vod') listitem.setProperty('PictureUrl', PictureUrl) listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty('ProgramDetails', ProgramDetails) listitem.setInfo('video', { 'Genre': 'Series', 'Plot': ProgramDetails }) iconProgramType = "common/series.png" iconStreamType = "common/vod.png" iconProgram = path.icon_vod(PictureUrl) listitem.setArt({ 'thumb': iconProgram, 'icon': iconProgram, 'image1': iconStreamType, 'image2': iconProgramType }) listcontainersort.append(listitem) except: continue
def search_programid_jsonrecording_event(searchProgramId): if var.ChannelsDataJsonRecordingEvent == []: return None for Record in var.ChannelsDataJsonRecordingEvent["resultObj"][ "containers"]: try: if metadatainfo.contentId_from_json_metadata( Record) == searchProgramId: return Record if metadatainfo.contentIdLive_from_json_metadata( Record) == searchProgramId: return Record except: continue return None
def record_event_next_television_playergui(listItemSelected): ProgramNextId = listItemSelected.getProperty('ProgramNextId') #Check the program recording state recordProgramEvent = func.search_programid_jsonrecording_event( ProgramNextId) if recordProgramEvent: ProgramRecordEventId = metadatainfo.contentId_from_json_metadata( recordProgramEvent) ProgramStartDeltaTime = metadatainfo.programstartdeltatime_from_json_metadata( recordProgramEvent) recordRemove = download.record_event_remove(ProgramRecordEventId, ProgramStartDeltaTime) if recordRemove == True: listItemSelected.setProperty("ProgramNextRecordEvent", 'false') else: recordAdd = download.record_event_add(ProgramNextId) if recordAdd != '': listItemSelected.setProperty("ProgramNextRecordEvent", 'true')
def update_program_record_event(self): #Get the epg list control listcontainer = self.getControl(1002) listitemcount = listcontainer.size() #Check if program has active recording for channelNum in range(0, listitemcount): updateItem = listcontainer.getListItem(channelNum) ProgramId = updateItem.getProperty('ProgramId') ProgramTimeEndString = updateItem.getProperty('ProgramTimeEnd') ProgramTimeEndDateTime = func.datetime_from_string( ProgramTimeEndString, '%Y-%m-%d %H:%M:%S') #Check if program is recording event and if the recording is planned or done recordProgramEvent = func.search_programid_jsonrecording_event( ProgramId) if recordProgramEvent: if datetime.now() > ProgramTimeEndDateTime: updateItem.setProperty('ProgramRecordEventPlanned', 'false') updateItem.setProperty('ProgramRecordEventDone', 'true') else: updateItem.setProperty('ProgramRecordEventPlanned', 'true') updateItem.setProperty('ProgramRecordEventDone', 'false') updateItem.setProperty( 'ProgramRecordEventId', metadatainfo.contentId_from_json_metadata( recordProgramEvent)) updateItem.setProperty( 'ProgramStartDeltaTime', str( metadatainfo.programstartdeltatime_from_json_metadata( recordProgramEvent))) else: updateItem.setProperty('ProgramRecordEventPlanned', 'false') updateItem.setProperty('ProgramRecordEventDone', 'false') updateItem.setProperty('ProgramRecordEventId', '') updateItem.setProperty('ProgramStartDeltaTime', '0')
def load_program(self, forceLoad=False, forceUpdate=False, silentUpdate=True): if forceUpdate == True and silentUpdate == False: notificationIcon = path.resources('resources/skins/default/media/common/vod.png') xbmcgui.Dialog().notification(var.addonname, "Programma's worden vernieuwd.", notificationIcon, 2500, False) #Get and check the list container listcontainer = self.getControl(1000) if forceLoad == False and forceUpdate == False: if listcontainer.size() > 0: return True else: listcontainer.reset() #Download the programs func.updateLabelText(self, 1, "Programma's downloaden") downloadResult = download.download_vod_yesterday(forceUpdate) if downloadResult == False: func.updateLabelText(self, 1, 'Niet beschikbaar') listcontainer = self.getControl(1001) self.setFocus(listcontainer) xbmc.sleep(100) listcontainer.selectItem(0) xbmc.sleep(100) return False #Add programs to the list func.updateLabelText(self, 1, "Programma's laden") for program in var.YesterdaySearchDataJson['resultObj']['containers']: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata(program) ProgramNameRaw = ProgramName EpisodeTitle = metadatainfo.episodetitle_from_json_metadata(program, True, ProgramNameRaw) ProgramTimeEndDateTime = metadatainfo.programenddatetime_from_json_metadata(program) #Check if there are search results if var.SearchFilterTerm != '': searchMatch1 = func.search_filter_string(ProgramName) searchMatch2 = func.search_filter_string(EpisodeTitle) searchResultFound = var.SearchFilterTerm in searchMatch1 or var.SearchFilterTerm in searchMatch2 if searchResultFound == False: continue #Check if program has finished airing and processing if datetime.now() < (ProgramTimeEndDateTime + timedelta(minutes=var.RecordingProcessMinutes)): continue #Load program details ExternalId = metadatainfo.externalChannelId_from_json_metadata(program) ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramYear = metadatainfo.programyear_from_json_metadata(program) ProgramSeason = metadatainfo.programseason_from_json_metadata(program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata(program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata(program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata(program, False) ProgramDescription = metadatainfo.programdescription_from_json_metadata(program) ProgramTimeStartDateTime = metadatainfo.programstartdatetime_from_json_metadata(program) ProgramTimeStartDateTime = func.datetime_remove_seconds(ProgramTimeStartDateTime) ProgramTimeStartStringTime = ProgramTimeStartDateTime.strftime('%H:%M') ProgramTimeStartStringDate = ProgramTimeStartDateTime.strftime('%a, %d %B %Y') ProgramTime = '[COLOR gray]Begon om ' + ProgramTimeStartStringTime + ' op ' + ProgramTimeStartStringDate + ' en duurde ' + ProgramDuration + '[/COLOR]' #Combine program details stringJoin = [ EpisodeTitle, ProgramYear, ProgramSeason, ProgramEpisode, ProgramAgeRating ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' #Update program name string ProgramName = ProgramNameRaw + ' [COLOR gray]' + ProgramDetails + '[/COLOR]' ProgramNameDesc = ProgramNameRaw + '\n[COLOR gray]' + ProgramDetails + '[/COLOR]' #Add program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_stream') listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty("ProgramNameDesc", ProgramNameDesc) listitem.setProperty("ProgramNameRaw", ProgramNameRaw) listitem.setProperty("ProgramDetails", ProgramTime) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', {'Genre': 'Gister Gemist', 'Plot': ProgramDescription}) listitem.setArt({'thumb': path.icon_television(ExternalId), 'icon': path.icon_television(ExternalId)}) listcontainer.addItem(listitem) except: continue #Update the status self.count_program(True)
def add_movies_week(self, listcontainersort): for program in var.MovieSearchDataJson['resultObj']['containers']: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata( program, True) #Check if there are search results if var.SearchFilterTerm != '': searchMatch = func.search_filter_string(ProgramName) searchResultFound = var.SearchFilterTerm in searchMatch if searchResultFound == False: continue #Load program details ExternalId = metadatainfo.externalChannelId_from_json_metadata( program) PictureUrl = metadatainfo.pictureUrl_from_json_metadata( program) ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramSeason = metadatainfo.programseason_from_json_metadata( program) ProgramStarRating = metadatainfo.programstarrating_from_json_metadata( program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata( program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata( program) ProgramDescription = metadatainfo.programdescription_from_json_metadata( program) ProgramAvailability = metadatainfo.vod_week_available_time( program) #Combine program details stringJoin = [ ProgramYear, ProgramSeason, ProgramStarRating, ProgramAgeRating, ProgramDuration ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' ProgramDetails = '[COLOR gray]' + ProgramDetails + '[/COLOR]' #Add week program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_stream_week') listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty("ProgramWeek", 'true') listitem.setProperty("ProgramDetails", ProgramDetails) listitem.setProperty("ProgramAvailability", ProgramAvailability) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', { 'Genre': 'Films', 'Plot': ProgramDescription }) iconStreamType = "common/calendarweek.png" iconProgram = path.icon_epg(PictureUrl) iconChannel = path.icon_television(ExternalId) listitem.setArt({ 'thumb': iconProgram, 'icon': iconProgram, 'image1': iconStreamType, 'image2': iconChannel }) listcontainersort.append(listitem) except: continue
def add_movies_vod(self, listcontainersort): for program in var.ChannelsDataJsonMovies['resultObj']['containers']: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata( program) TechnicalPackageIds = metadatainfo.technicalPackageIds_from_json_metadata( program) #Check if there are search results if var.SearchFilterTerm != '': searchMatch = func.search_filter_string(ProgramName) searchResultFound = var.SearchFilterTerm in searchMatch if searchResultFound == False: continue #Check if content is pay to play if metadatainfo.program_check_paytoplay(TechnicalPackageIds): continue #Load program details PictureUrl = metadatainfo.pictureUrl_from_json_metadata( program) ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramSeason = metadatainfo.programseason_from_json_metadata( program) ProgramStarRating = metadatainfo.programstarrating_from_json_metadata( program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata( program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata( program) ProgramDescription = metadatainfo.programdescription_from_json_metadata( program) ProgramAvailability = metadatainfo.vod_ondemand_available_time( program) #Combine program details stringJoin = [ ProgramYear, ProgramSeason, ProgramStarRating, ProgramAgeRating, ProgramDuration ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' ProgramDetails = '[COLOR gray]' + ProgramDetails + '[/COLOR]' #Add vod program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_stream_vod') listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty("ProgramDetails", ProgramDetails) listitem.setProperty("ProgramAvailability", ProgramAvailability) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', { 'Genre': 'Films', 'Plot': ProgramDescription }) iconStreamType = "common/vod.png" iconProgram = path.icon_vod(PictureUrl) listitem.setArt({ 'thumb': iconProgram, 'icon': iconProgram, 'image1': iconStreamType }) listcontainersort.append(listitem) except: continue
def load_recording(self, forceUpdate=False): listcontainer = self.getControl(1000) listcontainer.reset() #Download the recording programs func.updateLabelText(self, 3001, "Geplande opnames worden gedownload.") downloadResult = download.download_recording_event(forceUpdate) if downloadResult == False: func.updateLabelText(self, 3001, 'Geplande opnames zijn niet beschikbaar') closeButton = self.getControl(4000) self.setFocus(closeButton) xbmc.sleep(100) return False #Sort recording by upcoming time func.updateLabelText(self, 3001, "Geplande opnames worden geladen.") RecordingEvents = var.ChannelsDataJsonRecordingEvent["resultObj"][ "containers"] RecordingEvents = sorted( RecordingEvents, key=lambda x: x['metadata']['programStartTime'], reverse=False) #Process all the planned recording for program in RecordingEvents: try: #Load program basics ProgramTimeEndDateTime = metadatainfo.programenddatetime_generate_from_json_metadata( program) #Check if recording is planned or already recorded if ProgramTimeEndDateTime < datetime.now(): continue #Load program details ExternalId = metadatainfo.externalChannelId_from_json_metadata( program) ProgramRecordEventId = metadatainfo.contentId_from_json_metadata( program) ProgramStartDeltaTime = str( metadatainfo.programstartdeltatime_from_json_metadata( program)) ProgramName = metadatainfo.programtitle_from_json_metadata( program) ProgramTimeStartDateTime = metadatainfo.programstartdatetime_from_json_metadata( program) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramSeason = metadatainfo.programseason_from_json_metadata( program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata( program) ProgramDescription = 'Van ' + ProgramTimeStartDateTime.strftime( '%H:%M') + ' tot ' + ProgramTimeEndDateTime.strftime( '%H:%M') + ' op ' + ProgramTimeStartDateTime.strftime( '%a, %d %B %Y') #Combine program details stringJoin = [ProgramYear, ProgramSeason, ProgramEpisode] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' #Update program name string ProgramName += ' [COLOR gray]' + ProgramDetails + '[/COLOR]' #Add recording event to the list listitem = xbmcgui.ListItem() listitem.setProperty('ProgramRecordEventId', ProgramRecordEventId) listitem.setProperty('ProgramStartDeltaTime', ProgramStartDeltaTime) listitem.setProperty('ProgramName', ProgramName) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setArt({ 'thumb': path.icon_television(ExternalId), 'icon': path.icon_television(ExternalId) }) listcontainer.addItem(listitem) except: continue #Update the status self.count_recording(True) #Update the main page count if var.guiMain != None: var.guiMain.count_recorded_event() var.guiMain.count_recording_event()
def load_episodes_week(self, listItem, selectList=False): #Get the selected parentid selectedSeriesName = listItem.getProperty('ProgramName') selectedPictureUrl = listItem.getProperty('PictureUrl') #Get and check the list container listcontainer = self.getControl(1002) listcontainer.reset() listcontainersort = [] #Update the episodes status func.updateLabelText(self, 2, 'Afleveringen laden') #Process all the episodes for program in var.SeriesSearchDataJson["resultObj"]["containers"]: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata( program, True) #Check if program matches serie checkSerie1 = ProgramName.lower() checkSerie2 = selectedSeriesName.lower() if checkSerie1 != checkSerie2: continue #Load program details ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramSeasonInt = metadatainfo.programseason_from_json_metadata( program, False) ProgramEpisodeInt = metadatainfo.episodenumber_from_json_metadata( program, False) EpisodeTitle = metadatainfo.episodetitle_from_json_metadata( program, False, ProgramName) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramSeason = metadatainfo.programseason_from_json_metadata( program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata( program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata( program) ProgramDescription = metadatainfo.programdescription_from_json_metadata( program) ProgramAvailability = metadatainfo.vod_week_available_time( program) #Combine program details stringJoin = [ ProgramYear, ProgramSeason, ProgramEpisode, ProgramDuration ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' ProgramDetails = '[COLOR gray]' + ProgramDetails + '[/COLOR]' #Add vod program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_episode_week') listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", EpisodeTitle) listitem.setProperty("ProgramSeasonInt", ProgramSeasonInt) listitem.setProperty("ProgramEpisodeInt", ProgramEpisodeInt) listitem.setProperty('ProgramDetails', ProgramDetails) listitem.setProperty("ProgramAvailability", ProgramAvailability) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', { 'Genre': selectedSeriesName, 'Plot': ProgramDescription }) listitem.setArt({ 'thumb': path.icon_epg(selectedPictureUrl), 'icon': path.icon_epg(selectedPictureUrl) }) listcontainersort.append(listitem) except: continue #Sort and add episodes listcontainersort.sort( key=lambda x: (int(x.getProperty('ProgramSeasonInt')), int(x.getProperty('ProgramEpisodeInt')))) listcontainer.addItems(listcontainersort) #Update the episodes status func.updateLabelText( self, 2, selectedSeriesName + ' (' + str(listcontainer.size()) + ' afleveringen)') #Select the list container if selectList == True and listcontainer.size() > 0: self.setFocus(listcontainer) xbmc.sleep(100) listcontainer.selectItem(0) xbmc.sleep(100)
def load_episodes_vod(self, listItem, selectList=False): #Get the selected parentid selectedParentId = listItem.getProperty('ProgramId') selectedSeriesName = listItem.getProperty('ProgramName') selectedPictureUrl = listItem.getProperty('PictureUrl') #Get and check the list container listcontainer = self.getControl(1002) listcontainer.reset() #Update the episodes status func.updateLabelText(self, 2, 'Afleveringen downloaden') #Download the series episodes seasonDownloaded = download.download_series_season(selectedParentId) if seasonDownloaded == None: func.updateLabelText(self, 2, 'Afleveringen niet beschikbaar') return False #Update the episodes status func.updateLabelText(self, 2, 'Afleveringen laden') #Process all the episodes for program in seasonDownloaded["resultObj"]["containers"]: try: #Load program basics TechnicalPackageIds = metadatainfo.technicalPackageIds_from_json_metadata( program) #Check if content is pay to play if metadatainfo.program_check_paytoplay(TechnicalPackageIds): continue #Load program details ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramName = metadatainfo.programtitle_from_json_metadata( program) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramSeason = metadatainfo.programseason_from_json_metadata( program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata( program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata( program) ProgramDescription = metadatainfo.programdescription_from_json_metadata( program) ProgramAvailability = metadatainfo.vod_ondemand_available_time( program) #Combine program details stringJoin = [ ProgramYear, ProgramSeason, ProgramEpisode, ProgramDuration ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' ProgramDetails = '[COLOR gray]' + ProgramDetails + '[/COLOR]' #Add vod program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_episode_vod') listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty('ProgramDetails', ProgramDetails) listitem.setProperty("ProgramAvailability", ProgramAvailability) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', { 'Genre': selectedSeriesName, 'Plot': ProgramDescription }) listitem.setArt({ 'thumb': path.icon_vod(selectedPictureUrl), 'icon': path.icon_vod(selectedPictureUrl) }) listcontainer.addItem(listitem) except: continue #Update the episodes status func.updateLabelText( self, 2, selectedSeriesName + ' (' + str(listcontainer.size()) + ' afleveringen)') #Select the list container if selectList == True and listcontainer.size() > 0: self.setFocus(listcontainer) xbmc.sleep(100) listcontainer.selectItem(0) xbmc.sleep(100)
def load_program(self, forceLoad=False, forceUpdate=False): if forceUpdate == True: notificationIcon = path.resources('resources/skins/default/media/common/recorddone.png') xbmcgui.Dialog().notification(var.addonname, 'Opnames worden vernieuwd.', notificationIcon, 2500, False) #Get and check the list container listcontainer = self.getControl(1000) if forceLoad == False and forceUpdate == False: if listcontainer.size() > 0: return True else: listcontainer.reset() #Download the programs func.updateLabelText(self, 1, "Opnames downloaden") downloadResult = download.download_recording_event(forceUpdate) if downloadResult == False: func.updateLabelText(self, 1, 'Niet beschikbaar') listcontainer = self.getControl(1001) self.setFocus(listcontainer) xbmc.sleep(100) listcontainer.selectItem(0) xbmc.sleep(100) return False #Add programs to the list func.updateLabelText(self, 1, "Opnames laden") for program in var.ChannelsDataJsonRecordingEvent['resultObj']['containers']: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata(program) ProgramNameRaw = ProgramName ProgramTimeEndDateTime = metadatainfo.programenddatetime_generate_from_json_metadata(program) #Check if there are search results if var.SearchFilterTerm != '': searchMatch = func.search_filter_string(ProgramName) searchResultFound = var.SearchFilterTerm in searchMatch if searchResultFound == False: continue #Check if program has finished airing and processing if datetime.now() < (ProgramTimeEndDateTime + timedelta(minutes=var.RecordingProcessMinutes)): continue #Check if program is available for streaming AssetsLength = len(program['assets']) if AssetsLength > 0: AssetsStatus = str(program['assets'][0]['status']) if AssetsStatus == 'RecordFailed': ProgramName = '(Opname mislukt) ' + ProgramName elif AssetsStatus == 'ScheduleSuccess': ProgramName = '(Geplande opname) ' + ProgramName else: ProgramName = '(Niet speelbaar) ' + ProgramName #Load program details ExternalId = metadatainfo.externalChannelId_from_json_metadata(program) ProgramAssetId = metadatainfo.get_stream_assetid(program['assets']) ProgramRecordEventId = metadatainfo.contentId_from_json_metadata(program) EpisodeTitle = metadatainfo.episodetitle_from_json_metadata(program, True, ProgramNameRaw) ProgramYear = metadatainfo.programyear_from_json_metadata(program) ProgramSeason = metadatainfo.programseason_from_json_metadata(program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata(program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata(program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata(program, False) ProgramDescription = metadatainfo.programdescription_from_json_metadata(program) ProgramStartDeltaTime = str(metadatainfo.programstartdeltatime_from_json_metadata(program)) ProgramTimeStartDateTime = metadatainfo.programstartdatetime_from_json_metadata(program) ProgramTimeStartDateTime = func.datetime_remove_seconds(ProgramTimeStartDateTime) ProgramTimeStartStringTime = ProgramTimeStartDateTime.strftime('%H:%M') ProgramTimeStartStringDate = ProgramTimeStartDateTime.strftime('%a, %d %B %Y') ProgramTime = '[COLOR gray]Begon om ' + ProgramTimeStartStringTime + ' op ' + ProgramTimeStartStringDate + ' en duurde ' + ProgramDuration + '[/COLOR]' ProgramAvailability = metadatainfo.recording_available_time(program) #Combine program details stringJoin = [ EpisodeTitle, ProgramYear, ProgramSeason, ProgramEpisode, ProgramAgeRating ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' #Update program name string ProgramName = ProgramNameRaw + ' [COLOR gray]' + ProgramDetails + '[/COLOR]' ProgramNameDesc = ProgramNameRaw + '\n[COLOR gray]' + ProgramDetails + '[/COLOR]\n' + ProgramAvailability #Add program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_stream') listitem.setProperty('ProgramAssetId', ProgramAssetId) listitem.setProperty('ProgramRecordEventId', ProgramRecordEventId) listitem.setProperty('ProgramStartDeltaTime', ProgramStartDeltaTime) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty("ProgramNameDesc", ProgramNameDesc) listitem.setProperty("ProgramNameRaw", ProgramNameRaw) listitem.setProperty("ProgramDetails", ProgramTime) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', {'Genre': 'Opname', 'Plot': ProgramDescription}) listitem.setArt({'thumb': path.icon_television(ExternalId), 'icon': path.icon_television(ExternalId)}) listcontainer.addItem(listitem) except: continue #Update the status self.count_program(True) #Update the main page count if var.guiMain != None: var.guiMain.count_recorded_event() var.guiMain.count_recording_event()
def load_epg(self, forceUpdate=False): #Check if channel has changed epgChannelChanged = self.EpgPreviousChannelId != self.EpgCurrentChannelId #Check if the day has changed dateTimeNow = datetime.now() dateTimeNowString = dateTimeNow.strftime('%Y-%m-%d') epgDayString = ( dateTimeNow + timedelta(days=self.EpgCurrentLoadDayInt)).strftime('%Y-%m-%d') epgDayChanged = self.EpgPreviousLoadDayInt != self.EpgCurrentLoadDayInt epgDayTimeChanged = self.EpgPreviousLoadDateTime != dateTimeNowString #Check if update is needed if forceUpdate or epgChannelChanged or epgDayChanged or epgDayTimeChanged: #Get and check the list container listcontainer = self.getControl(1002) #Clear the current epg items listcontainer.reset() #Download the epg day information func.updateLabelText(self, 1, 'Gids download') func.updateLabelText( self, 2, 'TV Gids wordt gedownload, nog even geduld...') self.EpgCurrentDayJson = download.download_epg_day( epgDayString, forceUpdate) if self.EpgCurrentDayJson == None: func.updateLabelText(self, 1, 'Niet beschikbaar') func.updateLabelText(self, 2, 'TV Gids is niet beschikbaar.') listcontainer = self.getControl(1000) self.setFocus(listcontainer) xbmc.sleep(100) listcontainer.selectItem(0) xbmc.sleep(100) return else: #Load program progress self.load_progress() #Update the status self.count_epg(self.EpgCurrentChannelName) return #Update epg status func.updateLabelText(self, 1, 'Gids laden') func.updateLabelText(self, 2, 'TV Gids wordt geladen, nog even geduld...') ChannelEpg = func.search_channelid_jsonepg(self.EpgCurrentDayJson, self.EpgCurrentChannelId) if ChannelEpg == None: func.updateLabelText(self, 1, 'Zender gids mist') func.updateLabelText( self, 2, 'Gids is niet beschikbaar voor ' + self.EpgCurrentChannelName + '.') return programSelectIndex = 0 programCurrentIndex = 0 for program in ChannelEpg['containers']: try: #Load program basics ProgramTimeStartDateTime = metadatainfo.programstartdatetime_from_json_metadata( program) ProgramTimeStartDateTime = func.datetime_remove_seconds( ProgramTimeStartDateTime) ProgramTimeEndDateTime = metadatainfo.programenddatetime_from_json_metadata( program) #Check if program is starting or ending on target day ProgramTimeStartDayString = ProgramTimeStartDateTime.strftime( '%Y-%m-%d') ProgramTimeEndDayString = ProgramTimeEndDateTime.strftime( '%Y-%m-%d') if ProgramTimeStartDayString != epgDayString and ProgramTimeEndDayString != epgDayString: continue #Load program details ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramName = metadatainfo.programtitle_from_json_metadata( program) ProgramProgressPercent = int( ((dateTimeNow - ProgramTimeStartDateTime).total_seconds() / 60) * 100 / ((ProgramTimeEndDateTime - ProgramTimeStartDateTime).total_seconds() / 60)) ProgramDurationString = metadatainfo.programdurationstring_from_json_metadata( program, False, False) EpisodeTitle = metadatainfo.episodetitle_from_json_metadata( program, True, ProgramName) ProgramYear = metadatainfo.programyear_from_json_metadata( program) ProgramSeason = metadatainfo.programseason_from_json_metadata( program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata( program) ProgramStarRating = metadatainfo.programstarrating_from_json_metadata( program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata( program) ProgramGenres = metadatainfo.programgenres_from_json_metadata( program) ProgramDescriptionRaw = metadatainfo.programdescription_from_json_metadata( program) ProgramDescription = 'Programmabeschrijving wordt geladen.' ProgramEpgList = 'Programmaduur wordt geladen' #Combine program details stringJoin = [ EpisodeTitle, ProgramYear, ProgramSeason, ProgramEpisode, ProgramStarRating, ProgramAgeRating, ProgramGenres ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = 'Onbekend seizoen en aflevering' #Check if program vod is available for playback contentOptionsArray = metadatainfo.contentOptions_from_json_metadata( program) if 'CATCHUP' in contentOptionsArray: ProgramAvailable = 'true' else: ProgramAvailable = 'false' #Check if the program is part of series ProgramRecordSeriesId = metadatainfo.seriesId_from_json_metadata( program) #Check if current program is a rerun programRerunName = any(substring for substring in var.EpgRerunSearchTerm if substring in ProgramName.lower()) programRerunDescription = any( substring for substring in var.EpgRerunSearchTerm if substring in ProgramDescription.lower()) if programRerunName or programRerunDescription: ProgramRerun = 'true' else: ProgramRerun = 'false' #Add program to the list container listitem = xbmcgui.ListItem() listitem.setProperty('ProgramId', ProgramId) listitem.setProperty('AssetId', self.EpgCurrentAssetId) listitem.setProperty('ChannelId', self.EpgCurrentChannelId) listitem.setProperty('ExternalId', self.EpgCurrentExternalId) listitem.setProperty('ChannelName', self.EpgCurrentChannelName) listitem.setProperty('ProgramName', ProgramName) listitem.setProperty('ProgramRerun', ProgramRerun) listitem.setProperty('ProgramDuration', ProgramDurationString) listitem.setProperty('ProgramRecordSeriesId', ProgramRecordSeriesId) listitem.setProperty('ProgramDescriptionRaw', ProgramDescriptionRaw) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setProperty('ProgramEpgList', ProgramEpgList) listitem.setProperty('ProgramDetails', ProgramDetails) listitem.setProperty('ProgramTimeStart', str(ProgramTimeStartDateTime)) listitem.setProperty('ProgramTimeEnd', str(ProgramTimeEndDateTime)) listitem.setInfo('video', { 'Genre': 'TV Gids', 'Plot': ProgramDescriptionRaw }) listitem.setArt({ 'thumb': path.icon_television(self.EpgCurrentExternalId), 'icon': path.icon_television(self.EpgCurrentExternalId) }) #Check if program finished airing if ProgramProgressPercent >= 100: listitem.setProperty('ProgramAvailable', ProgramAvailable) #Check if program is still airing if ProgramProgressPercent > 0 and ProgramProgressPercent < 100: programSelectIndex = programCurrentIndex programCurrentIndex += 1 listcontainer.addItem(listitem) except: continue #Select program list item listcontainer.selectItem(programSelectIndex) xbmc.sleep(100) #Load program progress self.load_progress() #Update epg variables self.EpgPreviousChannelId = self.EpgCurrentChannelId self.EpgPreviousLoadDayInt = self.EpgCurrentLoadDayInt self.EpgPreviousLoadDateTime = dateTimeNowString #Update the status self.count_epg(self.EpgCurrentChannelName)
def load_progress(self): #Get and check the list container listcontainer = self.getControl(1002) listitemcount = listcontainer.size() #Clear expired alarms from Json alarm.alarm_clean_expired() #Generate program progress for programs dateTimeNow = datetime.now() for programNum in range(0, listitemcount): try: #Get program information list item updateItem = listcontainer.getListItem(programNum) ChannelId = updateItem.getProperty('ChannelId') ProgramId = updateItem.getProperty('ProgramId') ProgramName = updateItem.getProperty('ProgramName') ProgramDescriptionRaw = updateItem.getProperty( 'ProgramDescriptionRaw') ProgramDetailsProp = updateItem.getProperty('ProgramDetails') ProgramRecordSeriesId = updateItem.getProperty( 'ProgramRecordSeriesId') ProgramTimeStartProp = updateItem.getProperty( 'ProgramTimeStart') ProgramTimeStartDateTime = func.datetime_from_string( ProgramTimeStartProp, '%Y-%m-%d %H:%M:%S') ProgramTimeStartString = ProgramTimeStartDateTime.strftime( '%H:%M') ProgramTimeEndProp = updateItem.getProperty('ProgramTimeEnd') ProgramTimeEndDateTime = func.datetime_from_string( ProgramTimeEndProp, '%Y-%m-%d %H:%M:%S') ProgramTimeEndString = ProgramTimeEndDateTime.strftime('%H:%M') ProgramTimeLeftMinutes = int( (ProgramTimeEndDateTime - dateTimeNow).total_seconds() / 60) ProgramTimeLeftString = str(ProgramTimeLeftMinutes) ProgramDurationString = updateItem.getProperty( 'ProgramDuration') #Update program progress ProgramProgressPercent = int( ((dateTimeNow - ProgramTimeStartDateTime).total_seconds() / 60) * 100 / ((ProgramTimeEndDateTime - ProgramTimeStartDateTime).total_seconds() / 60)) #Set program duration text if ProgramDurationString == '0': ProgramTimingEpgList = ' onbekend programmaduur' ProgramTimingDescription = ' onbekend programmaduur' if func.date_time_between(dateTimeNow, ProgramTimeStartDateTime, ProgramTimeEndDateTime): if ProgramTimeLeftString == '0': ProgramTimingEpgList = ' is bijna afgelopen, duurde ' + ProgramDurationString + ' minuten' ProgramTimingDescription = ' is bijna afgelopen, duurde ' + ProgramDurationString + ' minuten, begon om ' + ProgramTimeStartString else: ProgramTimingEpgList = ' duurt nog ' + ProgramTimeLeftString + ' van de ' + ProgramDurationString + ' minuten' ProgramTimingDescription = ' duurt nog ' + ProgramTimeLeftString + ' van de ' + ProgramDurationString + ' minuten, begon om ' + ProgramTimeStartString + ' eindigt rond ' + ProgramTimeEndString elif dateTimeNow > ProgramTimeEndDateTime: ProgramTimingEpgList = ' duurde ' + ProgramDurationString + ' minuten' ProgramTimingDescription = ' duurde ' + ProgramDurationString + ' minuten, begon om ' + ProgramTimeStartString + ' eindigde rond ' + ProgramTimeEndString else: ProgramTimingEpgList = ' duurt ' + ProgramDurationString + ' minuten' ProgramTimingDescription = ' duurt ' + ProgramDurationString + ' minuten, begint om ' + ProgramTimeStartString + ' eindigt rond ' + ProgramTimeEndString #Check if program has active alarm if alarm.alarm_duplicate_program_check( ProgramTimeStartDateTime, ChannelId) == True: ProgramAlarm = 'true' else: ProgramAlarm = 'false' #Check if program is recording event and if the recording is planned or done recordProgramEvent = func.search_programid_jsonrecording_event( ProgramId) if recordProgramEvent: if dateTimeNow > ProgramTimeEndDateTime: ProgramRecordEventPlanned = 'false' ProgramRecordEventDone = 'true' else: ProgramRecordEventPlanned = 'true' ProgramRecordEventDone = 'false' ProgramRecordEventId = metadatainfo.contentId_from_json_metadata( recordProgramEvent) ProgramStartDeltaTime = str( metadatainfo.programstartdeltatime_from_json_metadata( recordProgramEvent)) else: ProgramRecordEventPlanned = 'false' ProgramRecordEventDone = 'false' ProgramRecordEventId = '' ProgramStartDeltaTime = '0' #Check if program is recording series recordProgramSeries = func.search_seriesid_jsonrecording_series( ProgramRecordSeriesId) if recordProgramSeries: ProgramRecordSeries = 'true' else: ProgramRecordSeries = 'false' #Combine the program description ProgramEpgList = ProgramTimeStartString + ProgramTimingEpgList ProgramDescription = '[COLOR white]' + ProgramName + ProgramTimingDescription + '[/COLOR]\n\n[COLOR gray]' + ProgramDetailsProp + '[/COLOR]\n\n[COLOR white]' + ProgramDescriptionRaw + '[/COLOR]' #Update program list item updateItem.setProperty('ProgramEpgList', ProgramEpgList) updateItem.setProperty('ProgramDescription', ProgramDescription) updateItem.setProperty('ProgramAlarm', ProgramAlarm) updateItem.setProperty('ProgramStartDeltaTime', ProgramStartDeltaTime) updateItem.setProperty('ProgramRecordEventPlanned', ProgramRecordEventPlanned) updateItem.setProperty('ProgramRecordEventDone', ProgramRecordEventDone) updateItem.setProperty('ProgramRecordEventId', ProgramRecordEventId) updateItem.setProperty('ProgramRecordSeries', ProgramRecordSeries) updateItem.setProperty('ProgramProgressPercent', str(ProgramProgressPercent)) except: pass #Update the selected channel alarm icon self.update_channel_alarm_icon(ChannelId) #Update the selected channel recording event icon self.update_channel_record_event_icon(ChannelId) #Update the selected channel recording series icon self.update_channel_record_series_icon(ChannelId)
def search_list(self, downloadResult=None): #Get and check the list container listcontainer = self.getControl(1000) listcontainer.reset() #Add programs to the list for program in downloadResult['resultObj']['containers']: try: #Load program basics ProgramName = metadatainfo.programtitle_from_json_metadata(program) ProgramNameRaw = ProgramName EpisodeTitle = metadatainfo.episodetitle_from_json_metadata(program, True, ProgramNameRaw) #Check if there are search results if var.SearchFilterTerm != '': searchMatch1 = func.search_filter_string(ProgramName) searchMatch2 = func.search_filter_string(EpisodeTitle) searchResultFound = var.SearchFilterTerm in searchMatch1 or var.SearchFilterTerm in searchMatch2 if searchResultFound == False: continue #Load program details ExternalId = metadatainfo.externalChannelId_from_json_metadata(program) ProgramId = metadatainfo.contentId_from_json_metadata(program) ProgramYear = metadatainfo.programyear_from_json_metadata(program) ProgramSeason = metadatainfo.programseason_from_json_metadata(program) ProgramEpisode = metadatainfo.episodenumber_from_json_metadata(program) ProgramAgeRating = metadatainfo.programagerating_from_json_metadata(program) ProgramDuration = metadatainfo.programdurationstring_from_json_metadata(program, False) ProgramDescription = metadatainfo.programdescription_from_json_metadata(program) ProgramTimeStartDateTime = metadatainfo.programstartdatetime_from_json_metadata(program) ProgramTimeStartDateTime = func.datetime_remove_seconds(ProgramTimeStartDateTime) ProgramTimeStartStringTime = ProgramTimeStartDateTime.strftime('%H:%M') ProgramTimeStartStringDate = ProgramTimeStartDateTime.strftime('%a, %d %B %Y') ProgramTime = '[COLOR gray]Begon om ' + ProgramTimeStartStringTime + ' op ' + ProgramTimeStartStringDate + ' en duurde ' + ProgramDuration + '[/COLOR]' ProgramAvailability = metadatainfo.vod_week_available_time(program) #Combine program details stringJoin = [ EpisodeTitle, ProgramYear, ProgramSeason, ProgramEpisode, ProgramAgeRating ] ProgramDetails = ' '.join(filter(None, stringJoin)) if func.string_isnullorempty(ProgramDetails): ProgramDetails = '(?)' #Update program name string ProgramName = ProgramNameRaw + ' [COLOR gray]' + ProgramDetails + '[/COLOR]' ProgramNameDesc = ProgramNameRaw + '\n[COLOR gray]' + ProgramDetails + '[/COLOR]\n' + ProgramAvailability #Add program listitem = xbmcgui.ListItem() listitem.setProperty('Action', 'play_stream') listitem.setProperty('ProgramId', ProgramId) listitem.setProperty("ProgramName", ProgramName) listitem.setProperty("ProgramNameDesc", ProgramNameDesc) listitem.setProperty("ProgramNameRaw", ProgramNameRaw) listitem.setProperty("ProgramDetails", ProgramTime) listitem.setProperty('ProgramDescription', ProgramDescription) listitem.setInfo('video', {'Genre': 'Zoeken', 'Plot': ProgramDescription}) listitem.setArt({'thumb': path.icon_television(ExternalId), 'icon': path.icon_television(ExternalId)}) listcontainer.addItem(listitem) except: continue #Update the status self.count_program(True)