9db0a8a4d4
- seed_demo.sh: 每剧提交6集独立哈希(file/merkle/perceptual+分辨率/时长) - 修复演示数据只有整剧哈希、无集级绑定的问题 - 验证: 3剧×6集集级哈希落 hash_binding(episode>0),集级验真 match/mismatch 正常
83 lines
4.0 KiB
Bash
83 lines
4.0 KiB
Bash
#!/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 " MA码: $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_macodes.txt
|
||
}
|
||
|
||
: > /tmp/tcs_demo_macodes.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_macodes.txt
|
||
echo ""
|
||
echo "提示:在 http://localhost:5174 输入上述任一 MA 码查询全链路三方映射。"
|