#!@perl@/bin/perl use utf8; use strict; use warnings; use Email::MIME; use Email::Date::Format qw(email_date); our $fromMail = "$ENV{'USER'}\@odin.asgard.yggdrasil"; our $fromName = "manual"; my $i = 0; my @tags = (); for (my $j = 0; $j < $#ARGV; $j++) { next unless ($ARGV[$j] eq "--"); @tags = @ARGV[0 .. $j - 1]; @ARGV = @ARGV[$j + 1 .. $#ARGV]; last; } # use Data::Dumper; # print Dumper(@tags, @ARGV); # exit 1; foreach my $url (@ARGV) { my $title; open(my $fh, '-|', "@youtubedl@/bin/youtube-dl --restrict-filenames --get-title --no-playlist -- '$url'") || die "Could not spawn youtube-dl"; $title = <$fh>; close($fh); die "youtube-dl could not extract title" unless (defined($title)); chomp($title); my $mail = Email::MIME->create( header_str => [ From => "$fromName <$fromMail>", To => 'gkleen@odin.asgard.yggdrasil', Subject => $title, 'X-RSS-URL' => $url, Date => email_date(time() + ($i++)) ], attributes => { content_type => 'text/html', encoding => '7bit', charset => 'US-ASCII' }, body => "$title\n" ); my @args = (); push @args, (('junk') x 5); push @args, @tags; open($fh, '|-', "rss_deliver", @args) || die "Could not spawn rss_deliver"; print $fh $mail->as_string; close($fh); }