youzaka / ariblib Goto Github PK
View Code? Open in Web Editor NEWpython implementation of arib-std-b10 and arib-stb-b24
License: MIT License
python implementation of arib-std-b10 and arib-stb-b24
License: MIT License
そのまま pil-py3k を使っても動かない
( import Image
を from PIL import Image
にしないといけなかったりする)
ので、それがこの環境のみの問題なら自前で直すしどこでも起こる問題ならpull req してみる
CLIな環境だと (携帯電話)
リッチな環境だと、それに相当するUnicode文字
みたいな
https://www.python.org/dev/peps/pep-0479/
ariblib/packet.py
def __iter__(self):
packet_size = self.PACKET_SIZE
chunk_size = self.chunk_size
buffer_size = packet_size * chunk_size
packets = iter(lambda: self.read(buffer_size), b'')
for packet in packets:
for start, stop in zip(
range(0, buffer_size - packet_size + 1, packet_size),
range(packet_size, buffer_size + 1, packet_size)
):
next = packet[start:stop]
if not next:
raise StopIteration <---
yield next
{{DRCS:<character_code>:<hash>}}
のように出力しておき、画像イメージから代替イメージを決めたあとに適宜置換する @case(lambda self: self.logo_transmission_type == x03)
class type_03(Syntax):
logo_char = aribstr(lambda self: self.descriptor_length - 1)
親のdescriptor_length が読めないのでエラーになる。
caseの場合には呼び出し元の参照を渡して、AttributeErrorだったら上を見るみたいな実装になるかも
こう使えるようなの
with TransportStreamFile("/path/to/file") as ts:
for event in events(ts): # EventInformationTableのeventsごとにyieldする
event.title # ShortEventDescriptor.event_name_char
event.description # ShortEventDescriptor.text_char
event.longdesc # ExtendedEventDescriptor.item_description_char, item_charをそのまま結合
event.descdict # ExtendedEventDescriptorの中身を辞書にパース
event.genre # ContentDescriptor.content_nibble_level_1
event.subgenre # ContentDescriptor.content_nibble_level_2
event.sampling_rate # AudioComponentDescriptor.sampling_rate
# その他もろもろ
字幕の場合
with TransportStramFile("/path/to/file") as ts:
for caption in captions(ts, color=True): # 字幕パケットをさらに色別にyieldするジェネレータ
caption.at # 字幕送出日時
caption.body # 字幕本文
caption.color # 字幕の色
caption.speaker # 話者名
captions(ts, dot=True)
とすると PIL で PNG 画像出す代わりに標準出力にドット表示したり
あと、TransportStreamFile()
と同じく使えるtsopen()
って関数があるとタイプ数節約できてよさそう
item_description_char
が空か一つ前と同じ場合は、本文(item_char
)を一つ前のものにつなげるitem
に分割されている場合がある)A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.