Skip to content

The only downloader you need. 下载器的集大成者。

803 B
Raw Blame
from __future__ import annotations

from typing import TYPE_CHECKING

from http_pack.android import editFields as editHttpFields

if TYPE_CHECKING:
    from .task import ArxivTask

UI_CLASS = "com.xychr.ghostdownloader.features.arxiv_pack.ArxivUi"


def editFields(task: ArxivTask) -> dict:
    fields = {**editHttpFields(task), "isBibtexEnabled": task.isBibtexEnabled}
    del fields["url"]
    if task.hasSource:
        fields["isSourceEnabled"] = task.isSourceEnabled
    return fields


def draftFields(task: ArxivTask) -> dict:
    return {
        "hasSource": task.hasSource,
        "isSourceEnabled": task.isSourceEnabled,
        "isBibtexEnabled": task.isBibtexEnabled,
    }


def setSideFile(task: ArxivTask, key: str, isEnabled: bool) -> None:
    task.setOptions({key: bool(isEnabled)})