Giter VIP home page Giter VIP logo

pycpix's Introduction

cpix

Python library for working with CPIX 2.1 (DASH-IF Content Protection Information Exchange) documents

For more details on CPIX see:

Supported features

  • Creation of CPIX documents
  • Content keys
  • Usage rules
  • DRM systems
  • Parsing of CPIX documents
  • Validation against CPIX XSD

Not yet implemented

  • Validation of document correctness (e.g. kid referenced by usage rule matches a content key)

Not supported

  • Encryption, decryption and signing are not supported.

Installation

Install using pip:

pip install cpix

Examples

Scripts

Example scripts which can be used with Widevine and Playready test servers to get or create keys and produce CPIX documents are available in example.

Simple CPIX

To create a simple CPIX document with a single key:

import cpix

full_cpix = cpix.CPIX(
    content_keys=cpix.ContentKeyList(
        cpix.ContentKey(
            kid="0DC3EC4F-7683-548B-81E7-3C64E582E136",
            cek="WADwG2qCqkq5TVml+U5PXw=="
        )
    ),
    drm_systems=cpix.DRMSystemList(
        cpix.DRMSystem(
            kid="0DC3EC4F-7683-548B-81E7-3C64E582E136",
            system_id="EDEF8BA9-79D6-4ACE-A3C8-27DCD51D21ED",
            pssh=("AAAAxnBzc2gBAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAINw+xPdoNUi4HnPGT"
                  "lguE2FEe37S9mVyu9EwbOfPNhDQAAAIISEBRHt+0vZlcrvRMGznzzYQ0SEF"
                  "rGoR6qL17Vv2aMQByBNMoSEG7hNRbI51h7rp9+zT6Zom4SEPnsEqYaJl1Hj"
                  "4MzTjp40scSEA3D7E92g1SLgec8ZOWC4TYaDXdpZGV2aW5lX3Rlc3QiEXVu"
                  "aWZpZWQtc3RyZWFtaW5nSOPclZsG")
        )
    )
)

This can then be printed as a formatted XML document:

print(str(full_cpix.pretty_print(xml_declaration=True), "utf-8'"))
<?xml version='1.0' encoding='utf-8'?>
<CPIX xmlns:pskc="urn:ietf:params:xml:ns:keyprov:pskc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="urn:dashif:org:cpix" xsi:schemaLocation="urn:dashif:org:cpix cpix.xsd">
  <ContentKeyList>
    <ContentKey kid="0dc3ec4f-7683-548b-81e7-3c64e582e136">
      <Data>
        <pskc:Secret>
          <pskc:PlainValue>WADwG2qCqkq5TVml+U5PXw==</pskc:PlainValue>
        </pskc:Secret>
      </Data>
    </ContentKey>
  </ContentKeyList>
  <DRMSystemList>
    <DRMSystem kid="0dc3ec4f-7683-548b-81e7-3c64e582e136" systemId="edef8ba9-79d6-4ace-a3c8-27dcd51d21ed">
      <PSSH>AAAAxnBzc2gBAAAA7e+LqXnWSs6jyCfc1R0h7QAAAAINw+xPdoNUi4HnPGTlguE2FEe37S9mVyu9EwbOfPNhDQAAAIISEBRHt+0vZlcrvRMGznzzYQ0SEFrGoR6qL17Vv2aMQByBNMoSEG7hNRbI51h7rp9+zT6Zom4SEPnsEqYaJl1Hj4MzTjp40scSEA3D7E92g1SLgec8ZOWC4TYaDXdpZGV2aW5lX3Rlc3QiEXVuaWZpZWQtc3RyZWFtaW5nSOPclZsG</PSSH>
    </DRMSystem>
  </DRMSystemList>
</CPIX>

pycpix's People

Contributors

markogle avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.