From 94ef038f3a28294c0a7148bc7e30b149cfabd63a Mon Sep 17 00:00:00 2001 From: Chocobo1 Date: Sun, 7 Sep 2025 17:50:39 +0800 Subject: [PATCH] Improve abstraction of search plugin To make intentions clear and avoid misuse. Now it should be possible to inherit `Engine` class and create an usable subclass from it. PR #23232. --- src/searchengine/nova3/nova2.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/searchengine/nova3/nova2.py b/src/searchengine/nova3/nova2.py index 6df365a07..64f61c15d 100644 --- a/src/searchengine/nova3/nova2.py +++ b/src/searchengine/nova3/nova2.py @@ -1,4 +1,4 @@ -# VERSION: 1.49 +# VERSION: 1.50 # Author: # Fabien Devaux @@ -39,6 +39,7 @@ import sys import traceback import urllib.parse import xml.etree.ElementTree as ET +from abc import ABC, abstractmethod from collections.abc import Iterable from enum import Enum from glob import glob @@ -77,19 +78,21 @@ Category = Enum('Category', ['all', 'anime', 'books', 'games', 'movies', 'music' EngineModuleName = str # the filename of the engine plugin -class Engine: - url: str +class Engine(ABC): name: str + url: str supported_categories: dict[str, str] - def __init__(self) -> None: - pass + @abstractmethod + def search(self, query: str, category: str = Category.all.name) -> None: + #novaprinter.prettyPrinter() + raise NotImplementedError - def search(self, what: str, cat: str = Category.all.name) -> None: - pass - - def download_torrent(self, info: str) -> None: - pass + """ + Provide customized .torrent file download implementation. For example in your own subclass: + def download_torrent(self, url: str) -> None: + print(helpers.download_file(url)) + """ # global state