Skip to content

Instantly share code, notes, and snippets.

@fcicq

fcicq/showroomlive.sh

Last active Apr 26, 2018
Embed
What would you like to do?
Recorder for showroom-live.com
#!/bin/bash
# coding: utf-8
# showroomlive.sh by fcicq
(jq --version 1>/dev/null 2>&1) || (echo 'install jq first'; exit)
(livestreamer --version 1>/dev/null 2>&1) || (echo 'install livestreamer first (run pip/pip3 install livestreamer)'; exit)
if [ -n "$1" ]; then
id=$(echo "$1" | sed 's|^.*/||g')
while true; do
while true; do
(curl -s "https://www.showroom-live.com/room/is_live?room_id=$id" | grep "\"ok\":1") && break
echo "Not Alive, Sleeping $(date +'%F_%H-%M-%S')"
sleep 30
done
fname="${id}_$(date +'%F_%H-%M-%S').ts"
# jq -r to strip ""
# HQ
# url=$(curl -s "https://www.showroom-live.com/room/get_live_data?room_id=$id" | jq -r '.streaming_url_hls')
# url=$(curl -s "https://www.showroom-live.com/room/get_live_data?room_id=$id" | jq -r '.streaming_url_list[0].url')
# LQ
url=$(curl -s "https://www.showroom-live.com/room/get_live_data?room_id=$id" | jq -r '.streaming_url_list[1].url')
livestreamer --hls-segment-threads 3 --hls-segment-timeout 1.5 --http-timeout 1.5 -o "$fname" "hlsvariant://$url" best
# ffmpeg -nostdin -i "$url" \
# -vcodec copy -acodec copy -f mpegts "$fname"
if [ "$2" != "loop" ]; then
break
fi
done
else
echo "usage: $0 showroom_roomid (Note: roomid is not username)"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment