Skip to content

Commit 6e7ae4c

Browse files
handle empty reponse, remove test scripts
1 parent c88832a commit 6e7ae4c

File tree

11 files changed

+45
-47
lines changed

11 files changed

+45
-47
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ The `token_handler` should implement the following methods:
5656
The `token_handler` is optional and will default to a `TokenFileHandler` if not provided.
5757

5858
> [!TIP]
59-
> You can use the `BaseTokenHandler` class to store and update tokens in a database or other storage mechanism. Simply implement the `read` and `write` methods and pass an instance of your custom class to the `SonicBit` constructor. This will allow you to store tokens in a secure location and easily update them as needed.
59+
> You can use the `TokenHandler` class to store and update tokens in a database or other storage mechanism. Simply implement the `read` and `write` methods and pass an instance of your custom class to the `SonicBit` constructor. This will allow you to store tokens in a secure location and easily update them as needed.
6060
6161
### User Module
6262

sonicbit/handlers/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
from .token_file import TokenHandler, TokenFileHandler
1+
from .token_file import TokenFileHandler, TokenHandler
22

33
__all__ = [
44
"TokenHandler",
55
"TokenFileHandler",
6-
]
6+
]

sonicbit/modules/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from .base import SonicBitBase
21
from .auth import Auth
2+
from .base import SonicBitBase
33
from .file import File
44
from .remote_download import RemoteDownload
55
from .torrent import Torrent
@@ -12,4 +12,4 @@
1212
"RemoteDownload",
1313
"Torrent",
1414
"User",
15-
]
15+
]

sonicbit/modules/auth.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@ def __init__(
2727

2828
self.session.headers.update({"Authorization": f"Bearer {token}"})
2929

30-
def get_token(
31-
self, email: str, password: str, token_handler: TokenHandler
32-
) -> str:
30+
def get_token(self, email: str, password: str, token_handler: TokenHandler) -> str:
3331
logger.debug("Getting token")
3432
token = token_handler.read(email)
3533
if token:

sonicbit/modules/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33

44
class SonicBitBase:
55
"""Base class for all SonicBit modules."""
6-
6+
77
session = Session

sonicbit/modules/file.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import json
22
import logging
33

4-
from requests import Session
54

65
from sonicbit.enums import FileCommand
76
from sonicbit.modules.base import SonicBitBase

sonicbit/modules/remote_download.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
from requests import Session
43

54
from sonicbit.enums import RemoteDownloadCommand
65
from sonicbit.error.error import SonicbitError
@@ -35,9 +34,6 @@ def list_remote_downloads(self) -> RemoteTaskList:
3534
self.url("/remote_download/task/list"), params=params
3635
)
3736

38-
with open("test.json", "w") as f:
39-
f.write(response.text)
40-
4137
return RemoteTaskList.from_response(self, response)
4238

4339
def delete_remote_download(self, id: int) -> bool:

sonicbit/modules/torrent.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22
from typing import List
33

4-
from requests import Session
54

65
from sonicbit.enums import TorrentCommand
76
from sonicbit.error import SonicbitError
@@ -50,9 +49,6 @@ def list_torrents(self) -> TorrentList:
5049

5150
response = self.session.post(self.url("/app/seedbox/torrent/list"))
5251

53-
with open("test.json", "w") as f:
54-
f.write(response.text)
55-
5652
return TorrentList.from_response(self, response)
5753

5854
def get_torrent_details(self, hash: str) -> TorrentDetails:

sonicbit/modules/user.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import logging
22

3-
from requests import Session
43

54
from sonicbit.error.error import SonicbitError
65
from sonicbit.modules.base import SonicBitBase

sonicbit/sonicbit.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
1+
from sonicbit.handlers.token_file import TokenFileHandler, TokenHandler
12
from sonicbit.modules.auth import Auth
23
from sonicbit.modules.file import File
34
from sonicbit.modules.remote_download import RemoteDownload
45
from sonicbit.modules.torrent import Torrent
56
from sonicbit.modules.user import User
6-
from sonicbit.handlers.token_file import TokenHandler, TokenFileHandler
7+
78

89
class SonicBit(Auth, User, File, Torrent, RemoteDownload):
9-
def __init__(self, email: str, password: str, token: str = None, token_handler: TokenHandler = TokenFileHandler()):
10+
def __init__(
11+
self,
12+
email: str,
13+
password: str,
14+
token: str = None,
15+
token_handler: TokenHandler = TokenFileHandler(),
16+
):
1017
super().__init__(email, password, token, token_handler)

0 commit comments

Comments
 (0)