sok.server.renames
The renames of S.O.K Server: the Ready rows of a tab go to their folder.
A rename takes the rows of one tab, all those that are Ready (or picked by hand) or a list of them, and runs in the background like an analysis, never at the same time as one. The file operations of the desktop batches move them, with the file mode, the behavior settings, the subtitles and the posters of the settings; the whole rename is one operation of the history.
With hard links, every source and destination of the rename are tested first: if one pair cannot be linked, nothing is renamed and the error says which folders. The files renamed leave the table; a file that fails, or is skipped as a duplicate, stays on its row with why.
RenameError
class RenameError(code: str, **details: str)Bases: Exception
A rename that cannot start: unknown_type, nothing_to_rename, no_destination, scan_running, already_running, or a hard link problem (different_drives, no_hard_links, missing_folder) with the folders.
Parameters
| Name | Type | Description |
|---|---|---|
code | str | |
**details | str |
Attributes
| Name |
|---|
code |
details |
detail
def detail() -> Dict[str, str]:Renamer
class Renamer( db: Database, config: ConfigManager, events: EventBus, searcher: Searcher, history: History, jobs: Jobs, notifier: Optional[Notifier] = None,)Start the renames and keep their results in the database.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
db | Database | ||
config | ConfigManager | ||
events | EventBus | ||
searcher | Searcher | ||
history | History | ||
jobs | Jobs | ||
notifier | Optional[Notifier] | None |
current
def current() -> Dict[str, Any]:The last rename, with its result once done.
Sourcestart
def start( media_type: str, row_ids: Optional[List[int]] = None, auto: bool = False,) -> int:Start renaming the Ready rows of a tab, in the background.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
media_type | str | The tab: movies, tv, music, books or games. | |
row_ids | Optional[List[int]] | None | Only these rows; all the Ready rows of the tab when None. The rows not Ready are left out. |
auto | bool | False | Started by the automatic sorting (Watcher), not by a click. |
Returns
intThe id of the rename.
Raises
RenameErrorSee its codes.
Functions
link_problem
def link_problem(file: str, folder: str) -> Optional[str]:Why a file cannot be hard linked into a folder, or None.
Parameters
| Name | Type | Description |
|---|---|---|
file | str | |
folder | str |
Attributes
| Name | Value |
|---|---|
ALREADY_EXISTS | 'already_exists' |
DONE | 'done' |
FAILED | 'failed' |
INTERRUPTED | 'interrupted' |
RENAME_FAILED | 'failed' |
RUNNING | 'running' |
logger | logging.getLogger(__name__) |