Exemplo n.º 1
0
def api_media_get(auth_user=None, api_core=None, request=None):
    u"""
    Return an array containing the informations about the media assets serialized to JSON.

    All ``thing_id`` fields are replaced by corresponding ``thing``.
    For example ``user_id`` is replaced by ``user``'s data.
    """
    data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True)
    return ok_200(api_core.get_medias(load_fields=True, **data), include_properties=True)
Exemplo n.º 2
0
def view_medias_list(request):
    u"""Show the media assets list page."""
    try:
        data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True)
        data.setdefault(u'skip', 50)  # ask for the last 50 media assets if skip is not provided
        return {u'medias': remove_underscores(api_core.get_medias(**data)), u'refresh_rate': 5}
    except Exception as e:
        logging.exception(e)
        return {u'errors': [unicode(e)], u'refresh_rate': 30}
Exemplo n.º 3
0
def view_publisher_tasks(request):
    u"""Show the publication tasks home page."""
    try:
        data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True)
        data.setdefault(u'skip', 50)  # ask for the last 50 media assets if skip is not provided
        data.setdefault(u'spec', {u'status': Media.READY})  # filter the media assets that cannot be published
        # FIXME add more filters
        medias = remove_underscores(api_core.get_medias(**data))
        queues = remove_underscores(api_core.get_publisher_queues())
        return {u'medias': medias, u'queues': queues}
    except Exception as e:
        logging.exception(e)
        return {u'errors': [unicode(e)]}
Exemplo n.º 4
0
def api_media_head(auth_user=None, api_core=None, request=None):
    u"""Return an array containing the informations about the media assets serialized to JSON."""
    data = get_request_data(request, accepted_keys=api_core.db_find_keys, qs_only_first_value=True, optional=True)
    return ok_200(api_core.get_medias(**data), include_properties=True)