MCPcopy Create free account
hub / github.com/datapane/datapane / get_embed_url

Function get_embed_url

python-client/src/datapane/common/viewxml_utils.py:94–107  ·  view source on GitHub ↗

Return html for an embeddable URL

(url: str, width: int = 960, height: int = 540)

Source from the content-addressed store, hash-verified

92
93
94def get_embed_url(url: str, width: int = 960, height: int = 540) -> Embedded:
95 """Return html for an embeddable URL"""
96 try:
97 r = providers.request(url, maxwidth=width, maxheight=height)
98 except ProviderException:
99 # add noembed to the list and try again
100 try:
101 log.debug("Initialising NoEmbed OEmbed provider")
102 bootstrap_noembed(registry=providers)
103 r = providers.request(url, maxwidth=width, maxheight=height)
104 except ProviderException:
105 raise DPError(f"No embed provider found for URL '{url}' - is there an active internet connection?")
106
107 return Embedded(html=r["html"], title=r.get("title", "Title"), provider=r.get("provider_name", "Embedding"))

Callers 1

__init__Method · 0.90

Calls 3

DPErrorClass · 0.85
EmbeddedClass · 0.85
getMethod · 0.45

Tested by

no test coverage detected