def get_active_uri(core, *args, **kwargs):
    """
    Tries to determine what the currently 'active' Mopidy track is, and returns it's URI. Makes use of a best-effort
    determination base on:
    1. looking for 'track' in kwargs, then
    2. 'tl_track' in kwargs, then
    3. interrogating the Mopidy core for the currently playing track, and lastly
    4. checking which track was played last according to the history that Mopidy keeps.

    :param core: the Mopidy core that can be used as a fallback if no suitable arguments are available.
    :param args: all available arguments from the calling function.
    :param kwargs: all available kwargs from the calling function.
    :return: the URI of the active Mopidy track, if it could be determined, or None otherwise.
    """
    uri = None
    track = kwargs.get("track", None)
    if track:
        uri = track.uri
    else:
        tl_track = kwargs.get("tl_track", core.playback.get_current_tl_track().get())
        if tl_track:
            uri = tl_track.track.uri
    if not uri:
        history = core.history.get_history().get()
        if history:
            uri = history[0]
    return uri