mercuree / html-telegraph-poster

Python html to telegra.ph poster (telegram article service)
MIT License
100 stars 31 forks source link

how can I embed Youtube Videos? What html code should work? #3

Closed JohnPlayerSpecial closed 6 years ago

JohnPlayerSpecial commented 6 years ago

tried with iframe and video tag, but given error is empty content

mercuree commented 6 years ago

Can you provide html you are working with?

JohnPlayerSpecial commented 6 years ago

It is a bigger project, in which I'm parsing a Blog post, and it happened to contain a YT video.

from html_telegraph_poster import upload_to_telegraph url2send = upload_to_telegraph(title=title, author='me', text=text)["url"]

variable text contains all the html (which I am modifying in order to be able to be able to upload to telegraph and to trim garbage :) )

I get a telegraph page with all images/text, but without video. Hence I tried to hardcoding variable text just before the line

url2send = upload_to_telegraph(title=title, author='me', text=text)["url"]

like this

text = "<video><source src="VIDEOURL"></video>" url2send = upload_to_telegraph(title=title, author='me', text=text)["url"]

or

text = "<embed src="VIDEOURL">" url2send = upload_to_telegraph(title=title, author='me', text=text)["url"]

but I can't

Thanks in advance

mercuree commented 6 years ago
  1. telegra.ph only supports youtube and vimeo iframe tags, so your html should contain for example:
    <iframe width="560" height="315" src="https://www.youtube.com/embed/EOQj_Ql4WSY" frameborder="0" allowfullscreen></iframe>

    This is what youtube offers for embedding

  2. video tag is supported for gifs without the sound.
  3. embed tag is unsupported.
  4. You can read tests for iframe here https://github.com/mercuree/html-telegraph-poster/blob/master/tests/htp_test.py#L280
JohnPlayerSpecial commented 6 years ago

Thanks for the kind response, you're been awesome. Just Successfully embedded the YT video as you said. In this blog post there is also a facebook iframe video, but as you said I have no hope... Thanks again

mercuree commented 6 years ago

Instant view supports facebook videos https://instantview.telegram.org/docs#embedded-elements but you have to write instant view template