#!/usr/bin/perl use strict; use warnings; use feature 'say'; use HTML::Parser (); use HTTP::Tiny (); scalar @ARGV or die 'Usage: rss NAMES'; foreach my $name (@ARGV) { my @links; my $youtube = 'https://www.youtube.com'; my $url = "$youtube/\@$name"; my sub start { my ($attr) = @_; if (exists $attr->{title} && $attr->{title} eq 'RSS' && exists $attr->{href}) { push @links, $attr->{href}; } } my $p = HTML::Parser->new(api_version => 3, handlers => { start => [\&start, 'attr'] }, report_tags => 'link'); $p->parse(HTTP::Tiny->new->get($url)->{content} or die "Failed to GET $url"); scalar @links or die "Failed to find any links"; # Uncomment this to label the URL (i.e., for newsboat's URL file) # say "# YouTube - $name"; say "$links[0]"; }