$status) { $season_path = seasonPath($series, $season); $monitored = $data[ 'season_' . $season ]; $monitored_path = $season_path . '/season_done'; if ($monitored) { if (file_exists($monitored_path)) { unlink($monitored_path); } } else { if (!file_exists($monitored_path)) { touch($monitored_path); } } $url = $data[ 'url_' . $season ]; $url_path = $season_path . '/url'; if ($url) { if (isMonitored($series, $season)) { file_put_contents($url_path, $url . "\n"); } } else { if ($seasons_last[ $season ] && isMonitored($series, $season)) { if (file_exists($url_path)) { unlink($url_path); } } } } } # 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 = seasonPath($series, $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); } # Remove the specified season folder, if possible (i.e. if empty) function delSeason($series, $season) { # 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"); } # Remove the directory (or fail silently) @rmdir(seasonPath($series, $season)); } ?>