Compare commits

3 Commits

2 changed files with 38 additions and 38 deletions

View File

@@ -145,7 +145,7 @@ class DownloadDispatcher_Source_Plugin_TV extends DownloadDispatcher_Source_Plug
protected function normalise($name) {
$normalised_name = $name;
if (preg_match('/(?:\[ www.[a-zA-Z0-9.]+ \] - )?(.*?)([\s.]+us)?([\s\.](19|20)\d{2})?[\s\.](\[?\s*\d+x\d+\s*\]?|s(?:eason ?)?\d+[.-_ ]?e(?:pisode ?)?\d+|\d{3,4}).*/i', $normalised_name, $matches)) {
if (preg_match('/(?:\[ www.[a-zA-Z0-9.]+ \] - )?(.*?)(?<!the)([\s.]+us)?([\s\.](19|20)\d{2})?[\s\.](\[?\s*\d+x\d+\s*\]?|s(?:eason ?)?\d+[.-_ ]?e(?:pisode ?)?\d+|\d{3,4}).*/i', $normalised_name, $matches)) {
$normalised_name = $matches[1];
}
@@ -186,7 +186,7 @@ class DownloadDispatcher_Source_Plugin_TV extends DownloadDispatcher_Source_Plug
return null;
};
if (preg_match('/(?:(?:[\s\.](?:19|20)\d{2})?[\s\.])?(?:\d+(\d{2})(?!\d|[\s\.](?:\d+x\d+|s\d[._-]?+ep?\d+))|\[?\s*\d+x(\d+)\s*\]?|s(?:eason ?)?\d+e(?:pisode ?)?(\d+))/i', $name, $matches)) {
if (preg_match('/(?:^the.\d+)?(?:(?:[\s\.](?:19|20)\d{2})?[\s\.])?(?:\d+(\d{2})(?!\d|[\s\.](?:\d+x\d+|s\d[._-]?+ep?\d+))|\[?\s*\d+x(\d+)\s*\]?|s(?:eason ?)?\d+e(?:pisode ?)?(\d+))/i', $name, $matches)) {
return $set_episode($matches);
} elseif (preg_match('/^(\d+)/i', $name, $matches)) {
return $set_episode($matches);
@@ -334,41 +334,41 @@ EOSH;
}
protected function forgetDownload($series, $season, $episode) {
$base_url = $this->config->get('sources.TV.flexget-url');
$username = $this->config->get('sources.TV.flexget-username');
$password = $this->config->get('sources.TV.flexget-password');
// Pad series and episode numbers with leading zeroes for flexget
$season = str_pad($season, 2, '0', STR_PAD_LEFT);
$episode = str_pad($episode, 2, '0', STR_PAD_LEFT);
$url = "{$base_url}execute/";
$data = array(
'options' => "--series-forget '{$series}' 's{$season}e{$episode}'",
'submit' => 'Start Execution',
);
DownloadDispatcher_LogEntry::debug($this->log, "Sending flexget series-forget command to {$url} with options '{$data['options']}'.");
$request = new HttpRequest($url, HTTP_METH_POST, array(
'httpauth' => "{$username}:{$password}",
'httpauthtype' => HTTP_AUTH_BASIC,
));
$request->setPostFields($data);
$response = $request->send();
DownloadDispatcher_LogEntry::debug($this->log, "Response code: {$response->getResponseCode()}.");
if ($response->getResponseCode() == 200) {
$response_body = $response->getBody();
if (preg_match('/Removed episode .* from series .*/', $response_body)) {
DownloadDispatcher_LogEntry::info($this->log, "Successfully made flexget forget about {$series} s{$season}e{$episode}.");
} else {
DownloadDispatcher_LogEntry::warning($this->log, "Failed to make flexget forget about {$series} s{$season}e{$episode}.");
}
} else {
DownloadDispatcher_LogEntry::warning($this->log, "Failed to communicate with flexget webui.");
}
#$base_url = $this->config->get('sources.TV.flexget-url');
#$username = $this->config->get('sources.TV.flexget-username');
#$password = $this->config->get('sources.TV.flexget-password');
#
#// Pad series and episode numbers with leading zeroes for flexget
#$season = str_pad($season, 2, '0', STR_PAD_LEFT);
#$episode = str_pad($episode, 2, '0', STR_PAD_LEFT);
#
#$url = "{$base_url}execute/";
#$data = array(
# 'options' => "--series-forget '{$series}' 's{$season}e{$episode}'",
# 'submit' => 'Start Execution',
#);
#
#DownloadDispatcher_LogEntry::debug($this->log, "Sending flexget series-forget command to {$url} with options '{$data['options']}'.");
#
#$request = new HttpRequest($url, HTTP_METH_POST, array(
# 'httpauth' => "{$username}:{$password}",
# 'httpauthtype' => HTTP_AUTH_BASIC,
#));
#$request->setPostFields($data);
#
#$response = $request->send();
#DownloadDispatcher_LogEntry::debug($this->log, "Response code: {$response->getResponseCode()}.");
#
#if ($response->getResponseCode() == 200) {
# $response_body = $response->getBody();
# if (preg_match('/Removed episode .* from series .*/', $response_body)) {
# DownloadDispatcher_LogEntry::info($this->log, "Successfully made flexget forget about {$series} s{$season}e{$episode}.");
# } else {
# DownloadDispatcher_LogEntry::warning($this->log, "Failed to make flexget forget about {$series} s{$season}e{$episode}.");
# }
#} else {
# DownloadDispatcher_LogEntry::warning($this->log, "Failed to communicate with flexget webui.");
#}
}
}