sphinx-contrib / video

A sphinx plugin that enables embedding of HTML5 videos
https://sphinxcontrib-video.readthedocs.io
Apache License 2.0
43 stars 29 forks source link

Support online video services as well #12

Open choldgraf opened 1 year ago

choldgraf commented 1 year ago

In many cases, video content might be hosted online in a service instead of locally. For example, many people upload videos to Google Drive or YouTube, and then want to embed their videos in documentation.

I think that it'd be in-scope for this extension to support these use-cases as well, for a limited subset of common video services. Probably somewhere around here:

https://github.com/sphinx-contrib/video/blob/d5e64ea43b3715e733724a8382c419aa2437783d/sphinxcontrib/video.py#L19

Implementing the logic to support a service would be too much work. For example, you could just add an extra check for whether the argument to .. video:: starts with http, and if so, try to detect the service (e.g., "youtube.com" self.arguments[0] or self.options.get("kind") == "youtube"). Then you could output an HTML raw:: block that included the proper structure for that video type.

If you want to see one example of directive logic like this, see:

https://github.com/2i2c-org/sphinx-2i2c-theme/blob/update-theme/src/sphinx_2i2c_theme/video.py

12rambau commented 1 year ago

for this very purpose there is the https://github.com/sphinx-contrib/youtube extention that works for vimeo and youtube is it fiting your objectives ?

choldgraf commented 1 year ago

I suppose so, though it seems excessive to have to install a separate extension + have a different directive for each type of thing given how simple the logic is. Also confusing that it is called youtube but also supports non-youtube services like vimeo. But strictly speaking that does satisfy the use-case :-)

12rambau commented 1 year ago

in the background, that's in fact quite different as vimeo and youtube provide specific iframes with specific parameters + that allows people to only specify the video ID (I use it a lot as everything I do is stored on youtube).

choldgraf commented 1 year ago

For sure - that's my point. Users shouldn't have to care about whether it's "a youtube video or a vimeo video", they should just (IMO) have a single directive where they can post the URL of many video services, and the directive can figure out the logic for them. The directive logic is pretty simple, but anything that can reduce the number of things a user has to remember or think about is a good idea I think.