-
Notifications
You must be signed in to change notification settings - Fork 4
/
tlc.pl
executable file
·44 lines (37 loc) · 1.23 KB
/
tlc.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/env perl
#------------------------------------------------------------------------------
# Author E-Mail - [email protected]
# Author GitHub - https://github.com/terminalforlife
#------------------------------------------------------------------------------
# Simple PERL script which endeavours to display the subscriber count for the
# YouTube channel 'The Linux Cast', by parsing the channel's 'about' page. This
# is suitable for use in a bar, such as in a tiling window manager.
#
# Written in an Ubuntu-based distribution with packages:
#
# libwww-perl (>= 6.31-1)
# perl (>= 5.22.1-9)
#------------------------------------------------------------------------------
require LWP::UserAgent;
use v5.22.1;
use strict;
use warnings;
use LWP::UserAgent;
my $UA = LWP::UserAgent->new(
'agent' => 'Mozilla/5.0',
'protocols_allowed' => ['http', 'https'],
'max_redirect' => 3,
'timeout' => 10
);
my $Response = $UA->get('https://www.youtube.com/c/TheLinuxCast/about');
$Response or exit(1);
# As long as you have at least 1 subscriber, the REGEX should work.
foreach (split("\n", $Response->decoded_content())) {
if (/"label":"(.*) subscribers"}}/) {
print("$1\n");
last()
}
}
<<<<<<< HEAD
=======
>>>>>>> master