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()
2727task = client.create_task()
2828task.start(TRANSCODING_PROFILEID, VIDO_URL)
2929
30+ #getting video metadata:
31+ metadata = client.get_metadata(VIDEO_URL)
32+
3033````
3134
3235** Documentation**
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ def x265_video_codec():
3333
3434
3535
36- __version__ = "0.9.27 "
36+ __version__ = "0.9.28 "
3737__status__ = "Beta"
3838__author__ = "Qencode"
3939
Original file line number Diff line number Diff line change 11from . httptools import Http
22from . task import Task
3+ from . metadata import Metadata
34
45class Client (object ):
56
@@ -41,3 +42,8 @@ def _get_access_token(self):
4142 self .error = response ['error' ]
4243 self .code = response ['error' ]
4344 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 1313
1414setup (
1515 name = 'qencode3' ,
16- version = '0.9.27 ' ,
16+ version = '0.9.28 ' ,
1717 description = "Qencode client library to easily setup a working solution using Python v3.x." ,
1818 long_description = long_description ,
1919 long_description_content_type = 'text/markdown' ,
You can’t perform that action at this time.
0 commit comments