forked from ali1234/vhs-teletext
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
script to split squashed t42 file into a directory of separate t42 pages
- Loading branch information
Showing
1 changed file
with
26 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,26 @@ | |||
#!/usr/bin/env python | |||
|
|||
import sys | |||
import os | |||
|
|||
from teletext.t42.pipeline import reader, make_service | |||
from teletext.t42.packet import Packet | |||
|
|||
if sys.platform == "win32": | |||
import os, msvcrt | |||
msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) | |||
|
|||
service = make_service(reader(open(sys.argv[1], 'rb'))) | |||
|
|||
for magazineno,magazine in service.magazines.iteritems(): | |||
for pageno,page in magazine.pages.iteritems(): | |||
for subpageno,subpage in page.subpages.iteritems(): | |||
if magazineno == 0: | |||
mag = 8 | |||
else: | |||
mag = magazineno | |||
outfile = open(os.path.join(sys.argv[2], 'P%d%02X-%04X.t42' % (mag, pageno, subpageno)), 'wb') | |||
subpagepackets = subpage.to_packets(magazineno, pageno, subpageno, magazine.header(magazineno, subpage)) | |||
for i in subpagepackets: | |||
outfile.write(i.to_bytes()) | |||
outfile.close() |