#!/bin/bash

nodeid=''
nodename=''
nodeip=`curl -s ip.sb`

if [ ! -d "nfstatus.txt" ]; then
touch "nfstatus.txt"
fi
nodestatus=`cat nfstatus.txt`

status=`curl -is "https://www.netflix.com/title/70143836"`

if [[ "$status" == *"HTTP/2 40"* ]]
then
	if [[ "$nodestatus" != 0 ]]
	then
		echo 0 > nfstatus.txt
		echo -e 'netflix解锁失效了' - `date +"%Y-%m-%d %H:%M:%S"`"\n"
	fi
	curl -s "http://hk1.sixu.space/nfstatus.php?nodeid=$nodeid&nodename=$nodename&nodeip=$nodeip&nodestatus=0&nodecountry=$nodecountry"
	exit
fi

if [[ "$status" == *"HTTP/2 200"* ]]
then
	status=us
else
    status=${status#*location: https://www.netflix.com/}
    status=${status%%/*}
    status=${status%%-*}
fi

if [ "$nodestatus" != 1 ]
then
	echo 1 > nfstatus.txt
	echo 'netflix解锁恢复了' - `date +"%Y-%m-%d %H:%M:%S"`
fi
nodecountry=$status
#echo "http://hk1.sixu.space/nfstatus.php?nodeid=$nodeid&nodename=$nodename&nodeip=$nodeip&nodestatus=1&nodecountry=$nodecountry"
curl -s "http://hk1.sixu.space/nfstatus.php?nodeid=$nodeid&nodename=$nodename&nodeip=$nodeip&nodestatus=1&nodecountry=$nodecountry"