Skip to content

Commit 31376bb

Browse files
committed
Docs: Fix examples, indentation, formatting, development instructions
1 parent d57b671 commit 31376bb

File tree

4 files changed

+146
-134
lines changed

4 files changed

+146
-134
lines changed

README.md

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
1-
## qencode-api-python-client
1+
# Qencode Python Library
22

3-
**install sdk libraries from github**
3+
The Qencode Python library provides convenient access to the Qencode API
4+
for applications written in the Python language.
45

5-
```
6-
cd your-workspace-folder
7-
git clone https://github.com/qencode-dev/qencode-api-python-client
8-
cd qencode-api-python-client
9-
pip install -r requirements.txt
10-
python setup.py install
11-
```
6+
Inside this repository in sample-code/, there are examples of [video transcoding](https://cloud.qencode.com/)
7+
tasks, launching encoding jobs, video clipping and receiving callbacks. Updates are posted on a regular basis and we are open to any improvements or suggestions you may have.
128

13-
**install from pip**
9+
## Installation
1410

15-
```
11+
You don't need the source code unless you want to modify the package itself.
12+
If you just want to use the package:
13+
14+
```sh
1615
pip install --upgrade qencode
1716
```
1817

19-
**Usage**
18+
## Contributing
19+
20+
To modify the package, install [poetry](https://python-poetry.org/docs/#installation)
21+
and checkout the source:
2022

23+
```sh
24+
cd your-workspace-folder
25+
git clone https://github.com/qencode-dev/qencode-api-python-client
26+
cd qencode-api-python-client
27+
poetry shell
28+
poetry install
2129
```
30+
31+
## Usage
32+
33+
```python
2234
import qencode
2335

2436
client = qencode.client(API_KEY)
@@ -27,19 +39,15 @@ client.create()
2739
task = client.create_task()
2840
task.start(TRANSCODING_PROFILEID, VIDEO_URL)
2941

30-
31-
#getting video metadata:
42+
# Getting video metadata
3243
metadata = client.get_metadata(VIDEO_URL)
33-
3444
```
3545

36-
**Documentation**
46+
## Documentation
3747

3848
Documentation is available at <https://docs.qencode.com>
3949

40-
**Description**
41-
42-
Inside this library, you will find sample code for creating [video transcoding](https://cloud.qencode.com/) tasks, launching encoding jobs, video clipping and receiving callbacks. Updates are posted on a regular basis and we are open to any improvements or suggestions you may have.
50+
## Features
4351

4452
Some of the options Qencode offers for transcoding your videos at scale:
4553

docs/install.md

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
##Installation
1+
# Installation
22

3-
**install sdk libraries from github**
3+
You don't need the source code unless you want to modify the package itself.
4+
If you just want to use the package:
45

6+
```sh
7+
pip install --upgrade qencode
58
```
9+
10+
# Contributing
11+
12+
To modify the package, install [poetry](https://python-poetry.org/docs/#installation)
13+
and checkout the source:
14+
15+
```sh
616
cd your-workspace-folder
717
git clone https://github.com/qencode-dev/qencode-api-python-client
818
cd qencode-api-python-client
9-
pip install -r requirements.txt
10-
python setup.py install
11-
```
12-
13-
**install from pip**
14-
15-
```
16-
pip install --upgrade qencode
19+
poetry shell
20+
poetry install
1721
```

docs/quickstart.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1+
# Quickstart
2+
13
## Installation
24

3-
**install sdk libraries from github**
5+
You don't need the source code unless you want to modify the package itself.
6+
If you just want to use the package:
47

8+
```sh
9+
pip install --upgrade qencode
510
```
11+
12+
# Contributing
13+
14+
To modify the package, install [poetry](https://python-poetry.org/docs/#installation)
15+
and checkout the source:
16+
17+
```sh
618
cd your-workspace-folder
719
git clone https://github.com/qencode-dev/qencode-api-python-client
820
cd qencode-api-python-client
9-
pip install -r requirements.txt
10-
python setup.py install
11-
```
12-
13-
**install from pip**
14-
15-
```
16-
pip install --upgrade qencode
21+
poetry shell
22+
poetry install
1723
```
1824

19-
**Usage**
25+
## Usage
2026

21-
```
27+
```python
2228
import qencode
2329

2430
client = qencode.client(API_KEY)
2531
client.create()
2632

2733
task = client.create_task()
28-
task.start(TRANSCODING_PROFILEID, VIDO_URL)
29-
3034
```
3135

32-
**Documentation**
36+
## Documentation
3337

3438
Documentation is available at <https://docs.qencode.com>

docs/usage.md

Lines changed: 87 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,65 @@
1-
##Usage
1+
# Usage
22

3-
**Usage by transcoding profile ID**
3+
## Usage by transcoding profile ID
44

5-
```
6-
import sys
5+
```python
76
import os.path
8-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
9-
import qencode
7+
import sys
108
import time
119

10+
import qencode
1211

1312
API_KEY = 'Your API KEY'
1413
TRANSCODING_PROFILEID = 'Your profile ID'
15-
VIDO_URL = 'your source url'
16-
14+
VIDEO_URL = 'your source url'
1715

1816

1917
def start_encode():
20-
"""
21-
Create client object
22-
:param api_key: string. required
23-
:param api_url: string. not required
24-
:param api_version: int. not required. default 'v1'
25-
:return: client object
26-
"""
27-
client = qencode.client(API_KEY)
28-
client.create()
29-
if client.error:
30-
print 'encoder error:', client.error, client.message
31-
raise SystemExit
32-
33-
"""
34-
:return: task object
35-
"""
36-
task = client.create_task()
37-
task.start_time = 0.0
38-
task.duration = 10.0
39-
task.start(TRANSCODING_PROFILEID, VIDO_URL)
40-
if task.error:
41-
print 'task error:', task.error, task.message
42-
raise SystemExit
43-
44-
while True:
45-
status = task.status()
46-
print '{0} | {1} | {2} | error: {3}'.format(VIDO_URL,
47-
status.get('status'),
48-
status.get('percent'),
49-
status.get('error'),
50-
status.get('error_description'))
51-
if status['error']:
52-
break
53-
if status['status'] == 'completed':
54-
break
55-
time.sleep(15)
18+
client = qencode.client(API_KEY)
19+
client.create()
20+
if client.error:
21+
print 'encoder error:', client.error, client.message
22+
raise SystemExit
23+
24+
task = client.create_task()
25+
task.start_time = 0.0
26+
task.duration = 10.0
27+
task.start(TRANSCODING_PROFILEID, VIDEO_URL)
28+
if task.error:
29+
print 'task error:', task.error, task.message
30+
raise SystemExit
31+
32+
while True:
33+
status = task.status()
34+
print (
35+
'{0} | {1} | {2} | error: {3}'.format(
36+
VIDEO_URL,
37+
status.get('status'),
38+
status.get('percent'),
39+
status.get('error'),
40+
status.get('error_description'),
41+
)
42+
)
43+
if status['error']:
44+
break
45+
if status['status'] == 'completed':
46+
break
47+
time.sleep(15)
5648

5749

5850
if __name__ == '__main__':
59-
start_encode()
51+
start_encode()
6052
```
6153

62-
**Usage by custom parameters**
54+
## Usage by custom parameters
6355

64-
```
65-
import sys
56+
```python
6657
import os.path
67-
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir)))
68-
import qencode
58+
import sys
6959
import time
7060

61+
import qencode
62+
7163
API_KEY = 'Your API KEY'
7264

7365
params = qencode.custom_params()
@@ -103,68 +95,72 @@ params.format = [FORMAT]
10395

10496

10597
def start_encode():
106-
107-
"""
98+
"""
10899
Create client object
109100
:param api_key: string. required
110101
:param api_url: string. not required
111102
:param api_version: int. not required. default 'v1'
112103
:return: client object
113-
"""
114-
client = qencode.client(API_KEY)
115-
client.create()
116-
if client.error:
117-
print 'encoder error:', client.error, client.message
118-
raise SystemExit
119-
120-
"""
104+
"""
105+
client = qencode.client(API_KEY)
106+
client.create()
107+
if client.error:
108+
print('encoder error:', client.error, client.message)
109+
raise SystemExit
110+
111+
"""
121112
Create task
122113
:return: task object
123-
"""
124-
125-
task = client.create_task()
126-
task.custom_start(params)
127-
if task.error:
128-
print 'task error:', task.error, task.message
129-
raise SystemExit
130-
131-
while True:
132-
status = task.status()
133-
print '{0} | {1} | {2} | error: {3}'.format(params.source,
134-
status.get('status'),
135-
status.get('percent'),
136-
status.get('error'),
137-
status.get('error_description'))
138-
if status['error']:
139-
break
140-
if status['status'] == 'completed':
141-
break
142-
time.sleep(15)
114+
"""
115+
task = client.create_task()
116+
task.custom_start(params)
117+
if task.error:
118+
print('task error:', task.error, task.message)
119+
raise SystemExit
120+
121+
while True:
122+
status = task.status()
123+
print(
124+
'{0} | {1} | {2} | error: {3}'.format(
125+
params.source,
126+
status.get('status'),
127+
status.get('percent'),
128+
status.get('error'),
129+
status.get('error_description'),
130+
)
131+
)
132+
if status['error']:
133+
break
134+
if status['status'] == 'completed':
135+
break
136+
time.sleep(15)
143137

144138

145139
if __name__ == '__main__':
146-
start_encode()
140+
start_encode()
147141
```
148142

149-
**Usage with callback methods**
143+
## Usage with callback methods
150144

151145
```
152-
def my_callback(e):
153-
print e
146+
def on_process_changed(process_data):
147+
print('on_process_changed', process_data)
154148
155-
def my_callback2(e):
156-
print e
157149
158-
...
150+
def on_task_completed(process_data):
151+
print('on_task_completed', process_data)
159152
160-
task.start(TRANSCODING_PROFILEID, VIDO_URL)
153+
154+
# ...
155+
156+
task.start(TRANSCODING_PROFILEID, VIDEO_URL)
161157
if task.error:
162-
raise SystemExit
158+
raise SystemExit
163159
164160
task.progress_changed(my_callback)
165-
task.task_completed(my_callback2)
161+
task.task_completed(on_task_completed)
166162
```
167163

168-
**Documentation**
164+
## Documentation
169165

170166
Documentation is available at <https://docs.qencode.com>

0 commit comments

Comments
 (0)