Reputation: 1
Using Django-embed-video 1.4.0, we can easily embed YouTube videos into Django projects. However it doesn't seem to work if the video is from any source but YouTube. The embed video code is different for every website and whenever I enter a code from a site like TikTok, CNN, or Facebook, it says "URL could not be recognized." YouTube Video CNN Video
Is there a way to modify the URL so that Django-embed-video recognizes the URL? Or is there another way to create a django website that can show embedded videos from a source other then youtube?
models.py
from django.db import models
# Create your models here.
from embed_video.fields import EmbedVideoField
class Item(models.Model):
video = EmbedVideoField()
Upvotes: 0
Views: 724
Reputation: 11
You can create link and show in iframe for example extract values fron link and combine:
parsed = urlparse('https://www.youtube.com/watch?v=8PQVbhiHv6k')
# print(parsed)
# This shows the result:
# ParseResult(scheme='https', netloc='www.youtube.com', path='/watch', params='', query='v=8PQVbhiHv6k', fragment='')
get_id=parsed.query.replace('v=','')
# Combine links
my_link='https://www.youtube.com/watch?v='
combine=my_link+get_id
Upvotes: 0
Reputation: 21
You can build your own custom backend supporting other sources such as TikTok or CNN built on top of their VideoBackend class. You can check their official documentation on how to do that here.
Also feel free to open a PR on the official repo in case you've actually built those extensions.
Upvotes: 0