• We did not send an email asking for donations - please read this post.

Bash script to determine if a streaming is live or off

iincognito15

New Member
Joined
Sep 25, 2022
Messages
2
Reaction score
0
Credits
22
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 $?
 


wizardfromoz

Administrator
Staff member
Gold Supporter
Joined
Apr 30, 2017
Messages
7,790
Reaction score
6,615
Credits
28,677
Moving this to Command Line, where scripting enquiries belong.

Chris Turner
wizardfromoz
 

JasKinasis

Well-Known Member
Joined
Apr 25, 2017
Messages
1,570
Reaction score
2,232
Credits
11,611
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!
 
OP
I

iincognito15

New Member
Joined
Sep 25, 2022
Messages
2
Reaction score
0
Credits
22
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!
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Linux.org Hosting Donations
Consider making a donation

Members online


Top