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

feat: add TikTok as provider #14

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This works right now for
* flickr.com (plugin name: ``flickr``)
* slideshare.net (plugin name: ``slideshare``)
* facebook.com videos (plugin name: ``facebookvideos``)
* tiktok.com videos (plugin name: ``tiktok``)

The raw OEmbed data can be accessed via the ``data`` attribute of the result if the result is an ``OEmbedMarkup`` instance::

Expand Down
16 changes: 14 additions & 2 deletions embeddify/embeddify.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import re
import requests

__all__ = ['Plugin', 'OEmbedPlugin', 'YouTube', 'Vimeo', 'Slideshare', 'Flickr', 'Embedder']
__all__ = ['Plugin', 'OEmbedPlugin', 'YouTube', 'Vimeo', 'Slideshare', 'Flickr', 'TikTok', 'Embedder']

class Plugin(object):
"""base plugin to be used for converting one type of link into an embed"""
Expand Down Expand Up @@ -192,6 +192,8 @@ class FacebookVideos(OEmbedPlugin):
"""

api_url = "https://www.facebook.com/plugins/video/oembed.json/"
# api_url = "https://graph.facebook.com/v15.0/{video-id}"
api_url = "https://graph.facebook.com/v15.0/"

def test(self, parts):
"""test if the plugin is able to convert that link"""
Expand All @@ -203,8 +205,18 @@ def test(self, parts):
return True
return False

class TikTok(OEmbedPlugin):
"""converts tiktok links into embeds
"""

api_url = "https://www.tiktok.com/oembed"

def test(self, parts):
"""test if the plugin is able to convert that link"""
return "tiktok.com" in parts.netloc


STANDARD_PLUGINS = [YouTube(), Slideshare(), Flickr(), Vimeo(), FacebookVideos()]
STANDARD_PLUGINS = [YouTube(), Slideshare(), Flickr(), Vimeo(), FacebookVideos(), TikTok()]


class Embedder(object):
Expand Down