asciinema-server icon indicating copy to clipboard operation
asciinema-server copied to clipboard

asciinema oembed doesn't provide the player

Open damageboy opened this issue 7 years ago • 3 comments

The asciinema oEmbed support provides the following json, as an example:

{
  "type": "rich",
  "version": 1,
  "title": "DevStats async loading, interactive mode and caching",
  "author_name": "shroudedcode",
  "author_url": "https://asciinema.org/~shroudedcode",
  "provider_name": "asciinema",
  "provider_url": "https://asciinema.org/",
  "thumbnail_url": "https://asciinema.org/a/170671.png",
  "thumbnail_width": 644,
  "thumbnail_height": 632,
  "html": "<a href=\"https://asciinema.org/a/170671\" target=\"_blank\"><img alt=\"DevStats async loading, interactive mode and caching\" src=\"https://asciinema.org/a/170671.png\" width=\"644\" /></a>",
  "width": 644,
  "height": 632
}

As it can be easily seen the html portion of the oEmbed doesn't actually embed a player, but rather embeds a link to the asciinema site...

Is there a reason no to embed the player through an iframe as, for example youtube does?

damageboy avatar May 26 '18 08:05 damageboy

Frankly I don't remember whether iframe would work here or not. I don't see why not though :) That's worth considering, thx!

ku1ik avatar Nov 13 '18 17:11 ku1ik

I also recently bumped into this issue and would love to see players provided in the oEmbed API.

Looking at the source code of oEmbed view, I think it should not be hard to support this, and I'm willing to contribute to this.

Specifically, the oEmbed API currently responds:

{
  "author_name": "captainPuff",
  "author_url": "https://asciinema.org/~captainPuff",
  "height": 792,
  "html": "<a href=\"https://asciinema.org/a/50301\" target=\"_blank\"><img alt=\"rya.nc 1987\" src=\"https://asciinema.org/a/50301.png\" width=\"1179\"></a>",
  "provider_name": "asciinema",
  "provider_url": "https://asciinema.org",
  "thumbnail_height": 792,
  "thumbnail_url": "https://asciinema.org/a/50301.png",
  "thumbnail_width": 1179,
  "title": "rya.nc 1987",
  "type": "rich",
  "version": 1.0,
  "width": 1179
}

and the html part provides:

<a href="https://asciinema.org/a/50301" target="_blank">
  <img alt="rya.nc 1987" src="https://asciinema.org/a/50301.png" width="1179" />
</a>

after changing, it'll be:

<script src="https://asciinema.org/a/50301.js" id="asciicast-50301" async></script>

If possible, I'll also try to make the customized parameters work.

@ku1ik Please let me know if you'd like this, then I'll start drafting a PR.

tomy0000000 avatar May 08 '23 09:05 tomy0000000

@tomy0000000 I think we can try that, yeah :+1:

ku1ik avatar Aug 25 '23 12:08 ku1ik