Read up on Embeds.
To trigger an embed use wp_oembed_get($url)
.
In general the url needs to be on it’s own line with a space below and above when inside the_content. wp_insert_post()
has nothing to do with embeds as the embed HTML is usually generated when passed through the_content filter.
To add support for non-oEmbed sites use wp_embed_register_handler()
And for oEmbed-enabled sites use wp_oembed_add_provider()
.