Răsfoiți Sursa

Merge branch 'master' of github.com:profplump/UberZach-Video

Zachary Kotlarek 10 ani în urmă
părinte
comite
0c6c9dd334
2 a modificat fișierele cu 23 adăugiri și 3 ștergeri
  1. 19 0
      findTorrent.pl
  2. 4 3
      mountMedia

+ 19 - 0
findTorrent.pl

@@ -4,6 +4,7 @@ use warnings;
 
 # Defaults
 my $DEBUG               = 0;
+my $SYSLOG              = 0;
 my $NO_QUALITY_CHECKS   = 0;
 my $MORE_NUMBER_FORMATS = 0;
 my $MIN_DAYS_BACK       = 0;
@@ -43,6 +44,7 @@ use URI::Encode qw(uri_encode);
 use HTML::Entities;
 use HTML::Strip;
 use JSON;
+use Sys::Syslog qw(:standard :macros);;
 use File::Temp;
 use File::Spec;
 use File::Basename;
@@ -99,6 +101,14 @@ if (defined($ENV{'MAX_DAYS_BACK'})) {
 if (defined($ENV{'NEXT_EPISODES'})) {
 	$NEXT_EPISODES = $ENV{'NEXT_EPISODES'};
 }
+if (defined($ENV{'SYSLOG'})) {
+	$SYSLOG = $ENV{'SYSLOG'};
+}
+
+# Open the log if enabled
+if ($SYSLOG) {
+	openlog(basename($0), '', LOG_DAEMON);
+}
 
 # Read the torrent excludes list
 my %EXCLUDES = ();
@@ -188,6 +198,9 @@ my %need          = ();
 	if ($DEBUG) {
 		print STDERR 'Checking directory: ' . $dir . "\n";
 	}
+	if ($SYSLOG) {
+		syslog(LOG_NOTICE, $show);
+	}
 }
 
 # Allow the show name to be overriden
@@ -1210,6 +1223,9 @@ foreach my $episode (keys(%tors)) {
 	if (defined($urls{$episode})) {
 		$urls{$episode} = resolveTrackers($urls{$episode});
 		print $urls{$episode} . "\n";
+		if ($SYSLOG) {
+			syslog(LOG_NOTICE, $show . ': ' . getHash($urls{$episode}));
+		}
 		if ($DEBUG) {
 			print STDERR 'Final URL: ' . $urls{$episode} . "\n";
 		}
@@ -1220,6 +1236,9 @@ foreach my $episode (keys(%tors)) {
 
 # Cleanup
 unlink($cookies);
+if ($SYSLOG) {
+	closelog();
+}
 exit(0);
 
 sub getHash($) {

+ 4 - 3
mountMedia

@@ -74,9 +74,10 @@ if [ $LOCAL_LINK -eq 0 ] && [ $FORCE -eq 0 ] && ~/bin/video/isMediaMounted; then
 fi
 
 # Check for connectivity and server live-ness
-if ! ~/bin/video/timeout -t "${TIMEOUT}" nc -z "${HOST}" 139 >/dev/null 2>&1; then
-	echo "`basename "${0}"`: Host not available: ${HOST}" 1>&2
-	OFFLINE=1
+if ! ~/bin/video/timeout -t "${TIMEOUT}" nc -z "${HOST}" 548 >/dev/null 2>&1 || \
+	! ~/bin/video/timeout -t "${TIMEOUT}" nc -z "${HOST}" 139 >/dev/null 2>&1; then
+		echo "`basename "${0}"`: Host not available: ${HOST}" 1>&2
+		OFFLINE=1
 fi
 
 # Drop local links if we're online