From 1774e464ccd9a3171dd4c9d880c06f2f8eeb43bb Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Mon, 24 Jun 2024 01:12:00 +0200 Subject: [PATCH] [torrent] Added `is_media` attribute to torrent results. --- platypush/plugins/torrent/_search/_model.py | 1 + platypush/plugins/torrent/_search/_popcorntime.py | 2 ++ platypush/plugins/torrent/_search/_torrents_csv/_facade.py | 6 +++++- platypush/schemas/torrent.py | 7 +++++++ 4 files changed, 15 insertions(+), 1 deletion(-) diff --git a/platypush/plugins/torrent/_search/_model.py b/platypush/plugins/torrent/_search/_model.py index 2375b92ae8..03ec0ce5e3 100644 --- a/platypush/plugins/torrent/_search/_model.py +++ b/platypush/plugins/torrent/_search/_model.py @@ -25,6 +25,7 @@ class TorrentSearchResult: peers: int = 0 image: Optional[str] = None description: Optional[str] = None + is_media: bool = False imdb_id: Optional[str] = None tvdb_id: Optional[str] = None year: Optional[int] = None diff --git a/platypush/plugins/torrent/_search/_popcorntime.py b/platypush/plugins/torrent/_search/_popcorntime.py index 8363963a95..1c35ec0bf1 100644 --- a/platypush/plugins/torrent/_search/_popcorntime.py +++ b/platypush/plugins/torrent/_search/_popcorntime.py @@ -160,6 +160,7 @@ class PopcornTimeSearchProvider(TorrentSearchProvider): [ TorrentSearchResult( provider=cls.provider_name(), + is_media=True, imdb_id=result.get('imdb_id'), type='movies', title=result.get('title', '[No Title]') @@ -196,6 +197,7 @@ class PopcornTimeSearchProvider(TorrentSearchProvider): [ TorrentSearchResult( provider=cls.provider_name(), + is_media=True, imdb_id=result.get('imdb_id'), tvdb_id=result.get('tvdb_id'), type='tv', diff --git a/platypush/plugins/torrent/_search/_torrents_csv/_facade.py b/platypush/plugins/torrent/_search/_torrents_csv/_facade.py index 6553b1f152..c1811b343c 100644 --- a/platypush/plugins/torrent/_search/_torrents_csv/_facade.py +++ b/platypush/plugins/torrent/_search/_torrents_csv/_facade.py @@ -78,7 +78,11 @@ class TorrentsCsvSearchProvider(TorrentsCsvBaseProvider): :param limit: Number of results to return (default: 25). :param page: Page number (default: 1). """ - return list(self._delegate.search(query=query, limit=limit, page=page)) + results = list(self._delegate.search(query=query, limit=limit, page=page)) + for result in results: + result.provider = self.provider_name() + + return results # vim:sw=4:ts=4:et: diff --git a/platypush/schemas/torrent.py b/platypush/schemas/torrent.py index d263c36ce3..abda225383 100644 --- a/platypush/schemas/torrent.py +++ b/platypush/schemas/torrent.py @@ -60,6 +60,13 @@ class TorrentResultSchema(Schema): }, ) + is_media = fields.Boolean( + metadata={ + 'description': 'True if the torrent is a media file', + 'example': True, + }, + ) + size = fields.Integer( missing=0, metadata={