Beispiel #1
0
    def set_alarm_next(self):
        #Get and check the list container
        listcontainer = self.getControl(1001)
        selectedItem = listcontainer.getSelectedItem()
        ProgramNextName = selectedItem.getProperty('ProgramNextName')
        ProgramNextTimeStartDateTime = func.datetime_from_string(
            selectedItem.getProperty("ProgramNextTimeStartDateTime"),
            '%Y-%m-%d %H:%M:%S')
        ChannelId = selectedItem.getProperty('ChannelId')
        ExternalId = selectedItem.getProperty('ExternalId')
        ChannelName = selectedItem.getProperty('ChannelName')

        #Check the program time
        if ProgramNextTimeStartDateTime != datetime(
                1970, 1, 1) and datetime.now() > ProgramNextTimeStartDateTime:
            notificationIcon = path.resources(
                'resources/skins/default/media/common/alarm.png')
            xbmcgui.Dialog().notification(var.addonname,
                                          'Programma is al afgelopen.',
                                          notificationIcon, 2500, False)
            return

        #Set or remove the next program alarm
        alarmAdded = alarm.alarm_add(ProgramNextTimeStartDateTime, ChannelId,
                                     ExternalId, ChannelName, ProgramNextName,
                                     True)

        #Update alarm icon in the information
        if alarmAdded == True:
            selectedItem.setProperty("ProgramNextAlarm", 'true')
        elif alarmAdded == 'Remove':
            selectedItem.setProperty("ProgramNextAlarm", 'false')
Beispiel #2
0
def alarm_notification():
    for alarm in var.AlarmDataJson:
        try:
            #Load alarm details
            #ChannelId = alarm['channelid']
            ExternalId = alarm['externalid']
            #ChannelName = alarm['channelname']
            ProgramName = alarm['programname']
            StartTime = alarm['starttime']

            #Calculate alarm times
            DateTimeNowDateTime = datetime.now()
            DateTimeNowString = DateTimeNowDateTime.strftime('%Y-%m-%d %H:%M')
            ProgramTimeStartDateTime = func.datetime_from_string(StartTime, '%Y-%m-%d %H:%M:%S')
            ProgramTimeStartPlusThreeDateTime = (ProgramTimeStartDateTime + timedelta(minutes=3))
            ProgramTimeStartMinOneString = (ProgramTimeStartDateTime - timedelta(minutes=1)).strftime('%Y-%m-%d %H:%M')
            ProgramTimeStartMinThreeString = (ProgramTimeStartDateTime - timedelta(minutes=3)).strftime('%Y-%m-%d %H:%M')
            ProgramTimeStartMinFiveString = (ProgramTimeStartDateTime - timedelta(minutes=5)).strftime('%Y-%m-%d %H:%M')
            ProgramTimeStartMinTenString = (ProgramTimeStartDateTime - timedelta(minutes=10)).strftime('%Y-%m-%d %H:%M')

            #Check alarm times
            if DateTimeNowDateTime >= ProgramTimeStartDateTime and DateTimeNowDateTime < ProgramTimeStartPlusThreeDateTime:
                xbmcgui.Dialog().notification(var.addonname, ProgramName + ' is begonnen.', path.icon_television(ExternalId), 5000, True)
            elif DateTimeNowString == ProgramTimeStartMinOneString:
                xbmcgui.Dialog().notification(var.addonname, ProgramName + ' begint over 1 minuut.', path.icon_television(ExternalId), 5000, True)
            elif DateTimeNowString == ProgramTimeStartMinThreeString:
                xbmcgui.Dialog().notification(var.addonname, ProgramName + ' begint over 3 minuten.', path.icon_television(ExternalId), 5000, True)
            elif DateTimeNowString == ProgramTimeStartMinFiveString:
                xbmcgui.Dialog().notification(var.addonname, ProgramName + ' begint over 5 minuten.', path.icon_television(ExternalId), 5000, True)
            elif DateTimeNowString == ProgramTimeStartMinTenString:
                xbmcgui.Dialog().notification(var.addonname, ProgramName + ' begint over 10 minuten.', path.icon_television(ExternalId), 5000, True)
        except:
            continue
Beispiel #3
0
def alarm_clean_expired(delayed=False):
    #Delay expired alarm cleaning
    if delayed == True:
        xbmc.sleep(2000)

    #Check if alarm has already passed
    for alarm in var.AlarmDataJson:
        try:
            ProgramTimeStartDateTime = func.datetime_from_string(alarm['starttime'], '%Y-%m-%d %H:%M:%S')
            ProgramTimeStartDateTime = func.datetime_remove_seconds(ProgramTimeStartDateTime)

            #Remove the alarm if it has passed
            if datetime.now() >= ProgramTimeStartDateTime:
                var.AlarmDataJson.remove(alarm)
        except:
            continue

    #Save the raw json data to storage
    JsonDumpBytes = json.dumps(var.AlarmDataJson).encode('ascii')
    files.saveFile('AlarmDataString1.js', JsonDumpBytes)

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

    #Update the alarm window count
    if var.guiAlarm != None:
        var.guiAlarm.count_alarm()

    return True
Beispiel #4
0
    def load_alarm(self):
        #Get and check the list container
        listcontainer = self.getControl(1000)
        listcontainer.reset()

        #Sort alarms by upcoming time
        var.AlarmDataJson.sort(key=lambda x: x['starttime'], reverse=False)

        for alarm in var.AlarmDataJson:
            try:
                ExternalId = alarm['externalid']
                #ChannelName = alarm['channelname']
                ProgramName = alarm['programname']
                ProgramTimeStart = alarm['starttime']

                ProgramTimeStartDateTime = func.datetime_from_string(ProgramTimeStart, '%Y-%m-%d %H:%M:%S')
                ProgramDescription = 'Om ' + ProgramTimeStartDateTime.strftime('%H:%M') + ' op ' + ProgramTimeStartDateTime.strftime('%a, %d %B %Y')

                listitem = xbmcgui.ListItem()
                listitem.setProperty('ProgramTimeStart', ProgramTimeStart)
                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_alarm(True)
Beispiel #5
0
def epg_day(dateStringDay):
    #Get all playable channel ids
    ChannelIdsPlayableString = ''
    for playableId in var.ChannelIdsPlayable:
        ChannelIdsPlayableString += playableId + ','
    ChannelIdsPlayableString = ChannelIdsPlayableString[:-1]

    #Set download time range
    datetimeMidnight = func.datetime_from_string(dateStringDay, '%Y-%m-%d')
    startTimeEpoch = func.datetime_to_ticks(datetimeMidnight -
                                            timedelta(hours=6))
    endTimeEpoch = func.datetime_to_ticks(datetimeMidnight +
                                          timedelta(hours=30))

    return api_url_120('TRAY/EPG?outputFormat=EXTENDED&filter_startTime=' +
                       str(startTimeEpoch) + '&filter_endTime=' +
                       str(endTimeEpoch) + '&filter_channelIds=' +
                       ChannelIdsPlayableString)
Beispiel #6
0
    def seek_begin_program(self):
        #Get and check the list container
        listcontainer = self.getControl(1001)
        selectedItem = listcontainer.getSelectedItem()

        ProgramNowTimeStartDateTime = func.datetime_from_string(
            selectedItem.getProperty("ProgramNowTimeStartDateTime"),
            '%Y-%m-%d %H:%M:%S')

        #Check the program start time
        if ProgramNowTimeStartDateTime != datetime(1970, 1, 1):
            playingSeconds = int(
                (datetime.now() - ProgramNowTimeStartDateTime).total_seconds())
            totalSeconds = int(xbmc.Player().getTotalTime())
            seekSeconds = totalSeconds - playingSeconds + 10
            if seekSeconds >= 0:
                #Seek to program beginning
                xbmc.Player().seekTime(seekSeconds)
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/rerun.png')
                xbmcgui.Dialog().notification(
                    var.addonname, 'Naar programma begin gespoeld.',
                    notificationIcon, 2500, False)

                #Select channel in list container
                CurrentChannelId = var.addon.getSetting('CurrentChannelId')
                func.focus_on_channel_list(self, 1001, 0, False,
                                           CurrentChannelId)
            else:
                notificationIcon = path.resources(
                    'resources/skins/default/media/common/rerun.png')
                xbmcgui.Dialog().notification(
                    var.addonname, 'Programma begin niet beschikbaar.',
                    notificationIcon, 2500, False)
        else:
            notificationIcon = path.resources(
                'resources/skins/default/media/common/rerun.png')
            xbmcgui.Dialog().notification(var.addonname,
                                          'Start tijd is onbekend.',
                                          notificationIcon, 2500, False)
Beispiel #7
0
    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')
Beispiel #8
0
    def set_program_alarm(self, listItemSelected):
        ProgramTimeStartString = listItemSelected.getProperty(
            'ProgramTimeStart')
        ProgramTimeStartDateTime = func.datetime_from_string(
            ProgramTimeStartString, '%Y-%m-%d %H:%M:%S')
        ProgramTimeStartDateTime = func.datetime_remove_seconds(
            ProgramTimeStartDateTime)

        ChannelId = listItemSelected.getProperty('ChannelId')
        ExternalId = listItemSelected.getProperty('ExternalId')
        ChannelName = listItemSelected.getProperty('ChannelName')
        ProgramName = listItemSelected.getProperty('ProgramName')

        alarmAdded = alarm.alarm_add(ProgramTimeStartDateTime, ChannelId,
                                     ExternalId, ChannelName, ProgramName,
                                     True)
        #Update alarm icon in the channel and epg list
        if alarmAdded == True:
            listItemSelected.setProperty('ProgramAlarm', 'true')
            self.update_channel_alarm_icon(ChannelId)
        elif alarmAdded == 'Remove':
            listItemSelected.setProperty('ProgramAlarm', 'false')
            self.update_channel_alarm_icon(ChannelId)
Beispiel #9
0
    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)
Beispiel #10
0
    def dialog_alarm_record(self, clickedControl):
        listItemSelected = clickedControl.getSelectedItem()
        ProgramTimeStartString = listItemSelected.getProperty(
            'ProgramTimeStart')
        ProgramTimeStartDateTime = func.datetime_from_string(
            ProgramTimeStartString, '%Y-%m-%d %H:%M:%S')
        ProgramTimeStartDateTime = func.datetime_remove_seconds(
            ProgramTimeStartDateTime)
        ProgramTimeEndString = listItemSelected.getProperty('ProgramTimeEnd')
        ProgramTimeEndDateTime = func.datetime_from_string(
            ProgramTimeEndString, '%Y-%m-%d %H:%M:%S')
        ProgramName = listItemSelected.getProperty('ProgramName')

        #Check if the current program is airing
        dateTimeNow = datetime.now()
        if var.RecordingAccess == True:
            if func.date_time_between(dateTimeNow, ProgramTimeStartDateTime,
                                      ProgramTimeEndDateTime):
                dialogAnswers = [
                    'Live programma kijken', 'Programma opnemen of annuleren',
                    'Serie seizoen opnemen of annuleren'
                ]
                dialogHeader = 'Programma kijken of opnemen'
                dialogSummary = ProgramName + ' kijken of opnemen?'
                dialogFooter = ''
            elif ProgramTimeStartDateTime < dateTimeNow:
                dialogAnswers = [
                    'Programma terug kijken',
                    'Serie seizoen opnemen of annuleren'
                ]
                dialogHeader = 'Programma terug kijken of opnemen'
                dialogSummary = ProgramName + ' terug kijken of opnemen?'
                dialogFooter = ''
            else:
                dialogAnswers = [
                    'Alarm zetten of annuleren',
                    'Programma opnemen of annuleren',
                    'Serie seizoen opnemen of annuleren'
                ]
                dialogHeader = 'Alarm zetten of opnemen'
                dialogSummary = ProgramName + ' alarm zetten of opnemen?'
                dialogFooter = ''
        else:
            if func.date_time_between(dateTimeNow, ProgramTimeStartDateTime,
                                      ProgramTimeEndDateTime):
                dialogAnswers = ['Live programma kijken']
                dialogHeader = 'Programma kijken'
                dialogSummary = ProgramName + ' kijken?'
                dialogFooter = ''
            elif ProgramTimeStartDateTime < dateTimeNow:
                dialogAnswers = ['Programma terug kijken']
                dialogHeader = 'Programma terug kijken'
                dialogSummary = ProgramName + ' terug kijken?'
                dialogFooter = ''
            else:
                dialogAnswers = ['Alarm zetten of annuleren']
                dialogHeader = 'Alarm zetten'
                dialogSummary = ProgramName + ' alarm zetten?'
                dialogFooter = ''

        dialogResult = dialog.show_dialog(dialogHeader, dialogSummary,
                                          dialogFooter, dialogAnswers)
        if dialogResult == 'Alarm zetten of annuleren':
            self.set_program_alarm(listItemSelected)
        elif dialogResult == 'Programma opnemen of annuleren':
            recordingfunc.record_event_epg(self, listItemSelected)
        elif dialogResult == 'Serie seizoen opnemen of annuleren':
            recordingfunc.record_series_epg(self, listItemSelected)
        elif dialogResult == 'Live programma kijken':
            stream.switch_channel_tv_listitem(listItemSelected, False, False)
        elif dialogResult == 'Programma terug kijken':
            stream.play_stream_program(listItemSelected, False)