z_media_import (zotonic_core v1.0.0-rc.17)

Import media from internet locations. The URL is inspected and the best possible import method is used to make resource, with optionally a medium record attached.

Summary

Functions

Create a resource with a selected #media_import_props{}, URL or embed code.

Create a resource with a selected #media_import_props{}, URL or embed code. The given resource properties are merged over the extracted properties.

Update a resource's medium record with the selected #media_import_props(), URL or embed code.

Find possible rsc/medium mappings for the url or fetched url metadata

Functions

insert(UrlOrMediaImport, Context)

-spec insert(UrlOrMediaImport, Context) -> {ok, m_rsc:resource_id()} | {error, term()}
                when
                    UrlOrMediaImport ::
                        #media_import_props{prio :: pos_integer(),
                                            category :: atom(),
                                            module :: atom(),
                                            description :: binary() | z:trans(),
                                            rsc_props :: map(),
                                            medium_props :: z_media_identify:media_info(),
                                            medium_url :: binary(),
                                            preview_url :: binary() | undefined,
                                            importer :: atom()} |
                        m_media:media_url(),
                    Context :: z:context().

Create a resource with a selected #media_import_props{}, URL or embed code.

insert(UrlOrMediaImport, RscProps, Context)

-spec insert(UrlOrMediaImport, RscProps, Context) -> {ok, m_rsc:resource_id()} | {error, term()}
                when
                    UrlOrMediaImport ::
                        m_media:media_url() |
                        #media_import_props{prio :: pos_integer(),
                                            category :: atom(),
                                            module :: atom(),
                                            description :: binary() | z:trans(),
                                            rsc_props :: map(),
                                            medium_props :: z_media_identify:media_info(),
                                            medium_url :: binary(),
                                            preview_url :: binary() | undefined,
                                            importer :: atom()},
                    RscProps :: #{binary() => term()},
                    Context :: z:context().

Create a resource with a selected #media_import_props{}, URL or embed code. The given resource properties are merged over the extracted properties.

update(RscId, MediaImport, Context)

-spec update(RscId, MediaImport, Context) -> {ok, m_rsc:resource_id()} | {error, term()}
                when
                    RscId :: m_rsc:resource_id(),
                    MediaImport ::
                        #media_import_props{prio :: pos_integer(),
                                            category :: atom(),
                                            module :: atom(),
                                            description :: binary() | z:trans(),
                                            rsc_props :: map(),
                                            medium_props :: z_media_identify:media_info(),
                                            medium_url :: binary(),
                                            preview_url :: binary() | undefined,
                                            importer :: atom()} |
                        Url,
                    Url :: string() | binary(),
                    Context :: z:context().

Update a resource's medium record with the selected #media_import_props(), URL or embed code.

url_import_props(Url, Context)

-spec url_import_props(z_url_metadata:metadata() | string() | binary(), z:context()) ->
                          {ok,
                           [#media_import_props{prio :: pos_integer(),
                                                category :: atom(),
                                                module :: atom(),
                                                description :: binary() | z:trans(),
                                                rsc_props :: map(),
                                                medium_props :: z_media_identify:media_info(),
                                                medium_url :: binary(),
                                                preview_url :: binary() | undefined,
                                                importer :: atom()}]} |
                          {error, term()}.

Find possible rsc/medium mappings for the url or fetched url metadata