Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

3
How do I select various picture sizes from submission.media_metadata?
Post Flair (click to view more posts with a particular flair)
Post Body

I'm pulling pictures from a gallery post. The goal is selecting the url that has picture size 365 x 320

if I run this code I can see all available sizes.

post_id = 'wknagi'
submission = cli.submission(id=post_id)
image_dict = submission.media_metadata
for image_item in image_dict.values():
    print(image_dict)

but for the life of me can't figure out this part from this code which gets a 3500 X

https://preview.redd.it/kx5zq96wg6h91.png?width=3500&format=png&auto=webp&s=5638e227541012f0ee912349db27d368b369d411

This is the code I'm currently working with

post_id = 'wknagi'
post = cli.submission(id=post_id)
gallery = []
ids = [i['media_id'] for i in post.gallery_data['items']]
for id in ids:
    url = post.media_metadata[id]['p'][0]['u']
    url = url.split("?")[0].replace("preview", "i")
    gallery.append(url)

for img in gallery:
    print(img)

I assume the variable for pic size is the ['p'][0]['u'] but I just can't seem to get 365 x 320 size.

Help! lol

Author
Account Strength
100%
Account Age
3 years
Verified Email
Yes
Verified Flair
No
Total Karma
12,468
Link Karma
8,164
Comment Karma
1,681
Profile updated: 1 week ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
2 years ago