2 # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
4 # Copyright (c) 2014 Thibault Saunier <thibault.saunier@collabora.com>
5 # Copyright (c) 2017 Sebastian Droege <sebastian@centricular.com>
7 # This program is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU Lesser General Public
9 # License as published by the Free Software Foundation; either
10 # version 2.1 of the License, or (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public
18 # License along with this program; if not, write to the
19 # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
20 # Boston, MA 02110-1301, USA.
23 The GstValidate DASH-IF test-vectors testsuite
29 import xml.etree.ElementTree as ET
31 TESTVECTOR_URL = "http://testassets.dashif.org:3000/v1/testvectors"
34 def cleanup_entries(data):
35 # we need to do some minor cleanup of the entries:
36 # * Replace <a href=..>something</a>
37 # * Add __ID corresponding to the testvector unique key on the website
40 # "testvector": "<a href=\"#testvector/details/58a5e0707459f8cb201b8ceb\">W3C Clear Key - audio only variant</a>",
41 testvector = entry["testvector"]
42 tmp = ET.XML(testvector)
43 _id = tmp.attrib["href"].split('/')[-1]
45 # use a key that is almost certain to be the first one. Ensures entries are sorted by ID
47 entry["testvector_description"] = _desc
49 # "url": "<a href=https://media.axprod.net/TestVectors/v7-MultiDRM-MultiKey-MultiPeriod/Manifest_1080p_ClearKey.mpd>Link</a>"
50 # badly formed html, let's just use splitters
52 _url = url.split("<a href=")[1].split(">Link<")[0]
56 def update_testvector_list(outputfile=None):
57 # download and cleanup testvector json
58 resp = requests.get(url=TESTVECTOR_URL)
59 data = json.loads(resp.text)
61 if outputfile is None:
62 print(json.dumps(data["data"], indent=4, sort_keys=True))
64 json.dump(data["data"], fp=open(outputfile, "w"), indent=4, sort_keys=True)
67 if __name__ == "__main__":
69 update_testvector_list(sys.argv[1])
71 update_testvector_list()