# Pastebin PJeVxRyU # -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python # # Copyright (c) 2014 Thibault Saunier # Copyright (c) 2017 Sebastian Droege # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this program; if not, write to the # Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, # Boston, MA 02110-1301, USA. """ The GstValidate DASH-IF test-vectors testsuite """ import json import requests import sys import xml.etree.ElementTree as ET TESTVECTOR_URL = "http://testassets.dashif.org:3000/v1/testvectors" def cleanup_entries(data): # we need to do some minor cleanup of the entries: # * Replace something # * Add __ID corresponding to the testvector unique key on the website d = data["data"] for entry in d: # "testvector": "W3C Clear Key - audio only variant", testvector = entry["testvector"] tmp = ET.XML(testvector) _id = tmp.attrib["href"].split('/')[-1] _desc = tmp.text # use a key that is almost certain to be the first one. Ensures entries are sorted by ID entry["A__ID"] = _id entry["testvector_description"] = _desc # "url": "Link" # badly formed html, let's just use splitters url = entry["url"] _url = url.split("Link<")[0] entry["url"] = _url def update_testvector_list(outputfile=None): # download and cleanup testvector json resp = requests.get(url=TESTVECTOR_URL) data = json.loads(resp.text) cleanup_entries(data) if outputfile is None: print(json.dumps(data["data"], indent=4, sort_keys=True)) else: json.dump(data["data"], fp=open(outputfile, "w"), indent=4, sort_keys=True) if __name__ == "__main__": if len(sys.argv) > 1: update_testvector_list(sys.argv[1]) else: update_testvector_list()