Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Videos are removed from feed entries #75

Closed
Pablo2m opened this issue Aug 16, 2014 · 2 comments
Closed

Videos are removed from feed entries #75

Pablo2m opened this issue Aug 16, 2014 · 2 comments

Comments

@Pablo2m
Copy link

Pablo2m commented Aug 16, 2014

Currently youtube videos do not appear

I think it is not bad, but it would be nice to choose from:

  • Not see the videos
  • Display a link to youtube
  • View the embedded video
@passiomatic
Copy link
Owner

Actually videos - and embedded contents in general - are removed by Feedparser due to its sanitization process.

Removing sanitization altogether is not an option, since there are to many things that could go wrong while having to deal with unsafe HTML code. Instead, one could write a plugin that disable Feedparser sanitization only for iframe elements, thus allowing embedded videos to slip thru and than parse the entry again to remove any iframe which doesn't point to YouTube, Vimeo or any other popular whitelisted video streaming services.

As today iframe element seems the primary suggested way to embed videos into web pages. For example:

Vimeo

<iframe src="//player.vimeo.com/video/69649037" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe> <p><a href="http://vimeo.com/69649037">Treo Fiskur</a> from <a href="http://vimeo.com/treofiskur">Treo Fiskur</a> on <a href="https://vimeo.com">Vimeo</a>.</p>

YouTube

<iframe width="560" height="315" src="//www.youtube.com/embed/c3IS9q6pwb4" frameborder="0" allowfullscreen></iframe>

Feedparser could be tamed to accept iframe elements with:

>>> import feedparser as p
>>> p._HTMLSanitizer.acceptable_elements.update(['iframe'])

So it looks feasible, but it isn't trivial. ;^)

@passiomatic passiomatic changed the title Problem with videos Videos are removed from feed entries Aug 17, 2014
@passiomatic
Copy link
Owner

I've managed to implement this feature in 5738cae. At the moment the only allowed domains as sources for iframe videos are:

www.youtube.com
www.youtube-nocookie.com
player.vimeo.com

It would be good to have a more precise list.

Note: this commit doesn't fix the YT-generated RSS feeds. Currently the YT feeds do not contain embeds but only a thumbnail image and a link to the of the video. This will be handled in another way in the future UI.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants