I accessed my Wordpress site's media library using the GetMediaLibrary() method of the python-wordpress-xmlrpc.media module. According to the documentation, this action should return a list of WordPressMedia instances. However, when I try to iterate over this list using a for-loop, I receive the error:
'GetMediaLibrary' object is not iterable
This is my code:
from wordpress_xmlrpc import Client, WordPressPost from wordpress_xmlrpc.methods import media, posts client = Client([*redacted*]) allwp_media = media.GetMediaLibrary() for media_file in allwp_media: if media_file.title == item.filename: attachment_url = media_file.link
Where 'item.filename' is a string. My Python/coding knowledge is kind of weak, so perhaps there is something fundamental about objects in Python that I do not understand, but I would assume that I should be able to iterate over this list.
Thanks in advance.