diff options
Diffstat (limited to 'odin')
| -rw-r--r-- | odin/strm.nix | 43 | ||||
| -rw-r--r--[-rwxr-xr-x] | odin/strm/cleanup_youtube | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | odin/strm/download_youtube | 0 | ||||
| -rw-r--r-- | odin/strm/manual_youtube | 62 | ||||
| -rw-r--r--[-rwxr-xr-x] | odin/strm/rss_staggered | 0 | ||||
| -rw-r--r--[-rwxr-xr-x] | odin/strm/send_kitty | 0 |
6 files changed, 103 insertions, 2 deletions
diff --git a/odin/strm.nix b/odin/strm.nix index 71d93011..094da07c 100644 --- a/odin/strm.nix +++ b/odin/strm.nix | |||
| @@ -1,6 +1,43 @@ | |||
| 1 | { stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email }: | 1 | { stdenv, zsh, ffmpeg-full, youtube-dl, pv, notmuch, rss2email, buildPerlPackage, perlPackages }: |
| 2 | 2 | ||
| 3 | stdenv.mkDerivation { | 3 | let |
| 4 | manual-youtube = buildPerlPackage { | ||
| 5 | name = "manual_youtube"; | ||
| 6 | |||
| 7 | src = ./strm/manual_youtube; | ||
| 8 | |||
| 9 | outputs = [ "out" ]; | ||
| 10 | phases = [ "unpackPhase" "configurePhase" "buildPhase" "installPhase" "fixupPhase" ]; | ||
| 11 | |||
| 12 | unpackPhase = '' | ||
| 13 | cp $src manual_youtube | ||
| 14 | |||
| 15 | cat >Makefile.PL <<EOF | ||
| 16 | #!/usr/bin/env perl | ||
| 17 | |||
| 18 | EOF | ||
| 19 | ''; | ||
| 20 | |||
| 21 | configurePhase = '' | ||
| 22 | preConfigure | ||
| 23 | ''; | ||
| 24 | |||
| 25 | youtubedl = youtube-dl; | ||
| 26 | |||
| 27 | buildPhase = '' | ||
| 28 | substituteAllInPlace manual_youtube | ||
| 29 | ''; | ||
| 30 | |||
| 31 | installPhase = '' | ||
| 32 | mkdir -p $out/bin | ||
| 33 | |||
| 34 | install -m 755 -t $out/bin \ | ||
| 35 | manual_youtube | ||
| 36 | ''; | ||
| 37 | |||
| 38 | propagatedBuildInputs = with perlPackages; [ EmailMIME EmailDateFormat ]; | ||
| 39 | }; | ||
| 40 | in stdenv.mkDerivation { | ||
| 4 | name = "strm"; | 41 | name = "strm"; |
| 5 | src = ./strm; | 42 | src = ./strm; |
| 6 | 43 | ||
| @@ -29,5 +66,7 @@ stdenv.mkDerivation { | |||
| 29 | cache_media \ | 66 | cache_media \ |
| 30 | send_kitty \ | 67 | send_kitty \ |
| 31 | rss_staggered | 68 | rss_staggered |
| 69 | |||
| 70 | ln -s ${manual-youtube}/bin/manual_youtube $out/bin | ||
| 32 | ''; | 71 | ''; |
| 33 | } | 72 | } |
diff --git a/odin/strm/cleanup_youtube b/odin/strm/cleanup_youtube index 2d91fe1f..2d91fe1f 100755..100644 --- a/odin/strm/cleanup_youtube +++ b/odin/strm/cleanup_youtube | |||
diff --git a/odin/strm/download_youtube b/odin/strm/download_youtube index 77172c87..77172c87 100755..100644 --- a/odin/strm/download_youtube +++ b/odin/strm/download_youtube | |||
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 | } | ||
diff --git a/odin/strm/rss_staggered b/odin/strm/rss_staggered index 54bbd1a3..54bbd1a3 100755..100644 --- a/odin/strm/rss_staggered +++ b/odin/strm/rss_staggered | |||
diff --git a/odin/strm/send_kitty b/odin/strm/send_kitty index a294d84c..a294d84c 100755..100644 --- a/odin/strm/send_kitty +++ b/odin/strm/send_kitty | |||
