Skip to content

Commit 7de936b

Browse files
committed
Merge pull request #48 from eauge/develop
Added hasAudio and hasVideo feature to archiving
2 parents 2634cd1 + 3470dc7 commit 7de936b

File tree

4 files changed

+120
-2
lines changed

4 files changed

+120
-2
lines changed

opentok/archives.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ class Archive(object):
5252
Amazon S3 bucket or Windows Azure container that you set at the
5353
`OpenTok dashboard <https://dashboard.tokbox.com>`_.
5454
55+
:ivar hasAudio:
56+
Boolean value set to true when the archive contains an audio track,
57+
and set to false otherwise.
58+
59+
:ivar hasVideo:
60+
Boolean value set to true when the archive contains a video track,
61+
and set to false otherwise.
62+
5563
:ivar url:
5664
The download URL of the available MP4 file. This is only set for an archive with the status set to
5765
"available"; for other archives, (including archives with the status "uploaded") this property is
@@ -72,6 +80,8 @@ def __init__(self, sdk, values):
7280
self.created_at = datetime.fromtimestamp(values.get('createdAt') // 1000, timezone.utc)
7381
self.size = values.get('size')
7482
self.duration = values.get('duration')
83+
self.hasAudio = values.get('hasAudio')
84+
self.hasVideo = values.get('hasVideo')
7585
self.url = values.get('url')
7686

7787
def stop(self):

opentok/opentok.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ def archive_url(self, archive_id=None):
263263
url = url + '/' + archive_id
264264
return url
265265

266-
def start_archive(self, session_id, **kwargs):
266+
def start_archive(self, session_id, hasAudio=True, hasVideo=True, name=None):
267267
"""
268268
Starts archiving an OpenTok 2.0 session.
269269
@@ -278,11 +278,17 @@ def start_archive(self, session_id, **kwargs):
278278
:param String name: This is the name of the archive. You can use this name
279279
to identify the archive. It is a property of the Archive object, and it is a property
280280
of archive-related events in the OpenTok.js library.
281+
:param Boolean hasAudio: if set to true, an audio track will be inserted to the archive. hasAudio is an optional parameter that is set to true by default.
282+
:param Boolean hasVideo: if set to true, a video track will be inserted to the archive. hasVideo is an optional parameter that is set to true by default.
281283
282284
:rtype: The Archive object, which includes properties defining the archive,
283285
including the archive ID.
284286
"""
285-
payload = {'name': kwargs.get('name'), 'sessionId': session_id}
287+
payload = {'name': name,
288+
'sessionId': session_id,
289+
'hasAudio': hasAudio,
290+
'hasVideo': hasVideo
291+
}
286292

287293
response = requests.post(self.archive_url(), data=json.dumps(payload), headers=self.archive_headers())
288294

tests/test_archive.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ def test_stop_archive(self):
2929
u('sessionId'): u('SESSIONID'),
3030
u('size'): 0,
3131
u('status'): u('started'),
32+
u('hasAudio'): True,
33+
u('hasVideo'): True,
3234
u('url'): None,
3335
})
3436
httpretty.register_uri(httpretty.POST, u('https://api.opentok.com/v2/partner/{0}/archive/{1}/stop').format(self.api_key, archive_id),
@@ -43,6 +45,8 @@ def test_stop_archive(self):
4345
"sessionId" : "SESSIONID",
4446
"size" : 0,
4547
"status" : "stopped",
48+
"hasAudio": true,
49+
"hasVideo": false,
4650
"url" : null
4751
}""")),
4852
status=200,
@@ -66,6 +70,8 @@ def test_stop_archive(self):
6670
expect(archive).to.have.property(u('created_at')).being.equal(created_at)
6771
expect(archive).to.have.property(u('size')).being.equal(0)
6872
expect(archive).to.have.property(u('duration')).being.equal(0)
73+
expect(archive).to.have.property(u('hasAudio')).being.equal(True)
74+
expect(archive).to.have.property(u('hasVideo')).being.equal(False)
6975
expect(archive).to.have.property(u('url')).being.equal(None)
7076

7177
@httpretty.activate
@@ -81,6 +87,8 @@ def test_delete_archive(self):
8187
u('sessionId'): u('SESSIONID'),
8288
u('size'): 0,
8389
u('status'): u('available'),
90+
u('hasAudio'): True,
91+
u('hasVideo'): True,
8492
u('url'): None,
8593
})
8694
httpretty.register_uri(httpretty.DELETE, u('https://api.opentok.com/v2/partner/{0}/archive/{1}').format(self.api_key, archive_id),

0 commit comments

Comments
 (0)