Documentation
¶
Index ¶
- Variables
- type AuthorFlairRichtext
- type CheckSubredditParams
- type Client
- type Data
- type DownloadStatusBroadcaster
- type GalleryData
- type GetPostsParam
- type Gildings
- type ImageDownloadReader
- type Images
- type Items
- type LinkFlairRichtext
- type Listing
- type MediaEmbed
- type MediaMetadata
- type NullDownloadStatusBroadcaster
- type Post
- func (post *Post) GetAuthor() string
- func (post *Post) GetAuthorURL() string
- func (post *Post) GetCreated() time.Time
- func (post *Post) GetID() string
- func (post *Post) GetImageAspectRatio() float64
- func (post *Post) GetImageFilename() string
- func (post *Post) GetImageRelativePath(device *models.Device) string
- func (post *Post) GetImageSize() (width, height int64)
- func (post *Post) GetImageTargetDir(cfg *config.Config, device *models.Device) string
- func (post *Post) GetImageTargetPath(cfg *config.Config, device *models.Device) string
- func (post *Post) GetImageURL() string
- func (post *Post) GetName() string
- func (post *Post) GetPermalink() string
- func (post *Post) GetPostCreated() int64
- func (post *Post) GetPostName() string
- func (post *Post) GetPostTitle() string
- func (post *Post) GetPostURL() string
- func (post *Post) GetSubreddit() string
- func (post *Post) GetThumbnailRelativePath() string
- func (post *Post) GetThumbnailSize() (width, height int64)
- func (post *Post) GetThumbnailTargetDir(cfg *config.Config) string
- func (post *Post) GetThumbnailTargetPath(cfg *config.Config) string
- func (post *Post) GetThumbnailURL() string
- func (post *Post) GetTitle() string
- func (post *Post) GetWindowsWallpaperImageRelativePath(device *models.Device) string
- func (post *Post) GetWindowsWallpaperImageTargetDir(cfg *config.Config, device *models.Device) string
- func (post *Post) GetWindowsWallpaperImageTargetPath(cfg *config.Config, device *models.Device) string
- func (post *Post) IsImagePost() bool
- func (post *Post) IsNSFW() bool
- func (post *Post) IsNSFWInt() int
- type PostData
- type PostImage
- type Preview
- type Reddit
- func (reddit *Reddit) CheckSubreddit(ctx context.Context, params CheckSubredditParams) (actual string, err error)
- func (reddit *Reddit) DownloadImage(ctx context.Context, post Post, broadcaster *broadcast.Relay[events.Event]) (image PostImage, err error)
- func (reddit *Reddit) DownloadThumbnail(ctx context.Context, post Post, broadcaster *broadcast.Relay[events.Event]) (image PostImage, err error)
- func (reddit *Reddit) GetPosts(ctx context.Context, params GetPostsParam) (posts Listing, err error)
- type Resolutions
- type SecureMediaEmbed
- type Source
- type SubredditType
- type ThumbnailPreview
- type Variants
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrIdleTimeoutReached = errors.New("download idle timeout reached")
Functions ¶
This section is empty.
Types ¶
type AuthorFlairRichtext ¶
type CheckSubredditParams ¶
type CheckSubredditParams struct {
Subreddit string `json:"subreddit"`
SubredditType SubredditType `json:"subreddit_type"`
}
type Client ¶
func NewRedditHTTPClient ¶
type DownloadStatusBroadcaster ¶
type DownloadStatusBroadcaster interface {
Broadcast(bmessage.ImageDownloadMessage)
}
type GalleryData ¶
type GalleryData struct {
Items []Items `json:"items"`
}
type GetPostsParam ¶
type GetPostsParam struct {
Subreddit string
Limit int
After string
SubredditType SubredditType
}
type ImageDownloadReader ¶
type ImageDownloadReader struct {
OnProgress func(downloaded int64, contentLength int64, err error)
OnClose func(downloaded int64, contentLength int64, closeErr error)
IdleTimeout time.Duration
IdleSpeedThreshold units.MetricBytes
// contains filtered or unexported fields
}
func (*ImageDownloadReader) Close ¶
func (idr *ImageDownloadReader) Close() error
func (*ImageDownloadReader) Read ¶
func (idr *ImageDownloadReader) Read(p []byte) (n int, err error)
func (*ImageDownloadReader) WrapHTTPResponse ¶
func (idr *ImageDownloadReader) WrapHTTPResponse(resp *http.Response) *http.Response
type Images ¶
type Images struct {
Source Source `json:"source"`
Resolutions []Resolutions `json:"resolutions"`
Variants Variants `json:"variants"`
ID string `json:"id"`
}
type LinkFlairRichtext ¶
type Listing ¶
func (*Listing) GetLastAfter ¶
GetLastAfter returns the last post namee for pagination.
Returns empty string if there is no more posts to look up.
func (*Listing) GetSubreddit ¶
type MediaEmbed ¶
type MediaEmbed struct{}
type MediaMetadata ¶
type MediaMetadata struct {
Status string `json:"status"`
Kind string `json:"e"`
Mimetype string `json:"m"`
ExtraThumbnails []ThumbnailPreview `json:"p"`
Thumbnail ThumbnailPreview `json:"s"`
ID string `json:"id"`
}
type NullDownloadStatusBroadcaster ¶
type NullDownloadStatusBroadcaster struct{}
func (NullDownloadStatusBroadcaster) Broadcast ¶
func (NullDownloadStatusBroadcaster) Broadcast(bmessage.ImageDownloadMessage)
type Post ¶
func (*Post) GetAuthorURL ¶
func (*Post) GetCreated ¶
func (*Post) GetImageAspectRatio ¶
func (*Post) GetImageFilename ¶
func (*Post) GetImageRelativePath ¶
func (*Post) GetImageSize ¶
func (*Post) GetImageTargetDir ¶
func (*Post) GetImageTargetPath ¶
func (*Post) GetImageURL ¶
func (*Post) GetPermalink ¶
func (*Post) GetPostCreated ¶
func (*Post) GetPostName ¶
func (*Post) GetPostTitle ¶
func (*Post) GetPostURL ¶
func (*Post) GetSubreddit ¶
func (*Post) GetThumbnailRelativePath ¶
func (*Post) GetThumbnailSize ¶
func (*Post) GetThumbnailTargetDir ¶
func (*Post) GetThumbnailTargetPath ¶
func (*Post) GetThumbnailURL ¶
func (*Post) GetWindowsWallpaperImageRelativePath ¶
func (*Post) GetWindowsWallpaperImageTargetDir ¶
func (*Post) GetWindowsWallpaperImageTargetPath ¶
func (*Post) IsImagePost ¶
type PostData ¶
type PostData struct {
ApprovedAtUtc any `json:"approved_at_utc"`
Subreddit string `json:"subreddit"`
Selftext string `json:"selftext"`
AuthorFullname string `json:"author_fullname"`
Saved bool `json:"saved"`
ModReasonTitle any `json:"mod_reason_title"`
Gilded int `json:"gilded"`
Clicked bool `json:"clicked"`
IsGallery bool `json:"is_gallery"`
Title string `json:"title"`
LinkFlairRichtext []LinkFlairRichtext `json:"link_flair_richtext"`
SubredditNamePrefixed string `json:"subreddit_name_prefixed"`
Hidden bool `json:"hidden"`
Pwls int `json:"pwls"`
LinkFlairCSSClass string `json:"link_flair_css_class"`
Downs int `json:"downs"`
ThumbnailHeight int64 `json:"thumbnail_height"`
TopAwardedType any `json:"top_awarded_type"`
HideScore bool `json:"hide_score"`
MediaMetadata map[string]MediaMetadata `json:"media_metadata"`
Name string `json:"name"`
Quarantine bool `json:"quarantine"`
LinkFlairTextColor any `json:"link_flair_text_color"`
UpvoteRatio float64 `json:"upvote_ratio"`
AuthorFlairBackgroundColor any `json:"author_flair_background_color"`
Ups int `json:"ups"`
Domain string `json:"domain"`
MediaEmbed MediaEmbed `json:"media_embed"`
ThumbnailWidth int64 `json:"thumbnail_width"`
AuthorFlairTemplateID string `json:"author_flair_template_id"`
IsOriginalContent bool `json:"is_original_content"`
UserReports []any `json:"user_reports"`
SecureMedia any `json:"secure_media"`
IsRedditMediaDomain bool `json:"is_reddit_media_domain"`
IsMeta bool `json:"is_meta"`
Category any `json:"category"`
SecureMediaEmbed SecureMediaEmbed `json:"secure_media_embed"`
GalleryData GalleryData `json:"gallery_data"`
LinkFlairText string `json:"link_flair_text"`
CanModPost bool `json:"can_mod_post"`
Score int `json:"score"`
ApprovedBy any `json:"approved_by"`
IsCreatedFromAdsUI bool `json:"is_created_from_ads_ui"`
AuthorPremium bool `json:"author_premium"`
Thumbnail string `json:"thumbnail"`
Edited any `json:"edited"`
AuthorFlairCSSClass string `json:"author_flair_css_class"`
AuthorFlairRichtext []AuthorFlairRichtext `json:"author_flair_richtext"`
Gildings Gildings `json:"gildings"`
ContentCategories any `json:"content_categories"`
IsSelf bool `json:"is_self"`
SubredditType string `json:"subreddit_type"`
Created float64 `json:"created"`
LinkFlairType string `json:"link_flair_type"`
Wls int `json:"wls"`
RemovedByCategory any `json:"removed_by_category"`
BannedBy any `json:"banned_by"`
AuthorFlairType string `json:"author_flair_type"`
TotalAwardsReceived int `json:"total_awards_received"`
AllowLiveComments bool `json:"allow_live_comments"`
SelftextHTML any `json:"selftext_html"`
Likes any `json:"likes"`
SuggestedSort any `json:"suggested_sort"`
BannedAtUtc any `json:"banned_at_utc"`
URLOverriddenByDest string `json:"url_overridden_by_dest"`
ViewCount any `json:"view_count"`
Archived bool `json:"archived"`
NoFollow bool `json:"no_follow"`
IsCrosspostable bool `json:"is_crosspostable"`
Pinned bool `json:"pinned"`
Over18 bool `json:"over_18"`
AllAwardings []any `json:"all_awardings"`
Awarders []any `json:"awarders"`
MediaOnly bool `json:"media_only"`
CanGild bool `json:"can_gild"`
Spoiler bool `json:"spoiler"`
Locked bool `json:"locked"`
AuthorFlairText string `json:"author_flair_text"`
TreatmentTags []any `json:"treatment_tags"`
Visited bool `json:"visited"`
RemovedBy any `json:"removed_by"`
ModNote any `json:"mod_note"`
Distinguished any `json:"distinguished"`
SubredditID string `json:"subreddit_id"`
AuthorIsBlocked bool `json:"author_is_blocked"`
ModReasonBy any `json:"mod_reason_by"`
NumReports any `json:"num_reports"`
RemovalReason any `json:"removal_reason"`
LinkFlairBackgroundColor any `json:"link_flair_background_color"`
ID string `json:"id"`
IsRobotIndexable bool `json:"is_robot_indexable"`
ReportReasons any `json:"report_reasons"`
Author string `json:"author"`
DiscussionType any `json:"discussion_type"`
NumComments int `json:"num_comments"`
SendReplies bool `json:"send_replies"`
WhitelistStatus string `json:"whitelist_status"`
ContestMode bool `json:"contest_mode"`
ModReports []any `json:"mod_reports"`
AuthorPatreonFlair bool `json:"author_patreon_flair"`
AuthorFlairTextColor string `json:"author_flair_text_color"`
Permalink string `json:"permalink"`
ParentWhitelistStatus string `json:"parent_whitelist_status"`
Stickied bool `json:"stickied"`
URL string `json:"url"`
SubredditSubscribers int `json:"subreddit_subscribers"`
CreatedUtc float64 `json:"created_utc"`
NumCrossposts int `json:"num_crossposts"`
Media any `json:"media"`
IsVideo bool `json:"is_video"`
PostHint string `json:"post_hint"`
Preview Preview `json:"preview"`
}
type PostImage ¶
type PostImage struct {
URL string
File io.ReadCloser
}
type Reddit ¶
func (*Reddit) CheckSubreddit ¶
func (reddit *Reddit) CheckSubreddit(ctx context.Context, params CheckSubredditParams) (actual string, err error)
CheckSubreddit checks a subreddit existence and will return error if subreddit not found.
The actual is the subreddit with proper capitalization if no error is returned.
func (*Reddit) DownloadImage ¶
func (reddit *Reddit) DownloadImage(ctx context.Context, post Post, broadcaster *broadcast.Relay[events.Event]) (image PostImage, err error)
DownloadImage downloades the image.
If downloading image or thumbnail fails
func (*Reddit) DownloadThumbnail ¶
type Resolutions ¶
type SecureMediaEmbed ¶
type SecureMediaEmbed struct{}
type SubredditType ¶
type SubredditType int
const ( SubredditTypeSub SubredditType = iota SubredditTypeUser )
func (SubredditType) Code ¶
func (s SubredditType) Code() string
func (*SubredditType) Parse ¶
func (su *SubredditType) Parse(s string) error
func (SubredditType) String ¶
func (s SubredditType) String() string
func (*SubredditType) UnmarshalJSON ¶
func (su *SubredditType) UnmarshalJSON(b []byte) error
type ThumbnailPreview ¶
Click to show internal directories.
Click to hide internal directories.