Files
MAcode/tcs-iptv/scripts/seed_demo.sh
T

84 lines
4.1 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# 陕西 IPTV 场景演示数据:造若干条内容,跑通"送审→发码→审核→入库→发布→注入"。
#
# 参与方设定:
# 管理方(审核+监管):陕西IPTV运营公司(机构节点 6101)
# 内容提供商(CP):西安曲江丝路文化传播 / 陕文投艺达影视 / 西部电影集团(西影)
# 运营商:中国电信陕西(天翼高清) / 中国移动陕西(魔百和) / 中国联通陕西
set -e
BASE="http://localhost:8080/api/v1"
sign() { printf '%s\n%s' "$2" "$3" | openssl dgst -sha256 -hmac "$1" -binary | base64; }
call() { # key secret method path body
local key="$1" secret="$2" method="$3" path="$4" body="$5"
local sig; sig=$(sign "$secret" "$method" "/api/v1${path%%\?*}")
if [ "$method" = "GET" ]; then
curl -s -X GET "$BASE$path" -H "Authorization: TCS $key:$sig"
else
curl -s -X "$method" "$BASE$path" -H "Authorization: TCS $key:$sig" \
-H "Content-Type: application/json" -d "$body"
fi
}
field() { echo "$1" | sed -n "s/.*\"$2\":\"\([^\"]*\)\".*/\1/p"; }
# episodes_json base_hash count → 构造分集哈希数组(一剧一码 + 集级独立哈希)
episodes_json() {
local fh="$1" n="${2:-6}" i out=""
for i in $(seq 1 "$n"); do
[ -n "$out" ] && out="$out,"
out="$out{\"episode\":$i,\"file_sha256\":\"$fh-E$i\",\"merkle_root\":\"mr-$fh-E$i\",\"perceptual_hash\":\"ph-$fh-E$i\",\"resolution\":\"1080p\",\"duration\":2400}"
done
echo "[$out]"
}
# 一条内容完整流转:title category fhash cp_id cp_name op_id op_name cdn [episodes]
flow() {
local title="$1" cat="$2" fh="$3" cpid="$4" cpname="$5" opid="$6" opname="$7" cdn="$8"
local n="${9:-6}"
echo ">>> [$title] CP=$cpname $n 集,每集独立哈希)"
local eps; eps=$(episodes_json "$fh" "$n")
local reg; reg=$(call ak-cp sk-cp POST /content/register \
"{\"title\":\"$title\",\"episode_count\":$n,\"category\":\"$cat\",\"file_sha256\":\"$fh\",\"merkle_root\":\"mr-$fh\",\"perceptual_hash\":\"ph-$fh\",\"episodes\":$eps,\"cp_media_id\":\"$cpid\",\"cp_name\":\"$cpname\"}")
local rid ctid; rid=$(field "$reg" review_id); ctid=$(field "$reg" content_twin_id)
# CSPS 合规审核(发码前)
call ak-reviewer sk-reviewer POST /content/csps-result \
"{\"review_id\":\"$rid\",\"approved\":true,\"reviewer_id\":\"sxiptv-审核员01\"}" >/dev/null
# 审核通过后发码签发
local iss; iss=$(call ak-regulator sk-regulator POST /content/issue \
"{\"review_id\":\"$rid\",\"issuer\":\"陕西IPTV运营公司\"}")
local ma cert; ma=$(field "$iss" ma_code); cert=$(field "$iss" certificate)
echo " CC码: $ma"
call ak-reviewer sk-reviewer POST /content/ingest \
"{\"ma_code\":\"$ma\",\"content_twin_id\":\"$ctid\",\"media_asset_id\":\"SXMEDIA-$fh\",\"lib_name\":\"陕西IPTV媒体资源库\"}" >/dev/null
call ak-reviewer sk-reviewer POST /content/publish \
"{\"ma_code\":\"$ma\",\"certificate\":\"$cert\"}" >/dev/null
local inj; inj=$(call ak-operator sk-operator POST /content/inject \
"{\"content_twin_id\":\"$ctid\",\"ma_code\":\"$ma\",\"file_sha256\":\"$fh\",\"operator_id\":\"$opid\",\"cdn_endpoint\":\"$cdn\"}")
echo " 运营商: $opname 注入: $(field "$inj" distribution_id)"
echo "$ma" >> /tmp/tcs_demo_cccodes.txt
}
: > /tmp/tcs_demo_cccodes.txt
flow "长安少年行" WD "fh-changan-001" \
"XAQJSL-2026-001" "西安曲江丝路文化传播有限公司" \
"CT-SX-IPTV" "中国电信陕西公司(天翼高清)" "cdn://ct-sx/iptv/vod/changan001"
flow "白鹿原·麦客" WJ "fh-bailuyuan-002" \
"SWTYD-2026-007" "陕文投艺达影视有限公司" \
"CM-SX-IPTV" "中国移动陕西公司(魔百和)" "cdn://cm-sx/iptv/vod/bailuyuan002"
flow "丝路驼铃" DY "fh-silu-003" \
"XIYING-2026-015" "西部电影集团(西影视频)" \
"CU-SX-IPTV" "中国联通陕西公司" "cdn://cu-sx/iptv/vod/silu003"
echo ""
echo "=== 已生成 MA 码(可复制到监管大屏查询)==="
cat /tmp/tcs_demo_cccodes.txt
echo ""
echo "提示:在 http://localhost:5174「角色工作台 → 监管片库」点详情查看全链路三方映射与集级哈希;"
echo " 或在「大小屏融合」tab 用上述 MA 码体验跨域解析 / 扫码验真 / 跨屏权益。"