Explorar o código

Integrate TVDB checks with season folder creation

Zachary Kotlarek %!s(int64=13) %!d(string=hai) anos
pai
achega
130ecabe21
Modificáronse 3 ficheiros con 17 adicións e 11 borrados
  1. 3 6
      web/includes/display.php
  2. 14 1
      web/includes/season.php
  3. 0 4
      web/includes/webloc.php

+ 3 - 6
web/includes/display.php

@@ -12,10 +12,8 @@ function printSeries($series) {
 		die('Unknown series: ' . $series_html);
 	}
 
-	# Check the flags
+	# Grab the flag and season data
 	$flags = readFlags($series);
-
-	# Check the seasons
 	$seasons = findSeasons($series);
 
 	# Header
@@ -24,10 +22,9 @@ function printSeries($series) {
 	echo '<input type="hidden" name="series" value="' . $series_html . '"/>';
 
 	# TVDB URL
+	$url_html = htmlspecialchars(TVDBURL($flags['tvdb-id'], $flags['tvdb-lid']));
 	echo '<h2>TVDB</h2>';
-	echo '<p><a target="_blank" href="' . 
-		htmlspecialchars($flags['url']) .
-		'">' . htmlspecialchars($flags['url']) . '</a></p>';
+	echo '<p><a target="_blank" href="' . $url_html . '">' . $url_html . '</a></p>';
 
 	# Series flags
 	echo '<h2>Series Parameters</h2>';

+ 14 - 1
web/includes/season.php

@@ -121,17 +121,30 @@ function saveSeasons($series, $data, $series_last, $seasons_last) {
 # Add the specified season folder
 function addSeason($series, $season) {
 
+	# Cheap validation
+	$season = intval($season);
+
 	# Ensure the series exists
 	if (!seriesExists($series)) {
 		die('Invalid series: ' . htmlspecialchars($series) . "\n");
 	}
 
 	# Ensure the season does not exist
-	$season_path = seriesPath($series) . '/Season ' . intval($season);
+	$season_path = seriesPath($series) . '/Season ' . $season;
 	if (file_exists($season_path)) {
 		die('Invalid season: ' . htmlspecialchars($season) . "\n");
 	}
 
+	# Ensure the season number is listed on TVDB
+	$flags = readFlags($series);
+	if (!$flags['tvdb-id']) {
+		die('No TVDB ID for series: ' . htmlspecialchars($series) . "\n");
+	}
+	$seasons = getTVDBSeasons($flags['tvdb-id'], $flags['tvdb-lid']);
+	if (!$seasons[ $season ]) {
+		die('Season not listed in TheTVDB: ' . htmlspecialchars($season) . "\n");
+	}
+
 	# Create the directory
 	mkdir($season_path);
 }

+ 0 - 4
web/includes/webloc.php

@@ -55,7 +55,6 @@ function readWebloc($file) {
 	$retval = array(
 		'tvdb-id'  => false,
 		'tvdb-lid' => false,
-		'url'      => false,
 	);
 
 	# Read and parse the file
@@ -68,9 +67,6 @@ function readWebloc($file) {
 		$retval['tvdb-lid'] = $matches[1];
 	}
 
-	# Grab the URL, if available
-	$retval['url'] = TVDBURL($retval['tvdb-id'], $retval['tvdb-lid']);
-
 	return $retval;
 }