Skip to content

Commit

Permalink
[patch] Merge pull request #105 from Feramance/104-issue-qbitrr-creat…
Browse files Browse the repository at this point in the history
…ing-folder-named-from-qbittorrent-category

Category path checking
  • Loading branch information
Feramance authored Sep 12, 2024
2 parents c620f84 + c038481 commit f225069
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 52 deletions.
24 changes: 12 additions & 12 deletions config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Password = "CHANGE_ME"
# Toggle whether to manage the Servarr instance torrents.
Managed = true

# The URL used to access Servarr interface (if you use a domain enter the domain without a port)
# The URL used to access Servarr interface eg. http://ip:port (if you use a domain enter the domain without a port)
URI = "CHANGE_ME"

# The Servarr API Key, Can be found it Settings > General > Security
Expand Down Expand Up @@ -159,7 +159,7 @@ PrioritizeTodaysReleases = true
# Search Ombi for pending requests (Will only work if 'SearchMissing' is enabled.)
SearchOmbiRequests = false

# Ombi URI (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
# Ombi URI eg. http://ip:port (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
OmbiURI = "CHANGE_ME"

# Ombi's API Key
Expand All @@ -174,7 +174,7 @@ ApprovedOnly = true
# If this and Ombi are both enable, Ombi will be ignored
SearchOverseerrRequests = false

# Overseerr's URI
# Overseerr's URI eg. http://ip:port
OverseerrURI = "CHANGE_ME"

# Overseerr's API Key
Expand Down Expand Up @@ -278,7 +278,7 @@ AddTags = ["qBitrr-anime"]
# Toggle whether to manage the Servarr instance torrents.
Managed = true

# The URL used to access Servarr interface (if you use a domain enter the domain without a port)
# The URL used to access Servarr interface eg. http://ip:port (if you use a domain enter the domain without a port)
URI = "CHANGE_ME"

# The Servarr API Key, Can be found it Settings > General > Security
Expand Down Expand Up @@ -362,7 +362,7 @@ PrioritizeTodaysReleases = true
# Search Ombi for pending requests (Will only work if 'SearchMissing' is enabled.)
SearchOmbiRequests = false

# Ombi URI (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
# Ombi URI eg. http://ip:port (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
OmbiURI = "CHANGE_ME"

# Ombi's API Key
Expand All @@ -377,7 +377,7 @@ ApprovedOnly = true
# If this and Ombi are both enable, Ombi will be ignored
SearchOverseerrRequests = false

# Overseerr's URI
# Overseerr's URI eg. http://ip:port
OverseerrURI = "CHANGE_ME"

# Overseerr's API Key
Expand Down Expand Up @@ -481,7 +481,7 @@ AddTags = ["qBitrr-anime"]
# Toggle whether to manage the Servarr instance torrents.
Managed = true

# The URL used to access Servarr interface (if you use a domain enter the domain without a port)
# The URL used to access Servarr interface eg. http://ip:port (if you use a domain enter the domain without a port)
URI = "CHANGE_ME"

# The Servarr API Key, Can be found it Settings > General > Security
Expand Down Expand Up @@ -561,7 +561,7 @@ TempQualityProfile = "CHANGE_ME"
# Search Ombi for pending requests (Will only work if 'SearchMissing' is enabled.)
SearchOmbiRequests = false

# Ombi URI (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
# Ombi URI eg. http://ip:port (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
OmbiURI = "CHANGE_ME"

# Ombi's API Key
Expand All @@ -576,7 +576,7 @@ ApprovedOnly = true
# If this and Ombi are both enable, Ombi will be ignored
SearchOverseerrRequests = false

# Overseerr's URI
# Overseerr's URI eg. http://ip:port
OverseerrURI = "CHANGE_ME"

# Overseerr's API Key
Expand Down Expand Up @@ -693,7 +693,7 @@ SuperSeedMode = false
# Toggle whether to manage the Servarr instance torrents.
Managed = true

# The URL used to access Servarr interface (if you use a domain enter the domain without a port)
# The URL used to access Servarr interface eg. http://ip:port (if you use a domain enter the domain without a port)
URI = "CHANGE_ME"

# The Servarr API Key, Can be found it Settings > General > Security
Expand Down Expand Up @@ -773,7 +773,7 @@ TempQualityProfile = "CHANGE_ME"
# Search Ombi for pending requests (Will only work if 'SearchMissing' is enabled.)
SearchOmbiRequests = false

# Ombi URI (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
# Ombi URI eg. http://ip:port (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)
OmbiURI = "CHANGE_ME"

# Ombi's API Key
Expand All @@ -788,7 +788,7 @@ ApprovedOnly = true
# If this and Ombi are both enable, Ombi will be ignored
SearchOverseerrRequests = false

# Overseerr's URI
# Overseerr's URI eg. http://ip:port
OverseerrURI = "CHANGE_ME"

# Overseerr's API Key
Expand Down
77 changes: 40 additions & 37 deletions qBitrr/arss.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,20 @@ def __init__(
self.logger.addHandler(fh)
run_logs(self.logger)
categories = self.manager.qbit_manager.client.torrent_categories.categories
self.logger.trace("Categories: %s", categories)
self.completed_folder = pathlib.Path(COMPLETED_DOWNLOAD_FOLDER).joinpath(self.category)
categ = categories[self.category]
if categ:
path = categ["savePath"]
if path:
self.logger.trace("Category exists with save path [%s]", path)
self.completed_folder = pathlib.Path(path)
else:
self.logger.trace("Category exists without save path")
self.completed_folder = pathlib.Path(COMPLETED_DOWNLOAD_FOLDER).joinpath(
self.category
)
else:
self.manager.qbit_manager.client.torrent_categories.createCategory(self.category)
self.completed_folder = pathlib.Path(COMPLETED_DOWNLOAD_FOLDER).joinpath(self.category)
if not self.completed_folder.exists() and not SEARCH_ONLY:
try:
self.completed_folder.mkdir(parents=True, exist_ok=True)
Expand Down Expand Up @@ -2448,15 +2460,15 @@ def db_update_single_series(
except AttributeError:
pass

self.logger.trace(
self.logger.debug(
"Updating database entry | %s | S%02dE%03d [Searched:%s][Upgrade:%s][QualityMet:%s][CustomFormatMet:%s]",
SeriesTitle,
SeriesTitle.ljust(60, "."),
SeasonNumber,
EpisodeNumber,
searched,
upgrade,
QualityMet,
customFormatMet,
str(searched).ljust(5),
str(upgrade).ljust(5),
str(QualityMet).ljust(5),
str(customFormatMet).ljust(5),
)

if request:
Expand Down Expand Up @@ -2603,11 +2615,11 @@ def db_update_single_series(
except AttributeError:
pass

self.logger.trace(
self.logger.debug(
"Updating database entry | %s [Searched:%s][Upgrade:%s]",
Title,
searched,
upgrade,
Title.ljust(60, "."),
str(searched).ljust(5),
str(upgrade).ljust(5),
)

db_commands = self.series_file_model.insert(
Expand Down Expand Up @@ -2665,10 +2677,11 @@ def db_update_single_series(
requests.exceptions.ContentDecodingError,
requests.exceptions.ConnectionError,
JSONDecodeError,
KeyError,
):
completed = True
except KeyError:
self.logger.warning("Key Error [%s]", db_entry["id"])
# except KeyError:
# self.logger.warning("Key Error [%s]", db_entry["id"])
QualityUnmet = (
db_entry["episodeFile"]["qualityCutoffNotMet"]
if "episodeFile" in db_entry
Expand Down Expand Up @@ -2760,13 +2773,13 @@ def db_update_single_series(
if request:
to_update[self.model_file.IsRequest] = request

self.logger.trace(
self.logger.debug(
"Updating database entry | %s [Searched:%s][Upgrade:%s][QualityMet:%s][CustomFormatMet:%s]",
title,
searched,
upgrade,
qualityMet,
customFormatMet,
title.ljust(60, "."),
str(searched).ljust(5),
str(upgrade).ljust(5),
str(qualityMet).ljust(5),
str(customFormatMet).ljust(5),
)

db_commands = self.model_file.insert(
Expand Down Expand Up @@ -3277,7 +3290,7 @@ def process_torrents(self):
return self._temp_overseer_request_cache
except qbittorrentapi.exceptions.APIError as e:
self.logger.error("The qBittorrent API returned an unexpected error")
self.logger.debug("Unexpected APIError from qBitTorrent", exc_info=e)
self.logger.debug("Unexpected APIError from qBitTorrent") # , exc_info=e)
raise DelayLoopException(length=300, type="qbit")
except DelayLoopException:
raise
Expand Down Expand Up @@ -4447,14 +4460,9 @@ def custom_format_unmet_check(self, torrent: qbittorrentapi.TorrentDictionary) -
.first()
)
if episode.EpisodeFileId != 0:
cfunmet = (
customFormat < episode.CustomFormatScore
or customFormat < episode.MinCustomFormatScore
)
elif self.force_minimum_custom_format:
cfunmet = customFormat < episode.MinCustomFormatScore
else:
return True
cfunmet = customFormat < episode.CustomFormatScore
if self.force_minimum_custom_format:
cfunmet = cfunmet & customFormat < episode.MinCustomFormatScore
if cfunmet:
return True
else:
Expand Down Expand Up @@ -4514,14 +4522,9 @@ def custom_format_unmet_check(self, torrent: qbittorrentapi.TorrentDictionary) -
self.model_file.select().where(self.model_file.EntryId == entry).first()
)
if movie.MovieFileId != 0:
cfunmet = (
customFormat < movie.CustomFormatScore
or customFormat < movie.MinCustomFormatScore
)
elif self.force_minimum_custom_format:
cfunmet = customFormat < episode.MinCustomFormatScore
else:
return True
cfunmet = customFormat < movie.CustomFormatScore
if self.force_minimum_custom_format:
cfunmet = cfunmet & customFormat < movie.MinCustomFormatScore
if cfunmet:
return True
else:
Expand Down
8 changes: 5 additions & 3 deletions qBitrr/gen_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def _gen_default_cat(category: str, config: TOMLDocument):
)
_gen_default_line(
cat_default,
"The URL used to access Servarr interface "
"The URL used to access Servarr interface eg. http://ip:port"
"(if you use a domain enter the domain without a port)",
"URI",
"CHANGE_ME",
Expand Down Expand Up @@ -665,7 +665,7 @@ def _gen_default_ombi_table(category: str, search_table: Table):
)
_gen_default_line(
ombi_table,
"Ombi URI (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)",
"Ombi URI eg. http://ip:port (Note that this has to be the instance of Ombi which manage the Arr instance request (If you have multiple Ombi instances)",
"OmbiURI",
"CHANGE_ME",
)
Expand All @@ -685,7 +685,9 @@ def _gen_default_overseerr_table(category: str, search_table: Table):
"SearchOverseerrRequests",
False,
)
_gen_default_line(overseerr_table, "Overseerr's URI", "OverseerrURI", "CHANGE_ME")
_gen_default_line(
overseerr_table, "Overseerr's URI eg. http://ip:port", "OverseerrURI", "CHANGE_ME"
)
_gen_default_line(overseerr_table, "Overseerr's API Key", "OverseerrAPIKey", "CHANGE_ME")
_gen_default_line(overseerr_table, "Only process approved requests", "ApprovedOnly", True)
overseerr_table.add(comment("Only for 4K Instances"))
Expand Down

0 comments on commit f225069

Please sign in to comment.