/All/
|
index
catalog
recent
update
post
|
/math/
/tech/
/misc/
/free/
/meta/
/test/
|
Guide
dark
mod
Log
P32653
Shell wrapper for ** Deep Web Radio **
Sat 2023-03-11 01:53:55
link
reply
edb8f2b481ce43834e7d930cf91815c84a2a924bc86880d234b9c24035fc70e9.jpg
210 KiB 650x650
I found this site where I could listen to the radio over Tor so I wrote a shell wrapper so that can do it through the terminal.
http://lambdaplusjs35padjaiz4jw2fugdoeutse262phqr72uf634s2wdbqd.onion/misc/32521
I suck at bash, and have only written a few scripts before, if there's some sage around that can tell me how to improve it and cut down the lines of code I would appreciate it. Either way it works.
```
#!/bin/bash
# A script that streams various radio channels over Tor with mpv
# Source of music is ** Deep Web Radio **
#
http://anonyradixhkgh5myfrkarggfnmdzzhhcgoy2v66uf7sml27to5n2tid.onion/
# Global variables
hservice="
http://anonyradixhkgh5myfrkarggfnmdzzhhcgoy2v66uf7sml27to5n2tid.onion/
"
wrapped="torsocks mpv"
sfx=".m3u"
rstation1="AnonyJazz"
rstation2="AnonyRadio"
rstation3="BaroqueRadio"
rstation3="DarkRet"
rstation4="DeepBanjo"
rstation5="DeepSpaceOne"
rstation6="DroneZone"
rstation7="GrooveSalad"
rstation8="Lush"
rstation9="c0vertElectr0"
# Check Dependencies
if [[ $(command -v mpv | wc -l) -ne 1 ]] ; then
echo "Error: mpv must be installed to run this script."
exit 1
elif [[ $(command -v torsocks | wc -l) -ne 1 ]] ; then
echo "Error: torsocks must be installed to run this script."
exit 1
else
:
fi
usage()
{
cat <<-EndUsage
Usage: $(basename $0) [OPTIONS]
Options:
-h --help Display this help and exit
-l --list List available stations
-s --station Radio station to stream
EndUsage
exit 0
}
list()
{
cat <<-EndStations
Available Stations:
(1) Anony JaZZ
(2) Radio Cladenstin@
(3) BaroqueRadio
(4) DarkRet
(5) DeepBanjo
(6) DeepSpaceOne
(7) DroneZone
(8) GrooveSalad
(9) Lush
(10) c0vertElectr0
EndStations
exit 0
}
station()
{
chosen_station="$1"
case "$chosen_station" in
"1")
${wrapped} ${hservice}${rstation1}${sfx}
exit;;
"2")
${wrapped} ${hservice}${rstation2}${sfx}
exit;;
"3")
${wrapped} ${hservice}${rstation3}${sfx}
exit;;
"4")
${wrapped} ${hservice}${rstation4}${sfx}
exit;;
"5")
${wrapped} ${hservice}${rstation5}${sfx}
exit;;
"6")
${wrapped} ${hservice}${rstation6}${sfx}
exit;;
"7")
${wrapped} ${hservice}${rstation7}${sfx}
exit;;
"8")
${wrapped} ${hservice}${rstation8}${sfx}
exit;;
"9")
${wrapped} ${hservice}${rstation9}${sfx}
exit;;
"10")
${wrapped} ${hservice}${rstatio410}${sfx}
exit;;
esac
}
while getopts ":hls" args; do
case $args in
h|help) # Display help and exit
usage
exit;;
l|list) # List available stations
list
exit;;
s|station) # Radio station to stream
station $2
;;
?) # Invalid argument
usage
exit;;
esac
done
```
Referenced by:
P32668
P34316
P34708
P32654
Sat 2023-03-11 01:55:09
link
reply
[spoiler:
lambdaplusjs needs code formatting.
]
Referenced by:
P32658
P32667
P32658
Sat 2023-03-11 01:57:25
link
reply
aaff24a65b4c1128caabe17fe6211c968448dec32901e8d94c88d167361cdaff.png
28.3 KiB 619x582
P32654
i agree
[bold:
see
]
>>
P2203
P32671
12of7
Sat 2023-03-11 02:39:53
link
reply
7ec1ec0feb8ad1a9d5394a9a40e77d9619412f471ac60bf51980e60eb9f1604f.mp4
384 KiB 854x480x12.48s
x
P32667
No!!!
This is a Snopes proxy though if your that much of a tranny
http://sd.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/
P32674
Sat 2023-03-11 02:44:15
link
reply
545affbebb7d2dd8a0f4b77a1929c62c498eef18f2d5fb606c2b8f1f244b3f83.jpg
365 KiB 1296x958
P32668
You inspired me to try it out with the Baroque radio only to find out that it plays a different channel. I have no idea why, and there's also a 10th channel despite the site not having 10 of them. That's your problem to fix if you care enough about it, I had my fun.
P32675
Sat 2023-03-11 02:52:07
link
reply
>there's also a 10th channel despite the site not having 10 of them.
That was a lie, it works now, Baroque too.
https://ghostbin.me/640bec7d80b0e
bash dradio.sh -s 3 for some nice classical.
Referenced by:
P32682
P32682
Honeypots really are Honeypots
Sat 2023-03-11 03:18:20
link
reply
947c9dbb4609e691a82c9514ec8e0729119ffaa9ca2de55f32e48533ddefa41e.png
33.9 KiB 935x450
c706b69218264cf39b71193134c13ea210cb8bd0324e8a4d04244ea92f392000.png
112 KiB 361x347
P32675
**Deep Web Radio** seems pretty cool minus this cringe...
[spoiler:
https://www.latimes.com/world-nation/story/2021-03-30/lawyer-fbi-enlisted-proud-boys-leader-to-inform-on-antifa
]
12of7
P32726
Sat 2023-03-11 09:49:04
link
reply
>based picture
very neat
>random link with possible search browser
alrighty then, hope no CIA shit
>dig a bit and see that the site is a hosting site
neat thing, idk if it's CIA or not, idc eighterway, I don't use those lmfao (onion ones as no usage for me rn)
P32742
POSIX squad
Sat 2023-03-11 17:31:22
link
reply
d190d83937274ca936769be80b52295fc9a5f97242a19612054623331d85b0ff.jpg
244 KiB 1200x1748
ebfd82cbb1374db219d429538ccb135063bcb6afda95601a1e4dc7d00b9e886b.txt
1.59 KiB
c7ebf3e779576dedafa804cf999fe5f7ba19f6f0bd4787ba00a4aa05dfe632c3.txt
1.38 KiB
Wew.
>Not POSIX
>bash
>not set -eu
>[[ ]] instead of [ ]
>Not using command exit status and instead parsing output
>Using echo braindamage
>case in station repeats commands over and over instead of just setting a variable and having a single command at the end
>getotps doesn't support long arguments (there's getopts_long script around to support those)
>s arg requires a value so optstring should have "s:"
>exit commands all over the place
>Not quoting variables
Referenced by:
P32769
P34261
P34316
P32769
Sat 2023-03-11 20:02:31
link
reply
e9a7b95600ada128c774f4ee0b0651869bdb3e805cd947981cfba086b1e9466e.jpg
70.5 KiB 474x580
P32742
Those are way better, thanks for improving it. I just looked things up online as I was writing it. Want to point me anywhere I can learn?
I was referencing this:
https://devmanual.gentoo.org/tools-reference/bash/index.html
https://devhints.io/bash
Referenced by:
P32771
P32771
Sat 2023-03-11 20:42:54
link
reply
2e97b4a7d67f33345f9bbb750411b1734a49a7f81e29cfc9d6c74885d925a0e1.jpg
237 KiB 1200x1748
P32769
Those look fine for getting started, but those can also make you fall into the bashism trap
[spoiler:
like I once did
]
.
I just learned writing scripts, doing a quick search:
https://www.grymoire.com/Unix/Sh.html
https://steinbaugh.com/posts/posix.html
https://drewdevault.com/2018/02/05/Introduction-to-POSIX-shell.html
More autism:
https://www.etalabs.net/sh_tricks.html
https://dwheeler.com/essays/fixing-unix-linux-filenames.html
You should always declare shebang as #!/bin/sh and you can use shellcheck to check if syntax is POSIX compliant or other mistakes. It won't warn you if you use non-POSIX arguments for some utility, though.
set -u is also highly advisable.
Referenced by:
P34261
P34316
P32804
Sun 2023-03-12 01:04:41
link
reply
> Want to point me anywhere I can learn?
https://www.gnu.org/software/bash/manual/
P34261
Sat 2023-03-18 08:19:16
link
reply
fd4083c3a25d2f31e913576616de257b5f535eb0cabce36fc221541a34fab580.txt
890 B
1d775d589cd52c708eacf1db9ffcc1b01ca755145e1648c70572323db758dcff.jpg
207 KiB 880x1021
P32742
P32771
I wrote a new script and tried to keep it POSIX compliant, shellcheck gives no warnings. Any pointers or improvements to this one?
I have more ideas but I spend most of my time learning other languages right now.
[spoiler:
And I'm a noob with them as well.
]
[spoiler:
Also I'm not the OP of the nigger thread, in case you wonder.
]
Referenced by:
P34264
P34366
P34262
Sat 2023-03-18 08:28:38
link
reply
That's short enough that I can't *possibly* have made any sacrilegious mistakes, but I intend to make it work with mogrify and exiftool as well later.
Referenced by:
P34269
P34366
P34316
Sat 2023-03-18 12:53:58
link
reply
699cc06eab9110099775f0a3027321ae8ddb4579d2aafba6008a2b27ba9c2769.gif
354 KiB 640x360x2.04s
P32653
P32742
P32771
Just use Python instead of writing shell spaghetti.
Shell script is literally useless at this point, trust me I've spent months writing shell scripts with hundred of lines trying to keep it POSIX compatible and all of that, it was a huge waste of my time. Just use Python for small scripts.
Referenced by:
P34318
P34318
Sat 2023-03-18 13:36:39
link
reply
2407aa6476444736dfd6d66b586a191e676b7095b8b7025a85dc0f9719c901fe.png
427 KiB 1000x1149
P34316
s/Python/Perl/g
Referenced by:
P34324
P34324
Sat 2023-03-18 14:05:38
link
reply
b5f236c19531b469f42d1dc808e3759975090e41011ad5c3b9211278003aa9b2.jpg
70.5 KiB 573x892
P34318
string.gsub("s/Python/Perl/g", "Python/Perl", "Perl/Lua")
P34366
POSIX compliant walltext
Sat 2023-03-18 17:24:26
link
reply
81195ae1508d38f951a234881e5f2f0d746d61f9a1302bc790c6ff5cd21da72c.jpg
388 KiB 1200x1683
P34261
P34262
>any sacrilegious mistakes
Depends on what flavour of autism you're willing to take.
[spoiler:
OCD mode:
* Be consistent using "$var" or ${var}"
]
Easy mode:
* You are looping twice over all files instead of just once.
* Glob should be *.png *.jpg *.jpeg *.gif *.mp4 which makes the case useless and could be removed and instead simply have a mv "${i}" "${filename}.${extension}"
Gotcha mode (
https://dwheeler.com/essays/filenames-in-shell.html):
* Glob should actually be ./*.png ./*.jpg ./*.jpeg ./*.gif ./*.mp4. If files start with -, they'll make mv break.
* If you want to include hidden files it gets even more annoying. It would have to be ./*.png ./.*.png ./*.jpg ./.*.jpg ./*.jpeg ./.*.jpeg ./*.gif ./.*.gif ./*.mp4 ./.*.mp4
* If one glob fails to match, you'll get a literal "./*.jpg", "./.*.jpg" and so on, so you'll need to include a if [ -e "${i}" ] inside your for loops.
* Or just use find command + exec to find files like the link above describes.
POSIX is not your friend mode:
* shuf is actually not part of POSIX (
https://pubs.opengroup.org/onlinepubs/9699919799/idx/utilities.html
), so you should add an extra check for shuf at the start of the script like you do with mat2
* date +%s is not POSIX (
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html
). Check "Seconds since the epoch" on
https://www.etalabs.net/sh_tricks.html
for an alternative.
Please make it stop mode:
* If you instead want to get rid of shuf,
[spoiler:
like you should
]
, to generate integers between a given range, be prepared to suffer because there's not a good way to do it.
I've talked about this before:
P8197
,
P8345
,
P8361
. POSIX only guarantees /dev/null, /dev/console and /tmp to exist, so you can't use /dev/random or any other file as a source of randomness.
What I ended up doing is using awk and taking advantage of how wildly sin(1/x) oscillates near x=0:
awk 'BEGIN{cmd="echo $$"; cmd | getline seed; close(cmd); t=srand(); srand(int(2147483648*sin(1/((t+int(seed))/9223372036854775808)))); printf "%d\n",(rand()*65536)}'
Also, I hope you are aware since you have set -e, if any command fails at any moment, script will immediatelly exit, so you may or may not want to do something like:
mat2 --inplace "$i" 2> /dev/null >/dev/null || mv "${i}" ../failed
In this case it might also make sense to loop twice.
>
[spoiler:
Also I'm not the OP of the nigger thread, in case you wonder.
]
What thread?
Referenced by:
P34396
P34408
P34414
P34368
GNU+sudoku
Sat 2023-03-18 17:32:17
link
reply
I forgot to include source for the /dev/null, /dev/console and /tmp thing.
https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap10.html
I also forgot about /dev/tty.
P34396
Sat 2023-03-18 19:32:45
link
reply
P34366
(dubs of autism)
wtf is even the point of following posix cuckoldry to the letter if everybody here uses gnu anyway
bsdfags are used to having to adapt everything they try to run
and temple os is a meme
Referenced by:
P34408
P34408
Sat 2023-03-18 19:49:10
link
reply
7b83a8cda4f0313cb3381637ced068166f812d37633e93178bed8cad37bb8efc.jpg
225 KiB 1523x1200
P34366
A minor but relevant correction. Instead of
awk 'BEGIN{cmd="echo $$"; cmd | getline seed; close(cmd); t=srand(); srand(int(2147483648*sin(1/((t+int(seed))/9223372036854775808)))); printf "%d\n",(rand()*65536)}'
it should be
awk 'BEGIN{cmd="echo $$"; cmd | getline seed; close(cmd); srand(); t=srand(); srand(int(2147483648*sin(1/((t+int(seed))/9223372036854775808)))); printf "%d\n",(rand()*65536)}'
with the double srand call.
POSIX doesn't define what first srand will return.
awk 'BEGIN{ print srand() }' returns 1 with busybox and current timestamp with mawk.
As a bonus, I also forgot to mention that
awk 'BEGIN{ srand(); print srand() }'
is an alternate way to get the same result as date +%s
P34396
Personally I once had to resort to busybox because reasons and nothing worked. After that I began my descent into POSIX cuckdom.
Referenced by:
P34414
P34534
P34414
Sat 2023-03-18 20:03:54
link
reply
43e5cebbaaaffb0d5c35ab2db1e21da9f084389446dc581d9e382ad02e2cc3b8.webm
1.09 MiB 1280x720x13.82s
x
P34366
P34408
Didn't read.
Install Python.
WebM unrelated.
Referenced by:
P34418
P34536
P34418
Sat 2023-03-18 20:06:18
link
reply
P34414
Now, that's an animu I haven't seen in a while.
>soundless
Shamefur dispray.
Referenced by:
P34536
P34541
P34534
Sun 2023-03-19 01:26:47
link
reply
P34408
>awk 'BEGIN{ srand(); print srand() }'
>is an alternate way to get the same result as date +%s
holy shit
why dont they define the less autistic way to do that
Referenced by:
P34705
P34536
Sun 2023-03-19 01:27:50
link
reply
P34414
or
P34418
sauce?
Referenced by:
P34539
P34573
P34705
P34707
P34705
Sun 2023-03-19 17:14:45
link
reply
3726dce8c143b328685148e51d3e19797885af5c89419710a353704911a4bb6f.jpg
242 KiB 921x1800
P34534
¯\_ (ツ)_/¯
P34536
Flip Flappers.
P34708
Sun 2023-03-19 17:21:35
link
reply
39aeccb3495c76afd3c9ee1733a8095e4fd529fcea0948e5d0d3055f895c2878.jpg
103 KiB 900x675
P32653
tin foil
Mod Controls:
x
Reason: