nyapy 0.1.3__py3-none-any.whl → 0.1.5__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- nyapy/__init__.py +2 -2
- nyapy/client.py +1 -1
- nyapy/enums.py +2 -2
- nyapy/nyaa.py +27 -13
- nyapy/nyaafun.py +3 -22
- nyapy/sukebei.py +3 -22
- nyapy/types/nyaa.py +37 -0
- {nyapy-0.1.3.dist-info → nyapy-0.1.5.dist-info}/METADATA +1 -1
- nyapy-0.1.5.dist-info/RECORD +10 -0
- nyapy-0.1.3.dist-info/RECORD +0 -10
- {nyapy-0.1.3.dist-info → nyapy-0.1.5.dist-info}/WHEEL +0 -0
nyapy/__init__.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
from .
|
|
1
|
+
from .nyaa import BadResponse
|
|
2
2
|
from .nyaafun import NyaaFun
|
|
3
3
|
from .sukebei import Sukebei
|
|
4
4
|
|
|
5
|
-
__all__ = ['
|
|
5
|
+
__all__ = ['NyaaFun', 'Sukebei', 'BadResponse']
|
nyapy/client.py
CHANGED
|
@@ -8,5 +8,5 @@ def get_client(base_url: str) -> AsyncClient:
|
|
|
8
8
|
'user-agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/144.0.0.0 Safari/537.36'
|
|
9
9
|
},
|
|
10
10
|
timeout=10.0,
|
|
11
|
-
transport=AsyncHTTPTransport(retries=
|
|
11
|
+
transport=AsyncHTTPTransport(retries=10),
|
|
12
12
|
)
|
nyapy/enums.py
CHANGED
nyapy/nyaa.py
CHANGED
|
@@ -3,8 +3,9 @@ import re
|
|
|
3
3
|
from bs4 import BeautifulSoup
|
|
4
4
|
|
|
5
5
|
from .client import get_client
|
|
6
|
-
from .enums import
|
|
7
|
-
from .
|
|
6
|
+
from .enums import Filter as FilterEnum
|
|
7
|
+
from .enums import NyaaFunCategories, NyaaSite, SukebeiCategories
|
|
8
|
+
from .types.nyaa import ContentData, Filter, Order, ResponseData, Sort
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
class BadResponse(Exception):
|
|
@@ -12,25 +13,36 @@ class BadResponse(Exception):
|
|
|
12
13
|
super().__init__(message)
|
|
13
14
|
|
|
14
15
|
|
|
15
|
-
class Nyaa:
|
|
16
|
+
class Nyaa[T: str]:
|
|
16
17
|
def __init__(self, site: NyaaSite) -> None:
|
|
17
|
-
self.
|
|
18
|
+
self._client = get_client(site)
|
|
19
|
+
self._categories_enum = (
|
|
20
|
+
NyaaFunCategories if NyaaSite.FUN == site else SukebeiCategories
|
|
21
|
+
)
|
|
18
22
|
|
|
19
23
|
async def get_content(
|
|
20
|
-
self,
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
filter: Filter | None = None,
|
|
27
|
+
category: T | None = None,
|
|
28
|
+
query: str | None = None,
|
|
29
|
+
page: int = 1,
|
|
30
|
+
sort: Sort | None = None,
|
|
31
|
+
order: Order = 'desc',
|
|
21
32
|
) -> ResponseData:
|
|
22
|
-
if sort == 'date'
|
|
23
|
-
|
|
33
|
+
sortval = 'id' if sort == 'date' else None
|
|
34
|
+
catval = self._categories_enum[category] if category else None
|
|
35
|
+
filterval = FilterEnum[filter] if filter else None
|
|
24
36
|
|
|
25
|
-
res = await self.
|
|
37
|
+
res = await self._client.get(
|
|
26
38
|
'',
|
|
27
39
|
params={
|
|
28
|
-
'f':
|
|
29
|
-
'c': category,
|
|
40
|
+
'f': filterval,
|
|
30
41
|
'q': query,
|
|
31
42
|
'p': page,
|
|
32
|
-
's':
|
|
43
|
+
's': sortval,
|
|
33
44
|
'o': order,
|
|
45
|
+
'c': catval,
|
|
34
46
|
},
|
|
35
47
|
)
|
|
36
48
|
|
|
@@ -54,7 +66,9 @@ class Nyaa:
|
|
|
54
66
|
torrent = properties[2].find('i', {'class': 'fa-download'})
|
|
55
67
|
torrent = torrent.parent if torrent else None
|
|
56
68
|
torrent = torrent.get('href') if torrent else None
|
|
57
|
-
torrent =
|
|
69
|
+
torrent = (
|
|
70
|
+
str(self._client.base_url)[:-1] + str(torrent) if torrent else None
|
|
71
|
+
)
|
|
58
72
|
magnet = properties[2].find('i', {'class': 'fa-magnet'})
|
|
59
73
|
magnet = magnet.parent if magnet else None
|
|
60
74
|
magnet = str(magnet.get('href')) if magnet else None
|
|
@@ -83,4 +97,4 @@ class Nyaa:
|
|
|
83
97
|
|
|
84
98
|
async def close(self):
|
|
85
99
|
"""Closes connection to nyaa"""
|
|
86
|
-
await self.
|
|
100
|
+
await self._client.aclose()
|
nyapy/nyaafun.py
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
from .enums import
|
|
1
|
+
from .enums import NyaaSite
|
|
2
2
|
from .nyaa import Nyaa
|
|
3
|
-
from .types.nyaa import
|
|
3
|
+
from .types.nyaa import NyaaFunCategories
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class NyaaFun(Nyaa):
|
|
6
|
+
class NyaaFun(Nyaa[NyaaFunCategories]):
|
|
7
7
|
def __init__(self) -> None:
|
|
8
8
|
super().__init__(NyaaSite.FUN)
|
|
9
|
-
|
|
10
|
-
async def get_content(
|
|
11
|
-
self,
|
|
12
|
-
*,
|
|
13
|
-
filter: Filter | None = None,
|
|
14
|
-
category: NyaaFunCategories | None = None,
|
|
15
|
-
query: str | None = None,
|
|
16
|
-
page: int = 1,
|
|
17
|
-
sort: Sort | None = None,
|
|
18
|
-
order: Order = 'desc',
|
|
19
|
-
) -> ResponseData:
|
|
20
|
-
return await super().get_content(
|
|
21
|
-
filter=filter,
|
|
22
|
-
category=category,
|
|
23
|
-
query=query,
|
|
24
|
-
sort=sort,
|
|
25
|
-
page=page,
|
|
26
|
-
order=order,
|
|
27
|
-
)
|
nyapy/sukebei.py
CHANGED
|
@@ -1,27 +1,8 @@
|
|
|
1
|
-
from .enums import
|
|
1
|
+
from .enums import NyaaSite
|
|
2
2
|
from .nyaa import Nyaa
|
|
3
|
-
from .types.nyaa import
|
|
3
|
+
from .types.nyaa import SukebeiCategories
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
class Sukebei(Nyaa):
|
|
6
|
+
class Sukebei(Nyaa[SukebeiCategories]):
|
|
7
7
|
def __init__(self) -> None:
|
|
8
8
|
super().__init__(NyaaSite.FAP)
|
|
9
|
-
|
|
10
|
-
async def get_content(
|
|
11
|
-
self,
|
|
12
|
-
*,
|
|
13
|
-
filter: Filter | None = None,
|
|
14
|
-
category: SukebeiCategories | None = None,
|
|
15
|
-
query: str | None = None,
|
|
16
|
-
page: int = 1,
|
|
17
|
-
sort: Sort | None = None,
|
|
18
|
-
order: Order = 'desc',
|
|
19
|
-
) -> ResponseData:
|
|
20
|
-
return await super().get_content(
|
|
21
|
-
filter=filter,
|
|
22
|
-
category=category,
|
|
23
|
-
query=query,
|
|
24
|
-
sort=sort,
|
|
25
|
-
page=page,
|
|
26
|
-
order=order,
|
|
27
|
-
)
|
nyapy/types/nyaa.py
CHANGED
|
@@ -27,3 +27,40 @@ class ResponseData(TypedDict):
|
|
|
27
27
|
|
|
28
28
|
type Sort = Literal['comments', 'size', 'date', 'seeders', 'leechers', 'downloads']
|
|
29
29
|
type Order = Literal['asc', 'desc']
|
|
30
|
+
type Filter = Literal['no_remakes', 'trusted_only']
|
|
31
|
+
type SukebeiCategories = Literal[
|
|
32
|
+
'art',
|
|
33
|
+
'art_anime',
|
|
34
|
+
'art_doujinshi',
|
|
35
|
+
'art_games',
|
|
36
|
+
'art_manga',
|
|
37
|
+
'art_pictures',
|
|
38
|
+
'real_life',
|
|
39
|
+
'real_life_pictures',
|
|
40
|
+
'real_life_videos',
|
|
41
|
+
]
|
|
42
|
+
type NyaaFunCategories = Literal[
|
|
43
|
+
'anime',
|
|
44
|
+
'anime_amv',
|
|
45
|
+
'anime_english',
|
|
46
|
+
'anime_non_english',
|
|
47
|
+
'anime_raw',
|
|
48
|
+
'audio',
|
|
49
|
+
'audio_lossless',
|
|
50
|
+
'audio_lossy',
|
|
51
|
+
'literature',
|
|
52
|
+
'literature_english',
|
|
53
|
+
'literature_non_english',
|
|
54
|
+
'literature_raw',
|
|
55
|
+
'live_action',
|
|
56
|
+
'live_action_english',
|
|
57
|
+
'live_action_idol_pv',
|
|
58
|
+
'live_action_non_english',
|
|
59
|
+
'live_action_raw',
|
|
60
|
+
'pictures',
|
|
61
|
+
'pictures_graphics',
|
|
62
|
+
'pictures_photos',
|
|
63
|
+
'software',
|
|
64
|
+
'software_apps',
|
|
65
|
+
'software_games',
|
|
66
|
+
]
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
nyapy/__init__.py,sha256=Vne0XdJw_CBviEjfe1y2cOI7N75OxeFZZeGHLVZ9Ed0,137
|
|
2
|
+
nyapy/client.py,sha256=JQH9Rln_9vuySjBOw9CRLJ-qtGM2f0Dhp22oq7qRYa4,386
|
|
3
|
+
nyapy/enums.py,sha256=Nw7iCWTvohcDqjIE16L-HDuXW5NSq3jZHFvwyQ9MdV4,1087
|
|
4
|
+
nyapy/nyaa.py,sha256=UFySVClr55NGfdolcLisUWATJ6XraQKRnhxkJ1IWTSE,3482
|
|
5
|
+
nyapy/nyaafun.py,sha256=rM-qWjox_9FCoitypRlo2apr14mdL7Ktd_8Tro2SzIQ,206
|
|
6
|
+
nyapy/sukebei.py,sha256=1wp5OS_ky0-OxSUEDO20jRbb492FIZPbiVRCSqrCUiM,206
|
|
7
|
+
nyapy/types/nyaa.py,sha256=jhCrNJ0OEN737yOd0CKY8gmPHtlcR1t-shmUZiGUNhw,1307
|
|
8
|
+
nyapy-0.1.5.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
9
|
+
nyapy-0.1.5.dist-info/METADATA,sha256=FNpjuOrxB7IKR_pMidXhjw-u9KciGDBycWe_X4MQVz8,338
|
|
10
|
+
nyapy-0.1.5.dist-info/RECORD,,
|
nyapy-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
nyapy/__init__.py,sha256=Q85n2fc9xfJPjy1nGcWjHo092HhL-wECjRH_YzNzAjo,208
|
|
2
|
-
nyapy/client.py,sha256=9LeOHoqLjgeKTxHDZApfSigDlOZG1qlN8yOB6ApCUzw,385
|
|
3
|
-
nyapy/enums.py,sha256=AEY7OpuW3I5tSQ1XuwGHPzv-DYQSYmPBJ6ChzS47pRo,1087
|
|
4
|
-
nyapy/nyaa.py,sha256=wfI2RtriFPspjP2veLVcsZJ3L6qkNx6cakkRJydKWeo,2924
|
|
5
|
-
nyapy/nyaafun.py,sha256=gWqSQ4yNiLrzs8flFibRAL4lEmy6A9EvHh1E981EzWU,715
|
|
6
|
-
nyapy/sukebei.py,sha256=FFkcJ47tR-aeapSUYQQYlDIZKRo0_srnpYYP_d-ylwk,715
|
|
7
|
-
nyapy/types/nyaa.py,sha256=zpnQdPRVL-GKoRQ25-YzxzGvSoFbSWESW8wQnKs3Hzw,520
|
|
8
|
-
nyapy-0.1.3.dist-info/WHEEL,sha256=fAguSjoiATBe7TNBkJwOjyL1Tt4wwiaQGtNtjRPNMQA,80
|
|
9
|
-
nyapy-0.1.3.dist-info/METADATA,sha256=azIVT5-Zr1uLVEsfcwZWgGFWvqLJ5AgPG1XcdZkIXkY,338
|
|
10
|
-
nyapy-0.1.3.dist-info/RECORD,,
|
|
File without changes
|