-
Notifications
You must be signed in to change notification settings - Fork 4
/
baseplugin.py
65 lines (55 loc) · 2.15 KB
/
baseplugin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
from typing import List
from functions import BulkMode
from pluginmixin import PluginMixin, PluginOutput
class BasePlugin(PluginMixin):
def get_bulk_mode(self, args) -> BulkMode:
"""
Implement to specify which bulk mode scanner should be used, based on parameters sent to the plugin
BulkMode.STANDARD: each subfolder in the scan path is treated as an item
BulkMode.MUSIC: each music release, identified by the recursive scanner, is treated as an item
:param args:
:return:
"""
return BulkMode.STANDARD
def get_blacklist_file_extensions(self, args) -> List[str]:
"""
Implement this function to disallow file types based on parameters to the plugin
Use to e.g. blacklist archives for media torrents
:param args: plugin parameters
:return: List of disallowed file extensions
"""
return []
def validate_settings(self) -> None:
"""
# TODO remove
"""
pass
def get_update(self, smarthash_version) -> str:
"""
# TODO remove
Retrieves an updated version of the current plugin
:param smarthash_version: Version of smarthash core
:return: text containing an updated plugin's code
"""
return ""
def validate_parameters(self, args) -> None:
"""
Implement this function to validate parameters passed to the plugin
:raises: PluginError if an invalid combination of parameters are passed
"""
pass
def early_validation(self, path, data) -> None:
"""
Implement this function to do server-size content validation before uploading
Use to avoid unnecessarily hashing content which would not be accepted
:param path: Path to the torrent's contents
:param data: plugin parameters and content metadata
"""
pass
def handle(self, data) -> PluginOutput:
"""
Required. This function contains the upload logic for the plugin
:param data: plugin parameters and content metadata
:return: object containing the finalized .torrent file
"""
pass