Browse Source

Initial commit

spesk1 2 years ago
parent
commit
685b6cdba1
2 changed files with 69 additions and 0 deletions
  1. 68 0
      pl_gen.pl
  2. 1 0
      start_vlc.sh

+ 68 - 0
pl_gen.pl

@@ -0,0 +1,68 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+my $ROOT="/mnt/usb/spesktv";
+my $BUMPER_DIR="$ROOT/bumpers";
+my $VID_DIR="$ROOT/videos";
+my $PFILE="$ROOT/playlist.vlc";
+
+my $PLENGTH=20;
+
+my @video_paths = split("\n", `ls $VID_DIR/*.mp4`);
+my @bumper_paths = split("\n", `ls $BUMPER_DIR/*.mp4`);
+
+sub wr($$) {
+	my $path = shift;
+	my $line = shift;
+	open(my $fh, '>', $path) or die "Couldn't open $path";
+	print $fh $line;
+	close($fh);
+}
+
+sub apd($$) {
+	my $path = shift;
+	my $line = shift;
+	open(my $fh, '>>', $path) or die "Couldn't open $path";
+	print $fh $line;
+	close($fh);
+}
+
+sub rnd_vid_path {
+	my $path =$video_paths[ rand @video_paths ];
+	$path = $path . "\n";
+	return $path;
+}
+
+sub rnd_bmp_path() {
+	my $path = $bumper_paths[ rand @bumper_paths ];
+	$path = $path . "\n";
+	return $path;
+}
+
+
+sub gen_pl() {
+
+	wr($PFILE,"");
+	apd($PFILE,rnd_bmp_path());
+	foreach my $i ( 1..$PLENGTH ) {
+		if ( $i % 2 == 0 ) {
+			apd($PFILE,rnd_bmp_path());
+		}
+		apd($PFILE,rnd_vid_path());
+	}
+	apd($PFILE,$PFILE . "\n");
+}
+
+while () {
+
+	my $date = `date`;
+	chomp $date;
+	print("$date\n");
+	print("Generating playlist...\n");
+	gen_pl();
+	print("Sleeping for 1hr minutes...\n");
+	sleep 3600;
+
+}

+ 1 - 0
start_vlc.sh

@@ -0,0 +1 @@
+vlc -I dummy --control dbus playlist.vlc --loop --sout-keep --sout '#standard{access=http,mux=ts,dst=10.0.0.253:21225}'