mirror of
https://github.com/instaloader/instaloader.git
synced 2024-11-09 03:42:31 +01:00
Post properties is_sponsored and sponsor_users
This allows to access the Paid Partnership With metadata of a Post. Closes #295.
This commit is contained in:
parent
9c2e7c70ac
commit
e725ca2640
@ -413,6 +413,30 @@ class Post:
|
|||||||
lambda d: d['data']['shortcode_media']['edge_liked_by'],
|
lambda d: d['data']['shortcode_media']['edge_liked_by'],
|
||||||
self._rhx_gis))
|
self._rhx_gis))
|
||||||
|
|
||||||
|
@property
|
||||||
|
def is_sponsored(self) -> bool:
|
||||||
|
"""
|
||||||
|
Whether Post is a sponsored post, equivalent to non-empty :meth:`Post.sponsor_users`.
|
||||||
|
|
||||||
|
.. versionadded:: 4.4
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
sponsor_edges = self._field('edge_media_to_sponsor_user', 'edges')
|
||||||
|
except KeyError:
|
||||||
|
return False
|
||||||
|
return bool(sponsor_edges)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def sponsor_users(self) -> List['Profile']:
|
||||||
|
"""
|
||||||
|
The Post's sponsors.
|
||||||
|
|
||||||
|
.. versionadded:: 4.4
|
||||||
|
"""
|
||||||
|
return ([] if not self.is_sponsored else
|
||||||
|
[Profile(self._context, edge['node']['sponsor']) for edge in
|
||||||
|
self._field('edge_media_to_sponsor_user', 'edges')])
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def location(self) -> Optional[PostLocation]:
|
def location(self) -> Optional[PostLocation]:
|
||||||
"""
|
"""
|
||||||
|
Loading…
Reference in New Issue
Block a user