changed API endpoint from v2 to v3.

This commit is contained in:
2023-12-12 20:05:46 +09:00
parent f10b42a1f2
commit 292ca1df27
19 changed files with 61 additions and 68 deletions

View File

@ -5,7 +5,7 @@ from typing import Any
from pydantic.dataclasses import dataclass
from mdrsclient.api import FileApi, FolderApi
from mdrsclient.api import FilesApi, FoldersApi
from mdrsclient.commands.base import BaseCommand
from mdrsclient.connection import MDRSConnection
from mdrsclient.exceptions import IllegalArgumentException
@ -62,13 +62,13 @@ class DownloadCommand(BaseCommand):
raise IllegalArgumentException(f"File or folder `{r_path}` not found.")
if not is_recursive:
raise IllegalArgumentException(f"Cannot download `{r_path}`: Is a folder.")
folder_api = FolderApi(connection)
folder_api = FoldersApi(connection)
cls.__multiple_download_pickup_recursive_files(folder_api, download_files, folder.id, l_dirname)
cls.__multiple_download(connection, download_files)
@classmethod
def __multiple_download_pickup_recursive_files(
cls, folder_api: FolderApi, infolist: list[DownloadFileInfo], folder_id: str, basedir: str
cls, folder_api: FoldersApi, infolist: list[DownloadFileInfo], folder_id: str, basedir: str
) -> None:
folder = folder_api.retrieve(folder_id)
dirname = os.path.join(basedir, folder.name)
@ -83,11 +83,11 @@ class DownloadCommand(BaseCommand):
@classmethod
def __multiple_download(cls, connection: MDRSConnection, infolist: list[DownloadFileInfo]) -> None:
file_api = FileApi(connection)
file_api = FilesApi(connection)
with ThreadPoolExecutor(max_workers=CONCURRENT) as pool:
pool.map(lambda x: cls.__multiple_download_worker(file_api, x), infolist)
@classmethod
def __multiple_download_worker(cls, file_api: FileApi, info: DownloadFileInfo) -> None:
def __multiple_download_worker(cls, file_api: FilesApi, info: DownloadFileInfo) -> None:
file_api.download(info.file, info.path)
print(info.path)