Last active
February 6, 2025 12:49
-
-
Save riverscn/e19479e9ca02867a49fe68558762ee2c to your computer and use it in GitHub Desktop.
中国电信IPTV抓包数据转m3u8播放列表
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
#!/bin/bash | |
# Usage: bash gen_iptv_m3u8.sh iptv.pcap | |
udpxy=192.168.5.1:7088 | |
input=$1 | |
workdir=${input%%.*} | |
tshark -r $1 -Y 'http.response_for.uri contains getchannellist' -T jsonraw -j data-text-lines_raw \ | |
| awk '/"data-text-lines_raw"/{getline; print}' \ | |
| sed -E 's/"|,//g' \ | |
| xxd -r -p \ | |
| tee \ | |
>(awk -F '[,=?|:"]' '/ChannelName=/ {printf "#EXTINF:-1 tvg-name=\"%s\",%s\nrtp:%s:%s\n", $9, $9, $18, $19}' \ | |
> ${workdir}_rtp.m3u8) \ | |
>(awk -F '[,=?|:"]' '/ChannelName=/ {printf "#EXTINF:-1 tvg-name=\"%s\",%s\nhttp://'"$udpxy"'/udp%s:%s\n", $9, $9, $18, $19}' \ | |
| sed -E 's/udp\/\//udp\//g' > ${workdir}_rtp_http.m3u8) \ | |
>(awk -F '[,=?|:"]' '/ChannelName=/ {printf "#EXTINF:-1 tvg-name=\"%s\",%s\n%s:%s\n", $9, $9, $20, $21}' \ | |
> ${workdir}_rtsp.m3u8) \ | |
>/dev/null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment