simple-rule34 0.1.5.1__tar.gz → 0.1.5.4__tar.gz

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.
Files changed (23) hide show
  1. simple_rule34-0.1.5.4/PKG-INFO +55 -0
  2. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/pyproject.toml +3 -3
  3. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/aio/ARule34.py +13 -6
  4. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/aio/types.py +4 -2
  5. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/types.py +4 -4
  6. simple_rule34-0.1.5.4/src/simple_rule34.egg-info/PKG-INFO +55 -0
  7. simple_rule34-0.1.5.4/tests/test.py +62 -0
  8. simple_rule34-0.1.5.1/PKG-INFO +0 -16
  9. simple_rule34-0.1.5.1/src/simple_rule34.egg-info/PKG-INFO +0 -16
  10. simple_rule34-0.1.5.1/tests/test.py +0 -20
  11. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/LICENSE +0 -0
  12. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/README.md +0 -0
  13. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/setup.cfg +0 -0
  14. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/Rule34.py +0 -0
  15. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/__init__.py +0 -0
  16. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/aio/utils.py +0 -0
  17. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/exceptions.py +0 -0
  18. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/setup.py +0 -0
  19. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/SimpleRule34/utils.py +0 -0
  20. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/simple_rule34.egg-info/SOURCES.txt +0 -0
  21. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/simple_rule34.egg-info/dependency_links.txt +0 -0
  22. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/simple_rule34.egg-info/requires.txt +0 -0
  23. {simple_rule34-0.1.5.1 → simple_rule34-0.1.5.4}/src/simple_rule34.egg-info/top_level.txt +0 -0
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.1
2
+ Name: simple_rule34
3
+ Version: 0.1.5.4
4
+ Summary: Simple api wrapper of rule34.xxx for python with asynchronous support
5
+ Author-email: StarMan12 <author@example.com>
6
+ Project-URL: Homepage, https://github.com/SyperAlexKomp/simple-rule34-api
7
+ Project-URL: Bug Tracker, https://github.com/SyperAlexKomp/simple-rule34-api/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: aiohttp==3.8.4
15
+ Requires-Dist: aiosignal==1.3.1
16
+ Requires-Dist: alabaster==0.7.13
17
+ Requires-Dist: async-timeout==4.0.2
18
+ Requires-Dist: attrs==23.1.0
19
+ Requires-Dist: Babel==2.9.1
20
+ Requires-Dist: build==0.10.0
21
+ Requires-Dist: certifi==2023.5.7
22
+ Requires-Dist: charset-normalizer==3.2.0
23
+ Requires-Dist: colorama==0.4.6
24
+ Requires-Dist: docopt==0.6.2
25
+ Requires-Dist: docutils==0.18.1
26
+ Requires-Dist: frozenlist==1.4.0
27
+ Requires-Dist: idna==3.4
28
+ Requires-Dist: imagesize==1.4.1
29
+ Requires-Dist: importlib-metadata==6.8.0
30
+ Requires-Dist: Jinja2==3.1.2
31
+ Requires-Dist: MarkupSafe==2.1.3
32
+ Requires-Dist: multidict==6.0.4
33
+ Requires-Dist: packaging==23.1
34
+ Requires-Dist: pipreqs==0.4.13
35
+ Requires-Dist: Pygments==2.15.1
36
+ Requires-Dist: pyproject_hooks==1.0.0
37
+ Requires-Dist: requests==2.31.0
38
+ Requires-Dist: snowballstemmer==2.2.0
39
+ Requires-Dist: Sphinx==6.2.1
40
+ Requires-Dist: sphinx-rtd-theme==1.2.2
41
+ Requires-Dist: sphinxcontrib-applehelp==1.0.4
42
+ Requires-Dist: sphinxcontrib-devhelp==1.0.2
43
+ Requires-Dist: sphinxcontrib-htmlhelp==2.0.1
44
+ Requires-Dist: sphinxcontrib-jquery==4.1
45
+ Requires-Dist: sphinxcontrib-jsmath==1.0.1
46
+ Requires-Dist: sphinxcontrib-qthelp==1.0.3
47
+ Requires-Dist: sphinxcontrib-serializinghtml==1.1.5
48
+ Requires-Dist: tomli==2.0.1
49
+ Requires-Dist: urllib3==2.0.3
50
+ Requires-Dist: yarg==0.1.9
51
+ Requires-Dist: yarl==1.9.2
52
+ Requires-Dist: zipp==3.16.2
53
+
54
+ # rule34-simple-api
55
+ Simple api wrapper of rule34.xxx for python with asynchronous support
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "simple_rule34"
7
- version = "0.1.5.1"
7
+ version = "0.1.5.4"
8
8
  authors = [
9
9
  { name="StarMan12", email="author@example.com" },
10
10
  ]
@@ -57,5 +57,5 @@ dependencies = ['aiohttp==3.8.4',
57
57
  'zipp==3.16.2']
58
58
 
59
59
  [project.urls]
60
- "Homepage" = "https://github.com/Loshok229/rule34-simple-api"
61
- "Bug Tracker" = "https://github.com/Loshok229/rule34-simple-api/issues"
60
+ "Homepage" = "https://github.com/SyperAlexKomp/simple-rule34-api"
61
+ "Bug Tracker" = "https://github.com/SyperAlexKomp/simple-rule34-api/issues"
@@ -47,8 +47,10 @@ async def parse_result(post_element):
47
47
  return main_post, sample_post, preview_post
48
48
 
49
49
  class Rule34Api:
50
+ def __init__(self):
51
+ self.header = {'User-Agent': 'rule34-simple-api 0.1.5.3 (Request)'}
50
52
  async def get_post_count(self, tags: str = '') -> int:
51
- async with aiohttp.ClientSession() as session:
53
+ async with aiohttp.ClientSession(headers=self.header) as session:
52
54
  async with session.get(f'https://api.rule34.xxx/index.php?'
53
55
  f'page=dapi&s=post&q=index&tags={tags}') as response:
54
56
  xml_data = await response.text()
@@ -60,7 +62,7 @@ class Rule34Api:
60
62
  async def get_post(self, id: int):
61
63
  st = time.time()
62
64
 
63
- async with aiohttp.ClientSession() as session:
65
+ async with aiohttp.ClientSession(headers=self.header) as session:
64
66
  async with session.get(f'https://api.rule34.xxx/index.php?'
65
67
  f'page=dapi&s=post&q=index&id={id}') as response:
66
68
  xml_data = await response.text()
@@ -113,14 +115,19 @@ class Rule34Api:
113
115
  st = time.time()
114
116
 
115
117
  request_count = 1
118
+ true_count = count*20
116
119
 
117
120
  post_list = []
118
121
 
119
- if count > 1000:
120
- request_count = count // 1000
122
+ if true_count > 1000:
123
+ request_count = true_count // 1000
124
+
125
+ post_count = await self.get_post_count(tags)
126
+ page_id = int(random.randint(0, int(post_count / true_count)) / 8) if post_count >= true_count else 0
121
127
 
122
128
  for pid in range(request_count + 1):
123
- post_list += await self.get_post_list(tags=tags, forbidden_tags=forbidden_tags)
129
+ post_list += await self.get_post_list(tags=tags, forbidden_tags=forbidden_tags,
130
+ page_id=page_id, limit=true_count if true_count <= 1000 else 1000)
124
131
 
125
132
  getted = []
126
133
 
@@ -136,7 +143,7 @@ class Rule34Api:
136
143
 
137
144
  async def get_post_list(self, limit: int = 1000, page_id: int = 0, tags: str = '', forbidden_tags: list[str] = [])\
138
145
  -> list[Rule34PostData]:
139
- async with aiohttp.ClientSession() as session:
146
+ async with aiohttp.ClientSession(headers=self.header) as session:
140
147
  if limit > 1000:
141
148
  raise ToBigRequestException(f"The max size of request is 1000 when you tried to request {limit}")
142
149
 
@@ -1,4 +1,6 @@
1
1
  import typing
2
+
3
+ import aiofiles
2
4
  import aiohttp
3
5
  import os
4
6
  import datetime
@@ -34,8 +36,8 @@ class Rule34Post:
34
36
 
35
37
  file_name = os.path.basename(self.url)
36
38
  save_path = os.path.join(path, file_name)
37
- with open(save_path, 'wb') as file:
38
- file.write(await response.read())
39
+ with aiofiles.open(save_path, 'wb') as file:
40
+ await file.write(await response.read())
39
41
 
40
42
  return save_path
41
43
  else:
@@ -6,9 +6,9 @@ from .utils import get_file_type, get_file_size
6
6
 
7
7
 
8
8
  class Rule34Post:
9
- def __init__(self, height: int, width: int, url: str, id: int, session: requests.Session):
9
+ def __init__(self, height: int, width: int, url: str, id: int):
10
10
  self.path = r'./rule34_download'
11
- self.s = session
11
+ self.s = requests.Session()
12
12
 
13
13
  self.height = height
14
14
  self.width = width
@@ -49,8 +49,8 @@ class Rule34Post:
49
49
  class Rule34MainPost(Rule34Post):
50
50
  def __init__(self, score: int, rating: str, creator_id: int, tags: str, has_children: bool,
51
51
  created_date: datetime.datetime, status: str, source: str, has_notes: bool, has_comments: bool,
52
- height: int, width: int, url: str, id: int, s):
53
- super().__init__(height, width, url, id, s)
52
+ height: int, width: int, url: str, id: int):
53
+ super().__init__(height, width, url, id)
54
54
  self.score = score
55
55
  self.rating = rating
56
56
  self.creator_id = creator_id
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.1
2
+ Name: simple_rule34
3
+ Version: 0.1.5.4
4
+ Summary: Simple api wrapper of rule34.xxx for python with asynchronous support
5
+ Author-email: StarMan12 <author@example.com>
6
+ Project-URL: Homepage, https://github.com/SyperAlexKomp/simple-rule34-api
7
+ Project-URL: Bug Tracker, https://github.com/SyperAlexKomp/simple-rule34-api/issues
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Requires-Python: >=3.9
12
+ Description-Content-Type: text/markdown
13
+ License-File: LICENSE
14
+ Requires-Dist: aiohttp==3.8.4
15
+ Requires-Dist: aiosignal==1.3.1
16
+ Requires-Dist: alabaster==0.7.13
17
+ Requires-Dist: async-timeout==4.0.2
18
+ Requires-Dist: attrs==23.1.0
19
+ Requires-Dist: Babel==2.9.1
20
+ Requires-Dist: build==0.10.0
21
+ Requires-Dist: certifi==2023.5.7
22
+ Requires-Dist: charset-normalizer==3.2.0
23
+ Requires-Dist: colorama==0.4.6
24
+ Requires-Dist: docopt==0.6.2
25
+ Requires-Dist: docutils==0.18.1
26
+ Requires-Dist: frozenlist==1.4.0
27
+ Requires-Dist: idna==3.4
28
+ Requires-Dist: imagesize==1.4.1
29
+ Requires-Dist: importlib-metadata==6.8.0
30
+ Requires-Dist: Jinja2==3.1.2
31
+ Requires-Dist: MarkupSafe==2.1.3
32
+ Requires-Dist: multidict==6.0.4
33
+ Requires-Dist: packaging==23.1
34
+ Requires-Dist: pipreqs==0.4.13
35
+ Requires-Dist: Pygments==2.15.1
36
+ Requires-Dist: pyproject_hooks==1.0.0
37
+ Requires-Dist: requests==2.31.0
38
+ Requires-Dist: snowballstemmer==2.2.0
39
+ Requires-Dist: Sphinx==6.2.1
40
+ Requires-Dist: sphinx-rtd-theme==1.2.2
41
+ Requires-Dist: sphinxcontrib-applehelp==1.0.4
42
+ Requires-Dist: sphinxcontrib-devhelp==1.0.2
43
+ Requires-Dist: sphinxcontrib-htmlhelp==2.0.1
44
+ Requires-Dist: sphinxcontrib-jquery==4.1
45
+ Requires-Dist: sphinxcontrib-jsmath==1.0.1
46
+ Requires-Dist: sphinxcontrib-qthelp==1.0.3
47
+ Requires-Dist: sphinxcontrib-serializinghtml==1.1.5
48
+ Requires-Dist: tomli==2.0.1
49
+ Requires-Dist: urllib3==2.0.3
50
+ Requires-Dist: yarg==0.1.9
51
+ Requires-Dist: yarl==1.9.2
52
+ Requires-Dist: zipp==3.16.2
53
+
54
+ # rule34-simple-api
55
+ Simple api wrapper of rule34.xxx for python with asynchronous support
@@ -0,0 +1,62 @@
1
+ from SimpleRule34.src.SimpleRule34.aio.ARule34 import Rule34Api
2
+ from SimpleRule34.src.SimpleRule34 import Rule34Api
3
+ import asyncio
4
+
5
+
6
+ async def main1():
7
+
8
+ r = Rule34Api()
9
+ print("=====ALL 10=====")
10
+ lis = await r.get_post_list(tags='', limit=10)
11
+
12
+ for x in lis:
13
+ print(x)
14
+
15
+ print("=====FIRST 5=====")
16
+ lis = await r.get_post_list(tags='brawl_stars', limit=5)
17
+
18
+ for x in lis:
19
+ print(x)
20
+
21
+ print("=====SECOND 5=====")
22
+ lis = await r.get_post_list(tags='brawl_stars', limit=5, page_id=1)
23
+
24
+ for x in lis:
25
+ print(x)
26
+
27
+ print("=====EDITED=====")
28
+ post_list_ = await r.get_post_list(tags='brawl_stars', limit=100, page_id=0,
29
+ forbidden_tags=['male'])
30
+
31
+ chunk_size = 5
32
+ for i in range(0, len(post_list_), chunk_size):
33
+ chunk = post_list_[i:i + chunk_size]
34
+ print(f"=====CHUNK {i}=====")
35
+ for x in chunk:
36
+ print(x)
37
+ i = 4
38
+ chunk = post_list_[i:i + chunk_size]
39
+ print(f"=====CHUNK {i}=====")
40
+ for x in chunk:
41
+ print(x)
42
+
43
+
44
+ print("=====TEST=====")
45
+ original_list = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20]
46
+
47
+ chunk_size = 5
48
+ for i in range(0, len(original_list), chunk_size):
49
+ print(i)
50
+ chunk = original_list[i:i + chunk_size]
51
+ print(chunk)
52
+
53
+ return
54
+
55
+
56
+ async def main():
57
+ r = Rule34Api()
58
+ p = r.get_post(213)
59
+ print(p)
60
+
61
+ if __name__ == '__main__':
62
+ asyncio.run(main())
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: simple_rule34
3
- Version: 0.1.5.1
4
- Summary: Simple api wrapper of rule34.xxx for python with asynchronous support
5
- Author-email: StarMan12 <author@example.com>
6
- Project-URL: Homepage, https://github.com/Loshok229/rule34-simple-api
7
- Project-URL: Bug Tracker, https://github.com/Loshok229/rule34-simple-api/issues
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
-
15
- # rule34-simple-api
16
- Simple api wrapper of rule34.xxx for python with asynchronous support
@@ -1,16 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: simple-rule34
3
- Version: 0.1.5.1
4
- Summary: Simple api wrapper of rule34.xxx for python with asynchronous support
5
- Author-email: StarMan12 <author@example.com>
6
- Project-URL: Homepage, https://github.com/Loshok229/rule34-simple-api
7
- Project-URL: Bug Tracker, https://github.com/Loshok229/rule34-simple-api/issues
8
- Classifier: Programming Language :: Python :: 3
9
- Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Operating System :: OS Independent
11
- Requires-Python: >=3.9
12
- Description-Content-Type: text/markdown
13
- License-File: LICENSE
14
-
15
- # rule34-simple-api
16
- Simple api wrapper of rule34.xxx for python with asynchronous support
@@ -1,20 +0,0 @@
1
- from SimpleRule34.src.SimpleRule34.aio.ARule34 import Rule34Api
2
- import asyncio
3
-
4
-
5
- async def main():
6
-
7
- r = Rule34Api()
8
-
9
- lis = await r.get_post_list(tags='1girl', limit=5, forbidden_tags=['male'])
10
-
11
- print(lis)
12
-
13
- for x in lis:
14
- print(x)
15
-
16
- return
17
-
18
-
19
- if __name__ == '__main__':
20
- asyncio.run(main())
File without changes