Bash script to determine if a streaming is live or off

iincognito15

New Member
Joined
Sep 25, 2022
Messages
8
Reaction score
1
Credits
104
I found this bash script in the ask ubuntu forum and it works, but I would like to know if it can be used or improved to know if a tiktok stream is live or off, using the bash script via terminal (./test.url.sh /url.txt) in the .txt would be the tiktok addresses for example:
and that in the terminal tell me if it is live or off, is it possible?

#!/bin/bash

if [ $# -eq 0 ]
then
fin=-
else
fin=$1
fi

urlarr=( $(cat $fin | strings | grep '://' | grep -i "\.com\|\.net\|\.edu\|\.org\|[0-9].*\.[0-9].*\.[0-9].*\.[0-9].*" | tr '\n' ' ' ) )

for i in ${urlarr[@]}
do
if wget -q --tries=1 --no-cache --spider -O /dev/null --ignore-length -T 1 "$i"
then
echo $i is good.
else
echo $i is bad.
fi
done

exit $?
 


Moving this to Command Line, where scripting enquiries belong.

Chris Turner
wizardfromoz
 
I’m usually the scripting guy. But I know nothing about TikTok.
As far as I can see from the script in your post, it uses wget to try to retrieve the webpage, or file at the specified address.
So if the URL returns a page and not an error, like a 404 - it considers the site good, or up.

But if the site has good error handling, it could potentially return a page that displays an error message.

With regards to TikTok, I imagine that any valid TikTok URL will return a valid page.
But I don’t think you’ll be able to tell whether that user is actually live or not from that.

From a quick bit of DuckDuckGo-fu, I can see that TikTok (as with many other social media sites) does have a web-api that can be used by programmers.

However, I know nothing about their API.
It looks like you need to have a TikTok account with a certain number of videos posted AND you need to apply for an api key, then you can develop your own application to perform whatever functionality is exposed by their api.

So potentially, you MIGHT be able to apply for an api key and then create an application that will allow you to retrieve a list of accounts you follow and then list any that are live….. Emphasis there is on MIGHT - because I have no idea exactly what functionality is exposed in the TikTok api!
 
I’m usually the scripting guy. But I know nothing about TikTok.
As far as I can see from the script in your post, it uses wget to try to retrieve the webpage, or file at the specified address.
So if the URL returns a page and not an error, like a 404 - it considers the site good, or up.

But if the site has good error handling, it could potentially return a page that displays an error message.

With regards to TikTok, I imagine that any valid TikTok URL will return a valid page.
But I don’t think you’ll be able to tell whether that user is actually live or not from that.

From a quick bit of DuckDuckGo-fu, I can see that TikTok (as with many other social media sites) does have a web-api that can be used by programmers.

However, I know nothing about their API.
It looks like you need to have a TikTok account with a certain number of videos posted AND you need to apply for an api key, then you can develop your own application to perform whatever functionality is exposed by their api.

So potentially, you MIGHT be able to apply for an api key and then create an application that will allow you to retrieve a list of accounts you follow and then list any that are live….. Emphasis there is on MIGHT - because I have no idea exactly what functionality is exposed in the TikTok api!
Ok, thanks for your answer!
 
I’m usually the scripting guy. But I know nothing about TikTok.
As far as I can see from the script in your post, it uses wget to try to retrieve the webpage, or file at the specified address.
So if the URL returns a page and not an error, like a 404 - it considers the site good, or up.

But if the site has good error handling, it could potentially return a page that displays an error message.

With regards to TikTok, I imagine that any valid TikTok URL will return a valid page.
But I don’t think you’ll be able to tell whether that user is actually live or not from that.

From a quick bit of DuckDuckGo-fu, I can see that TikTok (as with many other social media sites) does have a web-api that can be used by programmers.

However, I know nothing about their API.
It looks like you need to have a TikTok account with a certain number of videos posted AND you need to apply for an api key, then you can develop your own application to perform whatever functionality is exposed by their api.

So potentially, you MIGHT be able to apply for an api key and then create an application that will allow you to retrieve a list of accounts you follow and then list any that are live….. Emphasis there is on MIGHT - because I have no idea exactly what functionality is exposed in the TikTok api!
Hello! As you know I do NOT know anything about programming, and I got the code or bash script in Ubuntu to know if a page is online or not, I wanted to use it to know if a tiktok user is online or not from a list of users in a . TXT file, I have realized (within my naivety) that it may not be necessary to obtain an API, because when the User is in a LIVE streaming it appears in "LIVE" in the profile photo, and when "inspecting" the code changes, it is possible to do something with this in the script to make it work?

LIVE User: Notice "userSpaceOnUse"

<div class="tiktok-156wlhr-DivContainer e1vl87hj1" data-e2e="user-avatar" style="width: 116px; height: 116px;"><svg width="112" height="112" viewBox="0 0 112 112" fill="none" xmlns="http://www.w3.org/2000/svg" class="tiktok-14q8znz-SvgRoundCircle e1vl87hj0"><circle cx="56" cy="56" r="55.25" stroke="url(#paint0_linear)" stroke-width="1.5"></circle><defs><linearGradient id="paint0_linear" x1="-48.977133333333335" y1="56" x2="63.022866666666665" y2="153.95450000000002" gradientUnits="userSpaceOnUse"><stop stop-color="#FF1764"></stop><stop offset="1" stop-color="#ED3495"></stop></linearGradient></defs></svg><span shape="circle" data-e2e="" class="e1vl87hj2 tiktok-runlml-SpanAvatarContainer-StyledAvatar e1e9er4e0" style="width: 110px; height: 110px;"><img loading="lazy" alt="" src="https://p16-sign-va.tiktokcdn.com/t...&amp;x-signature=37MlnZlAml3BcpM4P9dECizzuxc=" class="tiktok-1zpj2q-ImgAvatar e1e9er4e1"></span><span class="tiktok-1k4z0xn-SpanLiveBadge e1vl87hj3">LIVE</span></div>


Offline User: Not Streaming, Show This: --->

<img loading="lazy" alt="" src="https://p16-sign-va.tiktokcdn.com/t...&amp;x-signature=A1o3NGAhmxCbuL9sSGrWDr2vBBA=" class="tiktok-1zpj2q-ImgAvatar e1e9er4e1">

Sorry if i Bother you or anyone who read this, I'm so Naive in Programming, I appreciate your answer, Thank You!
 
I'm a little concerned that you've included the 'signature' but I am not 100% sure if I should be.

Is that the access number you use for connecting to the TikTok API? If so, that's private information and you really shouldn't share it in a public forum. A malicious user could use your API access to do things that violate their TOS - or, worse, do malicious things that violate the law.

If that's nothing that's private, it's all good. But, I have no clue as I know nothing about TikTok nor anything about their API.
 
I'm a little concerned that you've included the 'signature' but I am not 100% sure if I should be.

Is that the access number you use for connecting to the TikTok API? If so, that's private information and you really shouldn't share it in a public forum. A malicious user could use your API access to do things that violate their TOS - or, worse, do malicious things that violate the law.

If that's nothing that's private, it's all good. But, I have no clue as I know nothing about TikTok nor anything about their API.
Don't Worry, it's not the API.
 

Members online


Top