Pythörhead

116 readers
3 users here now

A community to post announcements, updates, integrations and even memes about the first & best Lemmy Python Library

founded 1 year ago
MODERATORS
26
27
28
29
30
31
32
33
4
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

Hi, I'm looking for a bit of help getting a list of communities the authenticated user is subscribed to.

I'm getting the list like this:

communities = lemmy.community.list(type_=ListingType.Subscribed)

However despite specifying the _type as ListingType.Subscribed, I'm still getting back a list that includes items with the value:

'subscribed': 'NotSubscribed'

It's very possible that I'm interpreting how this works wrong, so if someone has any tips for doing this I'd be very appreciate.

Thanks!

34
3
submitted 1 year ago* (last edited 1 year ago) by [email protected] to c/[email protected]
 
 

Hi,

Not sure if its ok to ask questions in here...?

I'm very much a beginner at python but I've managed to get my python script set up to post to a community. The only issue is that I can only post to communities on my own instance.

I feel like I'm missing something obvious related to community_id or community_name.

from pythorhead import Lemmy

lemmy = Lemmy('https://lemmy.fmhy.ml')
lemmy.log_in('username', 'password')
community_id = lemmy.discover_community('test_video_bot')
lemmy.post.create(community_id, url='https://www.youtube.com/watch?v=riuGVkq2DKw', name='Football Highlights')

Above is my current code which works but if I remove the 'test_video_bot' community on my instance and replace it with 'lemmy.world/c/football' or 'lemmy.fmhy.ml/c/[email protected]' I get two errors:


Error encountered while Request.GET: {"error":"couldnt_find_community"}
Error encountered while Request.POST: Json deserialize error: invalid type: null, expected i32 at line 1 column 21

It's as if it's only searching my own instance and I'm not sure how to tell it to look elsewhere or if it's not possible yet to do this on pythorhead.

Thanks for any suggestions you can give to help with this issue.

35
36
37
38
 
 

The CI/CD pipeline for Pythorhead has been adjusted make a post in [email protected] whenever a new release is published.

39
40