$status) { $season_path = seasonPath($series, $season); $monitored = $data[ 'season_' . $season ]; $monitored_path = $season_path . '/' . $DONE_FILE; if ($monitored) { if (file_exists($monitored_path)) { unlink($monitored_path); } } else { if (!file_exists($monitored_path)) { touch($monitored_path); } } } # Force a cache update clearCache(); } # Add the specified season folder function addSeason($series, $season) { die_if_not_authenticated(); # 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 = seasonPath($series, $season); if (file_exists($season_path)) { die(htmlspecialchars($series). ': 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(htmlspecialchars($series) . ': Season not listed in TheTVDB: ' . htmlspecialchars($season) . "\n"); } # Create the directory @mkdir($season_path); # Force a cache update clearCache(); } # Remove the specified season folder, if possible (i.e. if empty) function delSeason($series, $season) { die_if_not_authenticated(); global $DONE_FILE; global $RECODE_FILE; # Ensure the series exists if (!seriesExists($series)) { die('Invalid series: ' . htmlspecialchars($series) . "\n"); } # Ensure the season exists if (!seasonExists($series, $season)) { die('Invalid season: ' . htmlspecialchars($season) . "\n"); } # Drop known files from the season folder $path = seasonPath($series, $season); @unlink($path . '/' . $RECODE_FILE); @unlink($path . '/' . $DONE_FILE); # Remove the directory (or fail silently) @rmdir($path); # Force a cache update clearCache(); } ?>