@@ -12,6 +12,36 @@ class ImageManager(BaseManager['Image', 'ImageResponse']):
1212 This is a factory object for creating image objects. Its the
1313 main interface for fetching image related data.
1414 """
15+ async def get (self , name : str ) -> Optional ['Image' ]:
16+ """
17+ Gets image data by their name, and returns it as an image object.
18+ Example of an image name: https://img.rec.net/>43ixtpl65wc9fc6ff4vsyrzoo.jpg<
19+ Only accepts image names of public RecNet posts.
20+ Returns nothing if the image doesn't exist or is private.
21+
22+ :param name: The name of the image.
23+ :return: An image object representing the data or nothing if not found.
24+ """
25+ data : 'Response[List[ImageResponse]]' = await self .rec_net .api .images .v4 .bulk .make_request ('post' , body = {'Names' : name })
26+ if data .data : return self .create_dataclass (id , data .data [0 ])
27+ return None
28+
29+
30+ async def get_many (self , names : List [str ]) -> Optional ['Image' ]:
31+ """
32+ Gets a list of images by a list of image names, and returns
33+ a list of image object.
34+ Example of an image name: https://img.rec.net/>43ixtpl65wc9fc6ff4vsyrzoo.jpg<
35+ Only accepts image names of public RecNet posts.
36+ Images that couldn't be found will be silently ignored.
37+
38+ :param name: The name of the image.
39+ :return: A list of image objects.
40+ """
41+ data : 'Response[List[ImageResponse]]' = await self .rec_net .api .images .v4 .bulk .make_request ('post' , body = {'Names' : names })
42+ return self .create_from_data_list (data .data )
43+
44+
1545 async def fetch (self , id : int ) -> Optional ['Image' ]:
1646 """
1747 Gets image data by their id, and returns it as an image object.
@@ -23,7 +53,8 @@ async def fetch(self, id: int) -> Optional['Image']:
2353 data : 'Response[ImageResponse]' = await self .rec_net .api .images .v4 (id ).make_request ('get' )
2454 if data .data : return self .create_dataclass (id , data .data )
2555 return None
26-
56+
57+
2758 async def fetch_many (self , ids : List [int ]) -> List ['Image' ]:
2859 """
2960 Gets a list of images by a list of image ids, and returns
0 commit comments