File tree Expand file tree Collapse file tree 6 files changed +80
-2
lines changed Expand file tree Collapse file tree 6 files changed +80
-2
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ client.create()
27
27
task = client.create_task()
28
28
task.start(TRANSCODING_PROFILEID, VIDO_URL)
29
29
30
+ #getting video metadata:
31
+ metadata = client.get_metadata(VIDEO_URL)
32
+
30
33
````
31
34
32
35
** Documentation**
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def x265_video_codec():
33
33
34
34
35
35
36
- __version__ = "0.9.27 "
36
+ __version__ = "0.9.28 "
37
37
__status__ = "Beta"
38
38
__author__ = "Qencode"
39
39
Original file line number Diff line number Diff line change 1
1
from . httptools import Http
2
2
from . task import Task
3
+ from . metadata import Metadata
3
4
4
5
class Client (object ):
5
6
@@ -41,3 +42,8 @@ def _get_access_token(self):
41
42
self .error = response ['error' ]
42
43
self .code = response ['error' ]
43
44
self .message = response .get ('message' )
45
+
46
+ def get_metadata (self , uri ):
47
+ metadata = Metadata (self .access_token , self .connect )
48
+ video_info = metadata .get (uri )
49
+ return video_info
Original file line number Diff line number Diff line change
1
+ from . task import *
2
+ from qencode3 import QencodeTaskException
3
+ import urllib .request as urllib2
4
+
5
+ class Metadata (Task ):
6
+
7
+ def get (self , uri ):
8
+ params = """
9
+ {"query": {
10
+ "source": "%s",
11
+ "format": [ {"output": "metadata", "metadata_version": "4.1.5"} ]
12
+ }
13
+ }
14
+ """ % uri
15
+ self .custom_start (params )
16
+ while True :
17
+ status = self .status ()
18
+ if status ['error' ] or status ['status' ] == 'completed' :
19
+ break
20
+ time .sleep (5 )
21
+
22
+ if self .error :
23
+ raise QencodeTaskException (self .message )
24
+
25
+ url = None
26
+ if len (status ['videos' ]) > 0 :
27
+ url = status ['videos' ][0 ]['url' ]
28
+ elif len (status ['audios' ]) > 0 :
29
+ url = status ['audios' ][0 ]['url' ]
30
+
31
+ if url is None :
32
+ raise QencodeTaskException ('No metadata URL found in status response' )
33
+
34
+ data = urllib2 .urlopen (url ).read ()
35
+
36
+ return data
37
+
38
+
Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import sys
5
+ import os .path
6
+ #import json
7
+ sys .path .append (os .path .abspath (os .path .join (os .path .dirname (__file__ ), os .path .pardir )))
8
+ import qencode3
9
+ from qencode3 import QencodeClientException
10
+
11
+ #replace with your API KEY (can be found in your Project settings on Qencode portal)
12
+ API_KEY = '5a2a846a26ace'
13
+ VIDEO_URL = 'https://nyc3.s3.qencode.com/qencode/bbb_30s.mp4'
14
+
15
+ client = qencode3 .client (API_KEY )
16
+ if client .error :
17
+ raise QencodeClientException (client .message )
18
+
19
+ print ('The client created. Expire date: {0}' .format (client .expire ))
20
+
21
+ metadata = client .get_metadata (VIDEO_URL )
22
+
23
+ try :
24
+ metadata = metadata .decode ("utf-8" )
25
+ except Exception as e :
26
+ pass
27
+
28
+ print (metadata )
29
+
30
+
31
+
Original file line number Diff line number Diff line change 13
13
14
14
setup (
15
15
name = 'qencode3' ,
16
- version = '0.9.27 ' ,
16
+ version = '0.9.28 ' ,
17
17
description = "Qencode client library to easily setup a working solution using Python v3.x." ,
18
18
long_description = long_description ,
19
19
long_description_content_type = 'text/markdown' ,
You can’t perform that action at this time.
0 commit comments