Return html for an embeddable URL
(url: str, width: int = 960, height: int = 540)
| 92 | |
| 93 | |
| 94 | def 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")) |