Skip to content

Instantly share code, notes, and snippets.

@vibhavsinha
Last active March 24, 2020 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save vibhavsinha/f65ed380b6f869a864269716179125a9 to your computer and use it in GitHub Desktop.
Save vibhavsinha/f65ed380b6f869a864269716179125a9 to your computer and use it in GitHub Desktop.
Python3 implementation of VdoCipher API
import requests
class vdocipher() :
values = {}
def __init__(self, csk):
self.values[ 'clientSecretKey' ] = csk
def getOtp(self, video, annotate=None, forcedBitrate=None):
url = 'https://api.vdocipher.com/v2/otp?video='+video
if forcedBitrate is not None:
self.values[ 'forcedBitrate' ] = forcedBitrate
if annotate is not None:
self.values[ 'annotate' ] = annotate
r = requests.post(url, data=self.values)
a = r.json()
return a['otp']
def embedCode(self, otp):
code = """
<div id="vdo{0}" style="height:400px;width:640px;max-width:100%;"></div>
<script>
(function(v,i,d,e,o){{v[o]=v[o]||{{}}; v[o].add = v[o].add || function V(a){{ (v[o].d=v[o].d||[]).push(a);}};
if(!v[o].l) {{ v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0];
a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}}
}})(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo');
vdo.add({{
o: "{0}",
}});
</script>
"""
return code.format(otp)
a = vdocipher('CLIENT_SECRET_KEY')
otp = a.getOtp('VIDEO_ID')
print(a.embedCode(otp))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment