diff --git a/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java b/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java index 8024a9c2..f77a0dc2 100644 --- a/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java +++ b/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TorrentCommands.java @@ -8,6 +8,7 @@ import com.halushko.kinocat.core.web.InputMessageHandlerApiRequest; import com.halushko.kinocat.torrent.entities.CommonTorrentEntity; import com.halushko.kinocat.torrent.internalScripts.ViewTorrentInfo; +import lombok.extern.slf4j.Slf4j; import lombok.val; import java.util.List; @@ -15,32 +16,11 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +@Slf4j public class TorrentCommands extends TransmissionWebApiExecutor { public TorrentCommands() { super(); } -// @Override -// protected String getResultString(List lines, SmartJson rabbitMessage) { -// if (lines == null || lines.isEmpty()) return "Something went wrong with EXECUTE_TORRENT_COMMAND_FILE_COMMANDS"; -// String arg = rabbitMessage.getValue("ARG"); -// -// Matcher matcher; -// String name = ""; -// for (String info : ViewTorrentInfo.getInfo(arg)) { -// matcher = PATTERN_GET_NAME.matcher(info); -// if (matcher.find()) { -// name = matcher.group(1); -// break; -// } -// } -// -// return String.format("%s\n%s%s\n%s%s\n%s%s\n%s%s", name, -// Constants.Commands.Torrent.PAUSE, arg, -// Constants.Commands.Torrent.RESUME, arg, -// Constants.Commands.Torrent.TORRENT_INFO, arg, -// Constants.Commands.Text.REMOVE_COMMAND, arg -// ); -// } @Override protected void executeRequest(SmartJson message) { @@ -48,9 +28,11 @@ protected void executeRequest(SmartJson message) { String requestBodyFormat = ResourceReader.readResourceContent(String.format("transmission_requests/%s", message.getText())); String torrentId = message.getValue("ARG"); String requestBody = String.format(requestBodyFormat, torrentId); + log.debug("[executeRequest] Request body:\n{}", requestBody); val responce = send(requestBody, "Content-Type", "application/json", sessionIdKey, sessionIdValue); String bodyJson = responce.getBody(); + log.debug("[executeRequest] Responce body:\n{}", bodyJson); val json = new SmartJson(bodyJson); StringBuilder sb = new StringBuilder(); diff --git a/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TransmissionWebApiExecutor.java b/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TransmissionWebApiExecutor.java index 36a0ed95..a112b1c4 100644 --- a/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TransmissionWebApiExecutor.java +++ b/torrent/src/main/java/com/halushko/kinocat/torrent/externalCalls/TransmissionWebApiExecutor.java @@ -3,9 +3,11 @@ import com.halushko.kinocat.core.files.ResourceReader; import com.halushko.kinocat.core.rabbit.SmartJson; import com.halushko.kinocat.core.web.InputMessageHandlerApiRequest; +import lombok.extern.slf4j.Slf4j; import lombok.val; // https://github.com/transmission/transmission/blob/main/docs/rpc-spec.md +@Slf4j public abstract class TransmissionWebApiExecutor extends InputMessageHandlerApiRequest { protected String sessionIdValue; protected final static String sessionIdKey = "X-Transmission-Session-Id"; @@ -15,8 +17,9 @@ public TransmissionWebApiExecutor() { @Override protected final void getDeliverCallbackPrivate(SmartJson message) { + log.debug("[executeRequest] Message:\n{}", message.getRabbitMessageText()); + if(sessionIdValue == null) { - String requestBody = ResourceReader.readResourceContent("transmission_requests/get_torrents_list.json"); val responce = send("", "Content-Type", "application/json"); String sessionIdKey = "X-Transmission-Session-Id"; this.sessionIdValue = responce.getHeader(sessionIdKey); diff --git a/torrent/src/main/resources/transmission_requests/get_torrents_names.json b/torrent/src/main/resources/transmission_requests/get_torrents_names.json index b6daf594..da51939f 100644 --- a/torrent/src/main/resources/transmission_requests/get_torrents_names.json +++ b/torrent/src/main/resources/transmission_requests/get_torrents_names.json @@ -4,7 +4,6 @@ "id", "name" ], - "format": "table", "ids": [ %s ]