Exemple #1
0
def record_series_epg(_self, listItemSelected, forceRecord=False):
    ChannelId = listItemSelected.getProperty('ChannelId')
    ProgramRecordSeries = listItemSelected.getProperty('ProgramRecordSeries')
    ProgramRecordSeriesId = listItemSelected.getProperty(
        'ProgramRecordSeriesId')

    if ProgramRecordSeriesId == '':
        notificationIcon = path.resources(
            'resources/skins/default/media/common/recordseries.png')
        xbmcgui.Dialog().notification(
            var.addonname, 'Serie seizoen kan niet worden opgenomen.',
            notificationIcon, 2500, False)
        return

    if ProgramRecordSeries == 'false' or forceRecord == True:
        seriesAdd = download.record_series_add(ChannelId,
                                               ProgramRecordSeriesId)
        if seriesAdd == True:
            _self.update_channel_record_event_icon(ChannelId)
            _self.update_program_record_event()
            _self.update_channel_record_series_icon(ChannelId)
            _self.update_program_record_series()
    else:
        #Get the removal series id
        recordProgramSeries = func.search_seriesid_jsonrecording_series(
            ProgramRecordSeriesId)
        if recordProgramSeries:
            ProgramRecordSeriesIdLive = metadatainfo.seriesId_from_json_metadata(
                recordProgramSeries)
        else:
            notificationIcon = path.resources(
                'resources/skins/default/media/common/recordseries.png')
            xbmcgui.Dialog().notification(var.addonname,
                                          'Serie seizoen annulering mislukt.',
                                          notificationIcon, 2500, False)
            return

        #Ask user to remove recordings
        dialogAnswers = ['Opnames verwijderen', 'Opnames houden']
        dialogHeader = 'Serie opnames verwijderen'
        dialogSummary = 'Wilt u ook alle opnames van deze serie seizoen verwijderen?'
        dialogFooter = ''
        dialogResult = dialog.show_dialog(dialogHeader, dialogSummary,
                                          dialogFooter, dialogAnswers)
        if dialogResult == 'Opnames verwijderen':
            KeepRecording = False
        elif dialogResult == 'Opnames houden':
            KeepRecording = True
        else:
            return

        #Remove record series
        seriesRemove = download.record_series_remove(ProgramRecordSeriesIdLive,
                                                     KeepRecording)
        if seriesRemove == True:
            _self.update_channel_record_event_icon(ChannelId)
            _self.update_program_record_event()
            _self.update_channel_record_series_icon(ChannelId)
            _self.update_program_record_series()
Exemple #2
0
def search_seriesid_jsonrecording_series(searchSeriesId):
    if var.ChannelsDataJsonRecordingSeries == []: return None
    for Record in var.ChannelsDataJsonRecordingSeries["resultObj"][
            "containers"]:
        try:
            if metadatainfo.seriesId_from_json_metadata(
                    Record) == searchSeriesId:
                return Record
            if metadatainfo.seriesIdLive_from_json_metadata(
                    Record) == searchSeriesId:
                return Record
        except:
            continue
    return None
Exemple #3
0
def count_recorded_series(seriesId):
    try:
        if var.ChannelsDataJsonRecordingEvent == []: return ''
        recordedCount = 0
        for program in var.ChannelsDataJsonRecordingEvent["resultObj"][
                "containers"]:
            try:
                recordSeriesId = metadatainfo.seriesId_from_json_metadata(
                    program)
                if recordSeriesId == seriesId:
                    recordedCount += 1
            except:
                continue
        return '(' + str(recordedCount) + 'x)'
    except:
        return ''
Exemple #4
0
    def add_series_week(self, listcontainersort):
        for program in var.SeriesSearchDataJson['resultObj']['containers']:
            try:
                #Load program basics
                ProgramName = metadatainfo.programtitle_from_json_metadata(
                    program, True)

                #Check if serie is already added
                if func.search_programname_listarray(listcontainersort,
                                                     ProgramName) != None:
                    continue

                #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)
                SeriesId = metadatainfo.seriesId_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 program
                listitem = xbmcgui.ListItem()
                listitem.setProperty('Action', 'load_episodes_week')
                listitem.setProperty('PictureUrl', PictureUrl)
                listitem.setProperty('SeriesId', SeriesId)
                listitem.setProperty('ProgramId', ProgramId)
                listitem.setProperty("ProgramName", ProgramName)
                listitem.setProperty("ProgramWeek", 'true')
                listitem.setProperty('ProgramDetails', ProgramDetails)
                listitem.setInfo('video', {
                    'Genre': 'Series',
                    'Plot': ProgramDetails
                })
                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
Exemple #5
0
    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)
Exemple #6
0
    def load_recording(self, forceUpdate=False):
        listcontainer = self.getControl(1000)
        listcontainer.reset()

        #Download the tv channels
        func.updateLabelText(self, 3001,
                             'Televisie zenders worden gedownload.')
        download.download_channels_tv(False)

        #Download the recording programs
        func.updateLabelText(self, 3001, "Geplande series worden gedownload.")
        downloadResult = download.download_recording_series(forceUpdate)
        if downloadResult == False:
            func.updateLabelText(self, 3001,
                                 'Geplande series zijn niet beschikbaar')
            closeButton = self.getControl(4000)
            self.setFocus(closeButton)
            xbmc.sleep(100)
            return False

        #Process all the planned recording
        func.updateLabelText(self, 3001, "Geplande series worden geladen.")
        for program in var.ChannelsDataJsonRecordingSeries["resultObj"][
                "containers"]:
            try:
                #Load program basics
                ProgramSeriesId = metadatainfo.seriesId_from_json_metadata(
                    program)
                ProgramName = metadatainfo.programtitle_from_json_metadata(
                    program)

                #Check recorded episodes count
                ProgramEpisodeCount = count_recorded_series(ProgramSeriesId)

                #Get first recording event
                RecordingEvent = func.search_seriesid_jsonrecording_event(
                    ProgramSeriesId)

                #Load program details
                ProgramYear = metadatainfo.programyear_from_json_metadata(
                    RecordingEvent)
                ProgramSeason = metadatainfo.programseason_from_json_metadata(
                    RecordingEvent)

                #Combine program details
                stringJoin = [ProgramYear, ProgramSeason, ProgramEpisodeCount]
                ProgramDetails = ' '.join(filter(None, stringJoin))
                if func.string_isnullorempty(ProgramDetails):
                    ProgramDetails = '(?)'

                #Update program name string
                ProgramName += ' [COLOR gray]' + ProgramDetails + '[/COLOR]'

                #Get channel basics
                ChannelId = metadatainfo.channelId_from_json_metadata(program)
                ChannelName = 'Onbekende zender'
                ChannelIcon = path.resources(
                    'resources/skins/default/media/common/unknown.png')
                ChannelDetails = func.search_channelid_jsontelevision(
                    ChannelId)
                if ChannelDetails:
                    ExternalId = metadatainfo.externalId_from_json_metadata(
                        ChannelDetails)
                    ChannelName = metadatainfo.channelName_from_json_metadata(
                        ChannelDetails)
                    ChannelIcon = path.icon_television(ExternalId)

                #Add recording series to the list
                listitem = xbmcgui.ListItem()
                listitem.setProperty('SeriesId', ProgramSeriesId)
                listitem.setProperty('ProgramName', ProgramName)
                listitem.setProperty('ProgramDescription', ChannelName)
                listitem.setArt({'thumb': ChannelIcon, 'icon': ChannelIcon})
                listcontainer.addItem(listitem)
            except:
                continue

        #Update the status
        self.count_recording(True)

        #Update the main page count
        if var.guiMain != None:
            var.guiMain.count_recording_series()