示例#1
0
def favorite_remove(listItem):
    ChannelId = listItem.getProperty('ChannelId')

    for favorite in var.FavoriteTelevisionDataJson:
        try:
            if favorite == ChannelId:
                var.FavoriteTelevisionDataJson.remove(favorite)
                break
        except:
            continue

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

    #Update the listitem status
    listItem.setProperty('ChannelFavorite', 'false')

    #Favorite has been removed notification
    notificationIcon = path.resources(
        'resources/skins/default/media/common/star.png')
    xbmcgui.Dialog().notification(var.addonname,
                                  'Zender is ongemarkeerd als favoriet.',
                                  notificationIcon, 2500, False)
    return 'Removed'
示例#2
0
def alarm_remove_all():
    if len(var.AlarmDataJson) > 0:
        dialogAnswers = ['Alle alarmen annuleren']
        dialogHeader = 'Alle alarmen annuleren'
        dialogSummary = 'Weet u zeker dat u alle geplande alarmen wilt annuleren?'
        dialogFooter = ''

        dialogResult = dialog.show_dialog(dialogHeader, dialogSummary, dialogFooter, dialogAnswers)
        if dialogResult == 'Alle alarmen annuleren':
            #Remove all the set alarms
            var.AlarmDataJson = []

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

            #Alarm has been removed notification
            notificationIcon = path.resources('resources/skins/default/media/common/alarm.png')
            xbmcgui.Dialog().notification(var.addonname, 'Alle alarmen zijn geannuleerd.', notificationIcon, 2500, False)

            #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
    else:
        notificationIcon = path.resources('resources/skins/default/media/common/alarm.png')
        xbmcgui.Dialog().notification(var.addonname, 'Er zijn geen alarmen gezet.', notificationIcon, 2500, False)
    return False
示例#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
示例#4
0
def alarm_remove(ProgramTimeStart):
    #Check if the alarm start exists
    for alarm in var.AlarmDataJson:
        try:
            if str(ProgramTimeStart) == alarm['starttime']:
                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)

    #Alarm has been removed notification
    notificationIcon = path.resources('resources/skins/default/media/common/alarm.png')
    xbmcgui.Dialog().notification(var.addonname, 'Programma alarm is geannuleerd.', notificationIcon, 2500, False)

    #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
示例#5
0
def search_remove(searchTerm, saveJson=True):
    #Remove search term from Json
    for search in var.SearchHistorySearchJson:
        try:
            if search == searchTerm:
                var.SearchHistorySearchJson.remove(search)
                break
        except:
            continue

    #Save the raw json data to storage
    if saveJson == True:
        JsonDumpBytes = json.dumps(var.SearchHistorySearchJson).encode('ascii')
        files.saveFile('SearchHistorySearch.js', JsonDumpBytes)
示例#6
0
def search_add(searchTerm):
    #Remove search term from Json
    search_remove(searchTerm, False)

    #Add search history to Json
    var.SearchHistorySearchJson.insert(0, searchTerm)

    #Trim search history length
    if len(var.SearchHistorySearchJson) > 30:
        var.SearchHistorySearchJson = var.SearchHistorySearchJson[:30]

    #Save the raw json data to storage
    JsonDumpBytes = json.dumps(var.SearchHistorySearchJson).encode('ascii')
    files.saveFile('SearchHistorySearch.js', JsonDumpBytes)
示例#7
0
def alarm_add(ProgramTimeStartDateTime, ChannelId, ExternalId, ChannelName, ProgramName, removeDuplicate=False):
    notificationIcon = path.resources('resources/skins/default/media/common/alarm.png')

    #Remove seconds from the program start time
    ProgramTimeStartDateTime = func.datetime_remove_seconds(ProgramTimeStartDateTime)

    #Check if alarm start time already exists
    if removeDuplicate == True and alarm_duplicate_program_check(ProgramTimeStartDateTime, ChannelId):
        alarm_remove(ProgramTimeStartDateTime)
        return 'Remove'
    elif alarm_duplicate_time_check(ProgramTimeStartDateTime):
        xbmcgui.Dialog().notification(var.addonname, 'Er is al een alarm voor dit tijdstip.', notificationIcon, 2500, False)
        return False

    #Check if program is more than 3 minutes away
    ProgramTimeLeft = int((ProgramTimeStartDateTime - datetime.now()).total_seconds())
    if ProgramTimeLeft <= 180:
        xbmcgui.Dialog().notification(var.addonname, 'Programma begint binnen 3 minuten.', notificationIcon, 2500, False)
        return False

    #Append the new alarm to Json
    var.AlarmDataJson.append({"starttime": str(ProgramTimeStartDateTime), "channelid": ChannelId, "externalid": ExternalId, "channelname": ChannelName, "programname": ProgramName})

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

    #Alarm has been set notification
    xbmcgui.Dialog().notification(var.addonname, 'Alarm gezet: ' + ProgramName + ' (' + ChannelName + ')', notificationIcon, 2500, False)

    #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
示例#8
0
def favorite_add(listItem):
    notificationIcon = path.resources(
        'resources/skins/default/media/common/star.png')
    ChannelId = listItem.getProperty('ChannelId')

    #Check if favorite already exists
    if favorite_check(ChannelId) == True:
        return favorite_remove(listItem)

    #Append the new favorite to Json
    var.FavoriteTelevisionDataJson.append(ChannelId)

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

    #Update the listitem status
    listItem.setProperty('ChannelFavorite', 'true')

    #Favorite has been set notification
    xbmcgui.Dialog().notification(var.addonname,
                                  'Zender is gemarkeerd als favoriet.',
                                  notificationIcon, 2500, False)
    return 'Added'
示例#9
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Feb 24 18:12:39 2019

@author: dan
"""
from my_sys import argv
from files import loadFile, saveFile
from parse import getStructure, generateTex

if __name__ == "__main__":
    try:
        inp = argv[1]
        out = argv[2]
        data = loadFile(inp)
        structure = getStructure(data)
        tex = generateTex(structure)
        saveFile(out, tex)
    except Exception as e:
        print("error %s" % e)
示例#10
0
 def saveNew(self):
     saveFile(self.newMails, pathSTR="lastids.txt")