mediacms-io / mediacms

MediaCMS is a modern, fully featured open source video and media CMS, written in Python/Django and React, featuring a REST API.
https://mediacms.io
GNU Affero General Public License v3.0
2.7k stars 498 forks source link

Request a feature that allow user to submit / embed iframe media, such youtube #271

Closed chorylee closed 1 year ago

chorylee commented 3 years ago

MediaCMS is cool to deal with media uploading, but I think it should have the capability to handle a simple task: submit a third party media url (such as youtube video, etc.), then MediaCMS can store the url simply (no need to download the video to self-hosted server), and then user can play the video as normal.

If you will not to add this feature, could you help to share some guideline, thanks a lot.

mgogoulos commented 3 years ago

It's a good suggestion and thanks for opening it, as it has been requested multiple times recently.

chorylee commented 3 years ago

@mgogoulos, great, hope can get the feature ready soon, thank you. Meanwhile, could you share the some guideline about how to implement it, then I can check how to help

mgogoulos commented 3 years ago

@chorylee I'm currently on a short break but next week I'm back and will provide details here, thanks!

mgogoulos commented 3 years ago

Hey @chorylee , so this is most complicated than it sounds, but I'll give some context here. I'm also working on a PR on this

So there is Media model, that all listings use (index page, user's page, search pages) and is also tight with interactions as views, comments, likes etc. So this need be reused for embedding URLS from external sources. But Media media_file is a required field there (the original file that is uploaded). Thus

  1. media_file need be set null=True, blank=True and a migration need be added since any change to the model fields produces the need of a new migration
  2. a new field need be added, eg embed_from_url, probably JsonField, that will store the URLs (eg {'youtube_url': 'xyz', 'thumbnail_url:'zzx'})
  3. add media API need to ensure that media_file will be required now! This should only get real files (not URLs)
  4. add an /embed_from_url type of URL, make a new page for it, link through the /upload page, and make it optional (probably off by default, through settings, so that you have to make this True to work)
  5. files.models.media_init should be modified to understand that a Media is saved with the embed_from_url field, and thus store what is necessary (eg if youtube URL, store media_type video) and avoid calling methods that produce thumbnails, encodings etc
  6. edit_form: should exclude the poster in this case - the listings should show the embed_from_url only - there should also be a validation that this is amongst a list of options, as youtube/vimeo and not anything, as
  7. the media page should be able to differentiate and not show the default MediaCMS player but instead the embedded URL - this is frontend work need to be done
  8. the API should return the url/thumbnail from the new field itself, this is easy through overriding files.models functions encodings_info and thumbnail_url that specify what will be loaded as encodings/hls URLs and thumbnails
  9. then Frontend work has to ensure that these media are not included on Playlists (so save button on playlist not appearing) and that the player is not loaded.
  10. ensure that everything works ok, listings etc

The above will be visible on the PR in a few days, but if you're willing to do any work as well, you are very welcome!