def reloadSchedule(existing, running):
    '''Reload the list of scheduled recordings.'''

    now = datetime.datetime.now() # Get the current timestamp
    revised = initialise(True) # Get the revised schedule

    # Get the schedule id for each of the running recordings
    running_ids = {}
    for r in running:
        sid = running[r]['sid']
        running_ids[sid] = r

    # Get the schedule id for each of the upcoming recordings
    upcoming_ids = {}
    for e in existing:
        sid = existing[e]['sid']
        upcoming_ids[sid] = e

    # Number of new entries
    new_rec = 0

    # Compare the revised schedule against the existing
    for r in revised:
        data = revised[r]
        sched_id = data['sid']
        endtime = data['end']

        # If this recording is already running
        if sched_id in running_ids:
            h = running_ids[sched_id]

            # TO DO: When the SID is implemented properly with the
            # schedule editor, there will be no need to check any of these
            # fields apart from the end time

            # Check if it's the same channel and programme
            ch = (data['channel'] == running[h]['channel'])
            pr = (data['programme'] == running[h]['programme'])

            # If it's the same channel and programme, check if we need to revise the end time
            if pr and ch and endtime != running[h]['end']:
                timePrint('Changed end time for running recording:')

                if data['programme'] is not None:
                    indentPrint('%(programme)s (%(channel)s)' % data)
                else:
                    indentPrint('%s' % h)

                indentPrint('%s to %s' % (running[h]['end'].strftime('%Y-%m-%d %H:%M:%S'), endtime.strftime('%Y-%m-%d %H:%M:%S')))

                running[h]['end'] = endtime

        # Otherwise, it's not a currently-running recording
        # We only want to consider programmes that haven't finished yet
        elif endtime > now:
            if sched_id in upcoming_ids:
                s = upcoming_ids[sched_id]

                # Remove the old data so that it can be replaced with the new
                temp = existing.pop(s, None)

                # Check if it's the same channel and programme
                ch = (data['channel'] == temp['channel'])
                pr = (data['programme'] == temp['programme'])

                # Only notify a change if it's the same programme
                if temp != data and ch and (pr or temp['programme'] is None):
                    timePrint('Changes made to scheduled recording:')

                    if data['programme'] is not None:
                        indentPrint('%(programme)s (%(channel)s)' % data)
                    else:
                        indentPrint('%s' % s)

            else:
                new_rec += 1

            existing[r] = data

    if new_rec > 0:
        timePrint('Added %d new scheduled recordings.' % new_rec)

    return (existing, running)
Reload the list of scheduled recordings.
recipes/Python/579096_vlcpy_stream_capture_scheduler/recipe-579096.py