Skip to content

Instantly share code, notes, and snippets.

@orumin
Last active January 4, 2022 12:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orumin/ec08f35fd958bee41c9bfdd10b8c8d5d to your computer and use it in GitHub Desktop.
Save orumin/ec08f35fd958bee41c9bfdd10b8c8d5d to your computer and use it in GitHub Desktop.
mirakc: 局ロゴ取得
#!/bin/sh
services=`curl -sSL http://localhost:40772/api/services`
len=`echo $services | jq length`
cat<<EOF > config_logo.yml
resource:
logos:
EOF
len_1=`expr $len - 1`
for idx in `seq 0 $len_1`; do
service=`echo $services | jq -M .[$idx]`
service_type=`echo $service | jq -Mr .channel.type`
service_type_lowercase=`echo $service_type | tr '[:upper:]' '[:lower:]'`
channel=`echo $service | jq -Mr .channel.channel`
serviceId=`echo $service | jq -Mr .serviceId`
transportStreamId=`echo $service | jq -Mr .transportStreamId`
networkId=`echo $service | jq -Mr .networkId`
echo " - serivce-triple: [$networkId, $transportStreamId, $serviceId]" >> config_logo.yml
echo " image: /var/lib/mirakc/logos/${service_type_lowercase}_${serviceId}_4.png" >> config_logo.yml
curl -sG http://localhost:40772/api/channels/$service_type/$channel/stream | \
sudo docker exec -i mirakc mirakc-arib collect-logos | head -n 6 > tmp.json
logo_idx=0
for logo in `cat tmp.json | jq -Mr '.data' | sed 's|data:image/png;base64,||'`; do
echo $logo | base64 -d > "${service_type_lowercase}_${serviceId}_${logo_idx}.png"
logo_idx=`expr $logo_idx + 1`
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment