mirror of
https://github.com/Xevion/indexer-analyze.git
synced 2025-12-05 23:15:18 -06:00
initial commit
This commit is contained in:
44
sonarr.py
Normal file
44
sonarr.py
Normal file
@@ -0,0 +1,44 @@
|
||||
import httpx
|
||||
from config import SONARR_URL, SONARR_API_KEY, logger
|
||||
|
||||
|
||||
async def get_all_series(client: httpx.AsyncClient):
|
||||
"""
|
||||
Fetch all series from Sonarr.
|
||||
"""
|
||||
url = f"{SONARR_URL}/api/v3/series"
|
||||
resp = await client.get(url)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
|
||||
async def get_series(client: httpx.AsyncClient, series_id: int):
|
||||
"""
|
||||
Fetch a single series by ID from Sonarr.
|
||||
"""
|
||||
url = f"{SONARR_URL}/api/v3/series/{series_id}"
|
||||
resp = await client.get(url)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
|
||||
async def get_episodes_for_series(client: httpx.AsyncClient, series_id: int):
|
||||
"""
|
||||
Fetch all episodes for a given series from Sonarr.
|
||||
"""
|
||||
url = f"{SONARR_URL}/api/v3/episode?seriesId={series_id}"
|
||||
resp = await client.get(url)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
|
||||
|
||||
async def get_history_for_episode(client: httpx.AsyncClient, episode_id: int):
|
||||
"""
|
||||
Fetch history for a given episode from Sonarr.
|
||||
"""
|
||||
resp = await client.get(
|
||||
SONARR_URL + "/api/v3/history",
|
||||
params={"episodeId": episode_id, "pageSize": 100},
|
||||
)
|
||||
resp.raise_for_status()
|
||||
return resp.json()
|
||||
Reference in New Issue
Block a user