Merge pull request #246 from maxdorninger/increase-timeout

Add timeout config variable
This commit is contained in:
Maximilian Dorninger
2025-12-10 18:13:08 +01:00
committed by GitHub
9 changed files with 44 additions and 8 deletions

View File

@@ -21,7 +21,20 @@ API key for Prowlarr. You can find this in Prowlarr's settings under General.
Set to `true` to reject torrents if there is a URL error when fetching from Prowlarr. Until MediaManager v1.9.0 the
default behavior was `false`, but from v1.9.0 onwards the default is `true`. It's recommended to set this to `true` to
avoid adding possibly invalid torrents.
avoid adding possibly invalid torrents.
- `timeout_seconds`
Timeout in seconds for requests to Prowlarr. Default is `60` seconds.
Symptoms of timeouts are typically no search results (*"No torrents found!"*) in conjunction with logs like these:
```
DEBUG - media_manager.indexer.utils -
follow_redirects_to_final_torrent_url():
An error occurred during the request for <some-url>:
HTTPConnectionPool(host='<some-host>', port=<some-port>):
Read timed out. (read timeout=10)
```
## Jackett (`[indexers.jackett]`)
@@ -41,6 +54,10 @@ API key for Jackett. You can find this in Jackett's dashboard.
List of indexer names to use with Jackett. You can specify which indexers Jackett should search through.
- `timeout_seconds`
Refer to the Prowlarr section for details.
## Example Configuration
Here's a complete example of the indexers section in your `config.toml`:
@@ -51,10 +68,14 @@ Here's a complete example of the indexers section in your `config.toml`:
enabled = true
url = "http://prowlarr:9696"
api_key = "your_prowlarr_api_key"
reject_torrents_on_url_error = true
timeout_seconds = 60
[indexers.jackett]
enabled = false
url = "http://jackett:9117"
api_key = "your_jackett_api_key"
indexers = ["1337x", "rarbg"]
timeout_seconds = 60
```

View File

@@ -1,9 +1,5 @@
# Troubleshooting
<note>
Note the lack of a trailing slash in some env vars like FRONTEND_URL. This is important.
</note>
<tip>
Always check the container and browser logs for more specific error messages
</tip>
@@ -28,4 +24,10 @@
<step>Make sure you are using only one volumes for TV, Movies and Downloads. <a href="https://raw.githubusercontent.com/maxdorninger/MediaManager/refs/heads/master/docker-compose.yaml"> See the configuration in the example <code>docker-compose.yaml</code> file.</a></step>
</procedure>
<procedure title="I get no search results for torrents?" id="procedure-i-get-no-search-results">
<step>Try switching to the advanced tab when searching for torrents.</step>
<step><a href="Indexer-Settings.md">If you use "slow" indexers, try increasing the timeout threshold.</a></step>
<step>If you still don't get any search results, check the logs, they will provide more information on what is going wrong.</step>
</procedure>
<note>If it still doesn't work, <a href="https://github.com/maxdorninger/MediaManager/issues">please open an Issue.</a> It is possible that a bug is causing the issue.</note>

View File

@@ -120,6 +120,7 @@ enabled = false
url = "http://localhost:9696"
api_key = ""
reject_torrents_on_url_error = true
timeout_seconds = 60
# Jackett settings
[indexers.jackett]
@@ -127,6 +128,7 @@ enabled = false
url = "http://localhost:9117"
api_key = ""
indexers = ["1337x", "torrentleech"] # List of indexer names to use
timeout_seconds = 60
# Title-based scoring rules
[[indexers.title_scoring_rules]]

View File

@@ -120,6 +120,7 @@ enabled = false
url = "http://localhost:9696"
api_key = ""
reject_torrents_on_url_error = true
timeout_seconds = 60
# Jackett settings
[indexers.jackett]
@@ -127,6 +128,7 @@ enabled = false
url = "http://localhost:9117"
api_key = ""
indexers = ["1337x", "torrentleech"] # List of indexer names to use
timeout_seconds = 60
# Title-based scoring rules
[[indexers.title_scoring_rules]]

View File

@@ -6,6 +6,7 @@ class ProwlarrConfig(BaseSettings):
api_key: str = ""
url: str = "http://localhost:9696"
reject_torrents_on_url_error: bool = True
timeout_seconds: int = 60
class JackettConfig(BaseSettings):
@@ -13,6 +14,7 @@ class JackettConfig(BaseSettings):
api_key: str = ""
url: str = "http://localhost:9696"
indexers: list[str] = ["all"]
timeout_seconds: int = 60
class ScoringRule(BaseSettings):

View File

@@ -24,6 +24,7 @@ class Jackett(GenericIndexer):
self.api_key = config.api_key
self.url = config.url
self.indexers = config.indexers
self.timeout_seconds = config.timeout_seconds
def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
log.debug("Searching for " + query)
@@ -59,7 +60,7 @@ class Jackett(GenericIndexer):
self.url
+ f"/api/v2.0/indexers/{indexer}/results/torznab/api?apikey={self.api_key}&t={'tvsearch' if is_tv else 'movie'}&q={query}"
)
response = session.get(url)
response = session.get(url, timeout=self.timeout_seconds)
if response.status_code != 200:
log.error(

View File

@@ -26,6 +26,7 @@ class Prowlarr(GenericIndexer):
self.api_key = config.api_key
self.url = config.url
self.reject_torrents_on_url_error = config.reject_torrents_on_url_error
self.timeout_seconds = config.timeout_seconds
def search(self, query: str, is_tv: bool) -> list[IndexerQueryResult]:
log.debug("Searching for " + query)
@@ -98,6 +99,7 @@ class Prowlarr(GenericIndexer):
final_download_url = follow_redirects_to_final_torrent_url(
initial_url=initial_url,
session=session,
timeout=self.timeout_seconds,
)
except RuntimeError as e:
log.warning(

View File

@@ -231,7 +231,9 @@ class MovieRepository:
result = self.db.execute(stmt)
if result.rowcount == 0:
self.db.rollback()
raise NotFoundError(f"movie request with id {movie_request_id} not found.")
raise NotFoundError(
f"movie request with id {movie_request_id} not found."
)
self.db.commit()
# Successfully deleted movie request with id: {movie_request_id}
except SQLAlchemyError as e:

View File

@@ -270,7 +270,9 @@ class TvRepository:
result = self.db.execute(stmt)
if result.rowcount == 0:
self.db.rollback()
raise NotFoundError(f"SeasonRequest with id {season_request_id} not found.")
raise NotFoundError(
f"SeasonRequest with id {season_request_id} not found."
)
self.db.commit()
except SQLAlchemyError as e:
self.db.rollback()