class UHSStreamWriter(SegmentedStreamWriter): def __init__(self, *args, **kwargs): SegmentedStreamWriter.__init__(self, *args, **kwargs) self.concater = FLVTagConcat(flatten_timestamps=True, sync_headers=True) def open_chunk(self, chunk, retries=3): if not retries or self.closed: return try: params = {} if chunk.offset: params["start"] = chunk.offset return http.get(chunk.url, timeout=10, params=params, exception=StreamError) except StreamError as err: self.logger.error("Failed to open chunk {0}: {1}", chunk.num, err) return self.open_chunk(chunk, retries - 1) def write(self, chunk, chunk_size=8192): res = self.open_chunk(chunk) if not res: return try: for data in self.concater.iter_chunks( buf=res.content, skip_header=not chunk.offset): self.reader.buffer.write(data) if self.closed: break else: self.logger.debug("Download of chunk {0} complete", chunk.num) except IOError as err: self.logger.error("Failed to read chunk {0}: {1}", chunk.num, err)
class UHSStreamWriter(SegmentedStreamWriter): def __init__(self, *args, **kwargs): SegmentedStreamWriter.__init__(self, *args, **kwargs) self.concater = FLVTagConcat(flatten_timestamps=True, sync_headers=True) def open_chunk(self, chunk, retries=3): if not retries or self.closed: return try: params = {} if chunk.offset: params["start"] = chunk.offset return http.get(chunk.url, timeout=10, params=params, exception=StreamError) except StreamError as err: self.logger.error("Failed to open chunk {0}: {1}", chunk.num, err) return self.open_chunk(chunk, retries - 1) def write(self, chunk, chunk_size=8192): res = self.open_chunk(chunk) if not res: return try: for data in self.concater.iter_chunks(buf=res.content, skip_header=not chunk.offset): self.reader.buffer.write(data) if self.closed: break else: self.logger.debug("Download of chunk {0} complete", chunk.num) except IOError as err: self.logger.error("Failed to read chunk {0}: {1}", chunk.num, err)
def __init__(self, *args, **kwargs): SegmentedStreamWriter.__init__(self, *args, **kwargs) self.concater = FLVTagConcat(flatten_timestamps=True, sync_headers=True)
def __init__(self, *args, **kwargs): FLVTagConcat.__init__(self, *args, **kwargs)