Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QBT remove false link to torrent folder. #8628

Merged
merged 13 commits into from
Nov 24, 2023
4 changes: 3 additions & 1 deletion sickchill/gui/slick/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,9 @@ const SICKCHILL = {
$('#torrent_auth_type_option').show();
} else if (selectedProvider.toLowerCase() === 'qbittorrent') {
client = 'qBittorrent';
$('#torrent_path_option').hide();
$('#torrent_path_option').show();
$('#torrent_path_option').find('.fileBrowser').show();
$('#torrent_path_incomplete_option').show();
$('#label_warning_qbittorrent').show();
$('#label_anime_warning_qbittorrent').show();
$('#torrent_verify_cert_option').show();
Expand Down
10 changes: 5 additions & 5 deletions sickchill/oldbeard/clients/download_station.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,17 @@ def _check_response(self, data=None):
try:
jdata = self.response.json()
except (ValueError, AttributeError):
logger.info("Could not convert response to json, check the host:port: {0!r}".format(self.response))
logger.debug("Could not convert response to json, check the host:port: {0!r}".format(self.response))
return False

if not jdata.get("success"):
error_code = jdata.get("error", {}).get("code")
api_method = (data or {}).get("method", "login")
log_string = self.error_map.get(api_method).get(error_code, None)
if not log_string:
logger.info(jdata)
logger.debug(jdata)
else:
logger.info("{0}".format(log_string))
logger.debug(f"{log_string}")

return jdata.get("success")

Expand Down Expand Up @@ -187,7 +187,7 @@ def _add_torrent_uri(self, result: "SearchResult"):
data["create_list"] = "false"
data["destination"] = self._get_destination(result)

logger.info('Posted as url with {} destination "{}"'.format(data["api"], data["destination"]))
logger.debug(f"Posted as file with {data['api']} destination {data['destination']}")
self._request(method="post", data=data)
return self._check_response(data)

Expand All @@ -208,7 +208,7 @@ def _add_torrent_file(self, result: "SearchResult"):
data["create_list"] = "false"
data["destination"] = f'"{self._get_destination(result)}"'

logger.info("Posted as file with {} destination {}".format(data["api"], data["destination"]))
logger.debg(f"Posted as file with {data['api']} destination {data['destination']}")
self._request(method="post", data=data, files=files)
return self._check_response(data)

Expand Down
7 changes: 5 additions & 2 deletions sickchill/oldbeard/clients/qbittorrent.py
Copy link
Collaborator Author

@BKSteve BKSteve Nov 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add this debug logging to others?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, this was added though when their API changes between dsm5 and 6 I think though. Up to you.

Copy link
Collaborator Author

@BKSteve BKSteve Nov 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant add logging.debug for uT and rT etc. so there is some data if any of them aren't working.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By all means, if you think it might be helpful at another time for debugging go for it.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import qbittorrentapi

from sickchill import settings
from sickchill import logger, settings
from sickchill.oldbeard.clients.generic import GenericClient

if TYPE_CHECKING: # pragma: no cover
Expand Down Expand Up @@ -43,15 +43,18 @@ def test_client_connection(self):
@staticmethod
def __torrent_args(result: "TorrentSearchResult"):
return dict(
save_path=settings.TORRENT_DIR or None,
save_path=settings.TORRENT_PATH or None,
download_path=settings.TORRENT_PATH_INCOMPLETE or None,
category=(settings.TORRENT_LABEL, settings.TORRENT_LABEL_ANIME)[result.show.is_anime] or settings.TORRENT_LABEL,
is_paused=settings.TORRENT_PAUSED,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The __torrent_args method has been updated to use settings.TORRENT_PATH and settings.TORRENT_PATH_INCOMPLETE for the save_path and download_path parameters, respectively. This change is crucial for ensuring that the correct paths are used when adding torrents via qBittorrent. However, the use of a tuple to determine the category (settings.TORRENT_LABEL, settings.TORRENT_LABEL_ANIME)[result.show.is_anime] assumes that result.show.is_anime is a boolean that can be used as an index. This could lead to an IndexError if is_anime is not strictly a boolean. It would be safer to use a conditional expression instead.

- category=(settings.TORRENT_LABEL, settings.TORRENT_LABEL_ANIME)[result.show.is_anime] or settings.TORRENT_LABEL,
+ category=settings.TORRENT_LABEL_ANIME if result.show.is_anime else settings.TORRENT_LABEL,

Commitable suggestion

[!IMPORTANT]
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
@staticmethod
def __torrent_args(result: "TorrentSearchResult"):
return dict(
save_path=settings.TORRENT_DIR or None,
save_path=settings.TORRENT_PATH or None,
download_path=settings.TORRENT_PATH_INCOMPLETE or None,
category=(settings.TORRENT_LABEL, settings.TORRENT_LABEL_ANIME)[result.show.is_anime] or settings.TORRENT_LABEL,
is_paused=settings.TORRENT_PAUSED,
)
@staticmethod
def __torrent_args(result: "TorrentSearchResult"):
return dict(
save_path=settings.TORRENT_PATH or None,
download_path=settings.TORRENT_PATH_INCOMPLETE or None,
category=settings.TORRENT_LABEL_ANIME if result.show.is_anime else settings.TORRENT_LABEL,
is_paused=settings.TORRENT_PAUSED,
)


def _add_torrent_uri(self, result: "TorrentSearchResult"):
logger.debug(f"Posted as url with {self.__torrent_args(result)}")
return self.api.torrents_add(urls=[result.url], **self.__torrent_args(result))

def _add_torrent_file(self, result: "TorrentSearchResult"):
logger.debug(f"Posted as file with {self.__torrent_args(result)}")
return self.api.torrents_add(torrent_files=[result.content], **self.__torrent_args(result))

def _set_torrent_priority(self, result: "TorrentSearchResult"):
Expand Down
Loading