#!/usr/bin/env python # Copyright 2016 Sam Yaple # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # Copied and licensed from https://github.com/SamYaple/osdk from binascii import b2a_hex from binascii import crc32 from datetime import datetime from struct import pack from struct import unpack from uuid import UUID class osdk(object): def __init__(self, manifest): self.manifest = manifest self.segments = dict() self.metadata = dict() self.metadata['signature'] = \ UUID('d326503ab5ca49adac56c89eb0b8ef08').bytes self.metadata['version'] = 0 def write_manifest(self): with open(self.manifest, 'wb') as f: self.write_header(f) self.write_body(f) def build_header(self): timestamp = utctimestamp() padding = str.encode('\0\0' * 14) data = pack( '