Added script for extraction.

This commit is contained in:
Yuuki Chan 2024-10-12 13:46:02 +09:00
parent 2a500d7900
commit baf29802e5
3 changed files with 41 additions and 0 deletions

27
.script/Extract.sh Normal file
View file

@ -0,0 +1,27 @@
#!/bin/bash
for filename in ./*.ts; do
Y=${filename:2:4}
M=${filename:7:2}
D=${filename:10:2}
H=${filename:13:2}
N=${filename:16:2}
echo "Working on "$filename" ..."
epgdump json "$filename" "$Y-$M-$D"_"$H-$N.json"
done
for filename in ./*.json; do
python3 readable.py $filename
done
for filename in ./*_formatted.json; do
f=${filename:2:16}
mv $filename $f".json"
done
for filename in ./*.json; do
f=${filename:2:16}
7za a -mx9 -ms=on -mhe=on -m0=lzma2 -mfb64 -md32m $f".7z" $filename -y > /dev/null
rm $filename
done

6
.script/README.md Normal file
View file

@ -0,0 +1,6 @@
# Note: Only works with Linux (WSL2) for now.
## Requirements
- Python
- epgdump ([link](https://github.com/Piro77/epgdump))
- Filename format `2024年10月11日20時50分00秒-EXAMPLE_CHANNEL.ts`

8
.script/readable.py Normal file
View file

@ -0,0 +1,8 @@
import json
import sys
data = json.load(open(sys.argv[1], mode='r'))
with open(f'{sys.argv[1].replace(".json", "_formatted.json")}', mode='w', encoding='UTF-8') as w:
w.write(json.dumps(data, indent=4, ensure_ascii=False))