diff options
Diffstat (limited to 'odin/strm/manual_youtube')
| -rw-r--r-- | odin/strm/manual_youtube | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/odin/strm/manual_youtube b/odin/strm/manual_youtube new file mode 100644 index 00000000..943ae5d4 --- /dev/null +++ b/odin/strm/manual_youtube | |||
| @@ -0,0 +1,62 @@ | |||
| 1 | #!@perl@/bin/perl | ||
| 2 | |||
| 3 | use utf8; | ||
| 4 | use strict; | ||
| 5 | use warnings; | ||
| 6 | |||
| 7 | use Email::MIME; | ||
| 8 | |||
| 9 | use Email::Date::Format qw(email_date); | ||
| 10 | |||
| 11 | our $fromMail = "$ENV{'USER'}\@odin.asgard.yggdrasil"; | ||
| 12 | our $fromName = "manual"; | ||
| 13 | |||
| 14 | my $i = 0; | ||
| 15 | |||
| 16 | my @tags = (); | ||
| 17 | for (my $j = 0; $j < $#ARGV; $j++) | ||
| 18 | { | ||
| 19 | next unless ($ARGV[$j] eq "--"); | ||
| 20 | |||
| 21 | @tags = @ARGV[0 .. $j - 1]; | ||
| 22 | @ARGV = @ARGV[$j + 1 .. $#ARGV]; | ||
| 23 | last; | ||
| 24 | } | ||
| 25 | |||
| 26 | # use Data::Dumper; | ||
| 27 | # print Dumper(@tags, @ARGV); | ||
| 28 | # exit 1; | ||
| 29 | |||
| 30 | foreach my $url (@ARGV) | ||
| 31 | { | ||
| 32 | my $title; | ||
| 33 | open(my $fh, '-|', "@youtubedl@/bin/youtube-dl --restrict-filenames --get-title --no-playlist -- '$url'") || die "Could not spawn youtube-dl"; | ||
| 34 | $title = <$fh>; | ||
| 35 | close($fh); | ||
| 36 | die "youtube-dl could not extract title" unless (defined($title)); | ||
| 37 | chomp($title); | ||
| 38 | |||
| 39 | my $mail = Email::MIME->create( | ||
| 40 | header_str => [ | ||
| 41 | From => "$fromName <$fromMail>", | ||
| 42 | To => 'gkleen@odin.asgard.yggdrasil', | ||
| 43 | Subject => $title, | ||
| 44 | 'X-RSS-URL' => $url, | ||
| 45 | Date => email_date(time() + ($i++)) | ||
| 46 | ], | ||
| 47 | attributes => { | ||
| 48 | content_type => 'text/html', | ||
| 49 | encoding => '7bit', | ||
| 50 | charset => 'US-ASCII' | ||
| 51 | }, | ||
| 52 | body => "<a href=\"$url\">$title</a>\n" | ||
| 53 | ); | ||
| 54 | |||
| 55 | my @args = (); | ||
| 56 | push @args, (('junk') x 5); | ||
| 57 | push @args, @tags; | ||
| 58 | |||
| 59 | open($fh, '|-', "rss_deliver", @args) || die "Could not spawn rss_deliver"; | ||
| 60 | print $fh $mail->as_string; | ||
| 61 | close($fh); | ||
| 62 | } | ||
