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
6 changes: 5 additions & 1 deletion sickchill/gui/slick/js/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,11 @@ 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();
$('#torrent_seed_time_label').text(_('Stop seeding after'));
$('#torrent_seed_time_option').show();
$('#label_warning_qbittorrent').show();
$('#label_anime_warning_qbittorrent').show();
$('#torrent_verify_cert_option').show();
Expand Down
8 changes: 4 additions & 4 deletions sickchill/oldbeard/clients/download_station.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ def _check_response(self, data=None):
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.debug(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
29 changes: 23 additions & 6 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 @@ -41,20 +41,37 @@ def test_client_connection(self):
return True, "Success: Connected and Authenticated"

@staticmethod
def __torrent_args(result: "TorrentSearchResult"):
def __torrent_args(result: "TorrentSearchResult") -> dict:
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,
ratio_limit=(None, float(result.ratio))[float(result.ratio) > 0],
seeding_time_limit=(None, 60 * int(settings.TORRENT_SEED_TIME))[int(settings.TORRENT_SEED_TIME) > 0],
tags=("sickchill", "sickchill-anime")[result.show.is_anime],
)

def __add_trackers(self, result: "TorrentSearchResult"):
if settings.TRACKERS_LIST and result.provider.public:
trackers = list({x.strip() for x in settings.TRACKERS_LIST.split(",") if x.strip()})
if trackers:
logger.debug(f"Adding trackers to public torrent")
return self.api.torrents_add_trackers(torrent_hash=result.hash.lower(), urls=trackers)

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

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

def _set_torrent_priority(self, result: "TorrentSearchResult"):
if not self.api.app_preferences().get("queueing_enabled"):
return True
return (self.api.torrents_decrease_priority, self.api.torrents_increase_priority)[result.priority == 1](result.hash.lower)
return (self.api.torrents_decrease_priority, self.api.torrents_increase_priority)[result.priority == 1](result.hash.lower())
Copy link
Contributor

Choose a reason for hiding this comment

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

These missing parenthesis are a really old bug o can't believe I missed this all those years.

2 changes: 1 addition & 1 deletion sickchill/views/config/providers.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ def saveProviders(self):
provider.check_set_option(self, "sorting", "seeders")
provider.check_set_option(self, "search_mode", "episode")

provider.check_set_option(self, "ratio", 0, cast=lambda x: max(try_int(x), -1))
provider.check_set_option(self, "ratio", 0, cast=float)

settings.NEWZNAB_DATA = "!!!".join([x.config_string() for x in settings.newznab_provider_list])
settings.PROVIDER_ORDER = enabled_provider_list + disabled_provider_list
Expand Down
Loading