API reference

Downloader

Methods
class rud.Downloader(client_id, client_secret)

class to facilitate downloading of a user’s posts.

Parameters:
  • client_id (str) – client id to connect with.

  • client_secret (str) – client secret to authenticate with.

await auth(useragent)

verify our connection to reddit.

Parameters:

useragent (str) – the useragent that should be sent with out requests.

Returns:

return True when connection is successful, otherwise returns False.

Return type:

bool

await callback(post)

method called to determine if the given post should be downloaded. (intended to be overwritten, defaults to always True)

Parameters:

post (Post) – post that will be downloaded.

Returns:

when True, the post will be downloaded, when False the post will be skipped.

Return type:

bool

await download(post, name)

method that downloads the images related to a given post.

Parameters:
  • post (Post) – the post to be downloaded.

  • name (str) – name of the output directory.

async for ... in get_posts(name)

get all posts from a given user

Parameters:

name (str) – name of the user who’s posts will be fetched.

Yields:

Post – one of the user’s posts.

await run(name)

main loop of the default implementation.

Parameters:

name (str) – name of the user who’s posts will be downloaded.

Raises:

ConnectionFailed – reddit did not respond the way we expect.

Post

Attributes
class rud.Post(src, url, title, subreddit, _id)

class contaning information for a given post.

src

source url of the post. (typically i.redd.it)

Type:

str

url

permalink to the post. (reddit.com/r/...)

Type:

str

title

title of the post.

Type:

str

subreddit

name of the subreddit this post belongs to.

Type:

str

Errors

class rud.ConnectionFailed

raised when reddit responds in an unexpected way.

Parameters:

Exception (str) – description of the exception.