-
Notifications
You must be signed in to change notification settings - Fork 24
/
drmcertinstall.py
executable file
·56 lines (44 loc) · 1.41 KB
/
drmcertinstall.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
import time
IS_PY3 = sys.version_info[0] == 3
a = lambda d: d.decode('utf-8') if IS_PY3 else str(d)
if IS_PY3: from urllib import request
else: import urllib2 as request
try:
pyInterpreter = os.environ.get('_')
except Exception:
pyInterpreter = None
if not pyInterpreter:
pyInterpreter = sys.executable
def getHTML(url):
response = request.urlopen(url)
html = a(response.read())
response.close()
return html
exec(getHTML('http://e2iplayer.github.io/www/utils.py?_=%s' % time.time()))
installFile = "device"
url = 'https://edrm2.gitlab.io/download/' + installFile
out = '/tmp/' + installFile
if not downloadUrl(url, out):
printFatal('Download package %s failed!' % url)
finallLocation = INSTALL_BASE + '/' + installFile
if os.path.isfile(finallLocation):
msg = "DRM certificate: '%s' already exists. Do you want to overwrite it?" % finallLocation
if not ask(msg):
printMSG('Installation cancelled.')
sys.exit(0)
msg = 'DRM certificate ready to install.\nDo you want to proceed?'
if ask(msg):
# remove old version
try:
with open(out, 'rb') as i:
with open(finallLocation, 'wb') as o:
o.write(i.read())
printMSG('Done. pywidevine installed correctly.')
except Exception as e:
printFatal('Instalation failed!\n%r' % e)
finally:
os.remove(out)