Skip to content

Commit

Permalink
feat: add denied reasoning when trashing torrents and added adult par…
Browse files Browse the repository at this point in the history
…sing (#888)

* fix: changed exception to log GarbageTorrent on _parsed_results. pinned RTN version

* chore: update poetry lock file on new RTN version pin

* chore: update RTN version to 1.5.3 to fix remove_trash option

* chore: housekeeping logs

* chore: update deps
  • Loading branch information
dreulavelle authored Nov 20, 2024
1 parent 24ee3d8 commit d3b5293
Show file tree
Hide file tree
Showing 8 changed files with 231 additions and 226 deletions.
426 changes: 217 additions & 209 deletions poetry.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ alembic = "^1.13.2"
psycopg2-binary = "^2.9.9"
apprise = "^1.8.1"
subliminal = "^2.2.1"
rank-torrent-name = "^1.0.2"
rank-torrent-name = ">=1.5,<2.0"
jsonschema = "^4.23.0"
scalar-fastapi = "^1.0.3"
psutil = "^6.0.0"
Expand Down
5 changes: 2 additions & 3 deletions src/program/apis/overseerr_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,7 @@ def get_media_requests(self, service_key: str) -> list[MediaItem]:
MediaItem({
"imdb_id": imdb_id,
"requested_by": service_key,
"overseerr_id": item.media.id,
"requested_id": item.id
"overseerr_id": item.media.id
})
)
elif item.media.tmdbId:
Expand Down Expand Up @@ -137,7 +136,7 @@ def delete_request(self, mediaId: int) -> bool:
try:
response = self.request_handler.execute(HttpMethod.DELETE, f"api/v1/request/{mediaId}", headers=headers)
logger.debug(f"Deleted request {mediaId} from overseerr")
return response.is_ok == True
return response.is_ok
except Exception as e:
logger.error(f"Failed to delete request from overseerr: {str(e)}")
return False
Expand Down
4 changes: 2 additions & 2 deletions src/program/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def _update_ongoing(self) -> None:
).scalars().all()

if not item_ids:
logger.debug("PROGRAM", "No ongoing or unreleased items to update.")
logger.debug("No ongoing or unreleased items to update.")
return

logger.debug(f"Updating state for {len(item_ids)} ongoing and unreleased items.")
Expand All @@ -242,7 +242,7 @@ def _update_ongoing(self) -> None:
except Exception as e:
logger.error(f"Failed to update state for item with ID {item_id}: {e}")

logger.debug("PROGRAM", f"Found {counter} items with updated state.")
logger.debug(f"Found {counter} items with updated state.")

def _schedule_functions(self) -> None:
"""Schedule each service based on its update interval."""
Expand Down
4 changes: 2 additions & 2 deletions src/program/services/scrapers/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ def _parse_results(item: MediaItem, results: Dict[str, str], log_msg: bool = Tru
if settings_manager.settings.scraping.parse_debug and log_msg:
logger.debug(f"Skipping torrent: '{raw_title}' - {e}")
continue
except GarbageTorrent:
except GarbageTorrent as e:
if settings_manager.settings.scraping.parse_debug and log_msg:
logger.debug(f"Trashing torrent for {item.log_string}: '{raw_title}'")
logger.debug(e)
continue

if torrents:
Expand Down
2 changes: 1 addition & 1 deletion src/program/settings/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class ScraperModel(Observable):


class RTNSettingsModel(SettingsModel, Observable):
profile: str = "default"
...


# Application Settings
Expand Down
10 changes: 5 additions & 5 deletions src/routers/secure/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ async def remove_item(request: Request, ids: str) -> RemoveResponse:
if symlink_service:
symlink_service.delete_item_symlinks_by_id(item.id)

with db.Session() as session:
requested_id = session.execute(select(MediaItem.requested_id).where(MediaItem.id == item.id)).scalar_one()
if requested_id:
logger.debug(f"Deleting request from Overseerr with ID {requested_id}")
Overseerr.delete_request(requested_id)
if item.overseerr_id:
overseerr: Overseerr = request.app.program.services.get(Overseerr)
if overseerr:
overseerr.delete_request(item.overseerr_id)
logger.debug(f"Deleted request from Overseerr with ID {item.overseerr_id}")

logger.debug(f"Deleting item from database with ID {item.id}")
db_functions.delete_media_item_by_id(item.id)
Expand Down
4 changes: 1 addition & 3 deletions src/routers/secure/webhooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@ async def overseerr(request: Request) -> Dict[str, Any]:
logger.error("Overseerr not initialized")
return {"success": False, "message": "Overseerr not initialized"}

new_item = MediaItem({"imdb_id": imdb_id, "requested_by": "overseerr", "requested_id": req.request.request_id})

new_item = MediaItem({"imdb_id": imdb_id, "requested_by": "overseerr", "overseerr_id": req.request.request_id})
request.app.program.em.add_item(new_item, service="Overseerr")

return {"success": True}


Expand Down

0 comments on commit d3b5293

Please sign in to comment.