Skip to content

Commit 4a3e1ee

Browse files
committed
black + isort (sort imports)
1 parent 11e6137 commit 4a3e1ee

21 files changed

+386
-352
lines changed

qencode/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ def x265_video_codec():
4141

4242

4343
from exeptions import QencodeClientException, QencodeTaskException
44-
45-
from tools import generate_aws_signed_url, fps_drm, cenc_drm
44+
from tools import cenc_drm, fps_drm, generate_aws_signed_url
4645

4746
__version__ = "1.0.4"
4847
__status__ = "Production/Stable"

qencode/client.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from httptools import Http
2-
from task import Task
32
from metadata import Metadata
3+
from task import Task
44

55

66
class QencodeApiClient(object):

qencode/custom_params.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from json import JSONEncoder
3+
34
from utils import rm_attributes_if_null
45

56

qencode/drm/buydrm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
import os
2+
13
from lxml import etree
24
from signxml import XMLSigner
3-
import os
45

56
NSMAP = {
67
'cpix': 'urn:dashif:org:cpix',

qencode/httptools.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import json
2+
import ssl
23
import urllib
34
import urllib2
45
from urlparse import urljoin
5-
import ssl
66

77

88
class Http(object):

qencode/metadata.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
import urllib2
2+
13
from task import *
4+
25
from qencode import QencodeTaskException
3-
import urllib2
46

57

68
class Metadata(Task):

qencode/task.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
from custom_params import Query, CustomTranscodingParams
2-
from const import *
3-
import time
41
import json
2+
import time
3+
4+
from const import *
5+
from custom_params import CustomTranscodingParams, Query
56
from utils import is_json, rm_key_if_null
67

78

qencode/tools.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#
2-
from const import *
32
import datetime
43
import hashlib
54
import hmac
5+
import uuid
6+
import xml.etree.cElementTree as et
7+
68
import requests
9+
from const import *
710
from requests.utils import quote
8-
import xml.etree.cElementTree as et
9-
import uuid
1011

1112

1213
def generate_aws_signed_url(

qencode/tus_uploader.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
23
from tusclient import client
34
from utils import get_tus_from_url
45

qencode/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import sys
2-
import logging
31
import json
2+
import logging
3+
import sys
44

55

66
def is_number(s):
Lines changed: 36 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import uuid
2-
import time
3-
import json
41
import base64
2+
import json
3+
import time
4+
import uuid
5+
56
import qencode
6-
from qencode.drm.buydrm import create_cpix_user_request
77
from qencode import QencodeClientException, QencodeTaskException
8+
from qencode.drm.buydrm import create_cpix_user_request
89

910
# replace with your API KEY (can be found in your Project settings on Qencode portal)
1011
API_KEY = 'your-api-qencode-key'
@@ -14,13 +15,12 @@
1415
USER_PUB_CERT_PATH = './keys/user_public_cert.pem'
1516

1617
key_ids = [
17-
{ 'kid': str(uuid.uuid4()), 'track_type': 'SD' },
18-
{ 'kid': str(uuid.uuid4()), 'track_type': 'HD' }
18+
{'kid': str(uuid.uuid4()), 'track_type': 'SD'},
19+
{'kid': str(uuid.uuid4()), 'track_type': 'HD'},
1920
]
2021
media_id = 'my first stream'
2122

2223

23-
2424
QUERY = """
2525
{
2626
"query": {
@@ -48,40 +48,44 @@
4848

4949

5050
def start_encode():
51-
# this creates signed request to BuyDRM
52-
cpix_request = create_cpix_user_request(
53-
key_ids, media_id, USER_PVT_KEY_PATH, USER_PUB_CERT_PATH,
54-
use_playready=True, use_widevine=True
55-
)
51+
# this creates signed request to BuyDRM
52+
cpix_request = create_cpix_user_request(
53+
key_ids,
54+
media_id,
55+
USER_PVT_KEY_PATH,
56+
USER_PUB_CERT_PATH,
57+
use_playready=True,
58+
use_widevine=True,
59+
)
5660

57-
client = qencode.client(API_KEY)
58-
if client.error:
59-
raise QencodeClientException(client.message)
61+
client = qencode.client(API_KEY)
62+
if client.error:
63+
raise QencodeClientException(client.message)
6064

61-
print 'The client created. Expire date: %s' % client.expire
65+
print 'The client created. Expire date: %s' % client.expire
6266

63-
task = client.create_task()
67+
task = client.create_task()
6468

65-
if task.error:
66-
raise QencodeTaskException(task.message)
69+
if task.error:
70+
raise QencodeTaskException(task.message)
6771

68-
query = QUERY.replace('{cpix_request}', base64.b64encode(cpix_request))
72+
query = QUERY.replace('{cpix_request}', base64.b64encode(cpix_request))
6973

70-
task.custom_start(query)
74+
task.custom_start(query)
7175

72-
if task.error:
73-
raise QencodeTaskException(task.message)
76+
if task.error:
77+
raise QencodeTaskException(task.message)
7478

75-
print 'Start encode. Task: %s' % task.task_token
79+
print 'Start encode. Task: %s' % task.task_token
7680

77-
while True:
78-
status = task.status()
79-
# print status
80-
print json.dumps(status, indent=2, sort_keys=True)
81-
if status['error'] or status['status'] == 'completed':
82-
break
83-
time.sleep(5)
81+
while True:
82+
status = task.status()
83+
# print status
84+
print json.dumps(status, indent=2, sort_keys=True)
85+
if status['error'] or status['status'] == 'completed':
86+
break
87+
time.sleep(5)
8488

8589

8690
if __name__ == '__main__':
87-
start_encode()
91+
start_encode()

sample-code/metadata.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33

4-
import sys
54
import os.path
6-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
5+
import sys
6+
77
import qencode
88
from qencode import QencodeClientException
99

10-
#replace with your API KEY (can be found in your Project settings on Qencode portal)
10+
sys.path.append(
11+
os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
12+
)
13+
14+
# replace with your API KEY (can be found in your Project settings on Qencode portal)
1115
API_KEY = 'your-api-qencode-key'
1216
VIDEO_URL = 'https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4'
1317

@@ -18,7 +22,4 @@
1822
print 'The client created. Expire date: %s' % client.expire
1923

2024
metadata = client.get_metadata(VIDEO_URL)
21-
print('Metadata: ' + metadata)
22-
23-
24-
25+
print ('Metadata: ' + metadata)

sample-code/start_custom_hls.py

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
#!/usr/bin/python
22
# -*- coding: utf-8 -*-
33

4-
import sys
4+
import json
55
import os.path
6-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
7-
import qencode
6+
import sys
87
import time
9-
import json
8+
9+
import qencode
1010
from qencode import QencodeClientException, QencodeTaskException
1111

12-
#replace with your API KEY (can be found in your Project settings on Qencode portal)
12+
sys.path.append(
13+
os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
14+
)
15+
16+
# replace with your API KEY (can be found in your Project settings on Qencode portal)
1317
API_KEY = 'your-api-qencode-key'
1418

1519
params = qencode.custom_params()
@@ -35,47 +39,47 @@
3539
FORMAT.output = "advanced_hls"
3640
FORMAT.destination = DESTINATION
3741

38-
#replace with a link to your input video
42+
# replace with a link to your input video
3943
params.source = 'https://qencode.com/static/1.mp4'
4044
params.format = [FORMAT]
4145

4246

4347
def start_encode():
4448

45-
"""
49+
"""
4650
Create client object
4751
:param api_key: string. required
4852
:param api_url: string. not required
4953
:param api_version: int. not required. default 'v1'
5054
:return: task object
51-
"""
55+
"""
5256

53-
client = qencode.client(API_KEY)
54-
if client.error:
55-
raise QencodeClientException(client.message)
57+
client = qencode.client(API_KEY)
58+
if client.error:
59+
raise QencodeClientException(client.message)
5660

57-
print 'The client created. Expire date: %s' % client.expire
61+
print 'The client created. Expire date: %s' % client.expire
5862

59-
task = client.create_task()
63+
task = client.create_task()
6064

61-
if task.error:
62-
raise QencodeTaskException(task.message)
65+
if task.error:
66+
raise QencodeTaskException(task.message)
6367

64-
task.custom_start(params)
68+
task.custom_start(params)
6569

66-
if task.error:
67-
raise QencodeTaskException(task.message)
70+
if task.error:
71+
raise QencodeTaskException(task.message)
6872

69-
print 'Start encode. Task: %s' % task.task_token
73+
print 'Start encode. Task: %s' % task.task_token
7074

71-
while True:
72-
status = task.status()
73-
# print status
74-
print json.dumps(status, indent=2, sort_keys=True)
75-
if status['error'] or status['status'] == 'completed':
76-
break
77-
time.sleep(5)
75+
while True:
76+
status = task.status()
77+
# print status
78+
print json.dumps(status, indent=2, sort_keys=True)
79+
if status['error'] or status['status'] == 'completed':
80+
break
81+
time.sleep(5)
7882

7983

8084
if __name__ == '__main__':
81-
start_encode()
85+
start_encode()

0 commit comments

Comments
 (0)