news

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const HITS_PER_PAGE = 100
View Source
const MAX_PAGES = 3
View Source
const MAX_RESULTS = 100

Variables

View Source
var (
	ClientID     = os.Getenv("REDDIT_CLIENT_ID")
	ClientSecret = os.Getenv("REDDIT_CLIENT_SECRET")
	Username     = os.Getenv("REDDIT_USERNAME")
	Password     = os.Getenv("REDDIT_PASSWORD")
	UserAgent    = os.Getenv("REDDIT_USER_AGENT")
)

Replace with your own client ID and client secret

View Source
var (
	YTApiKey = os.Getenv("YOUTUBE_API_KEY")
)

Functions

This section is empty.

Types

type Article

type Article struct {
	Title        string
	CreatedAt    string
	Points       int
	NumComments  int
	URL          string
	HNURL        string
	MatchedWords []string
}

func FetchHackerNewsArticles

func FetchHackerNewsArticles(query string, minPoints int) ([]Article, error)

type ArticleData

type ArticleData struct {
	Title       string `json:"title"`
	Created     string `json:"created"`
	Ups         int    `json:"ups"`
	NumComments int    `json:"num_comments"`
	Url         string `json:"url"`
}

func FetchRedditPosts

func FetchRedditPosts(query string, minUpvotes int) ([]ArticleData, error)

type HNHit

type HNHit struct {
	Title           string          `json:"title"`
	CreatedAt       string          `json:"created_at"`
	Points          int             `json:"points"`
	NumComments     int             `json:"num_comments"`
	URL             string          `json:"url"`
	StoryURL        string          `json:"story_url"`
	ObjectID        string          `json:"objectID"`
	HighlightResult HighlightResult `json:"_highlightResult"`
}

type HNResponse

type HNResponse struct {
	Hits    []HNHit `json:"hits"`
	NBPages int     `json:"nbPages"`
}

type HighlightResult

type HighlightResult struct {
	Title struct {
		Value        string   `json:"value"`
		MatchedWords []string `json:"matchedWords"`
	} `json:"title"`
}

type PostData

type PostData struct {
	Title       string  `json:"title"`
	Created     float64 `json:"created"`
	Ups         int     `json:"ups"`
	NumComments int     `json:"num_comments"`
	Permalink   string  `json:"permalink"`
}

type RedditResponse

type RedditResponse struct {
	Data struct {
		Children []struct {
			Data PostData `json:"data"`
		} `json:"children"`
	} `json:"data"`
}

type TokenResponse

type TokenResponse struct {
	AccessToken string `json:"access_token"`
}

type YTVideoMetadata

type YTVideoMetadata struct {
	VideoID     string `json:"video_id"`
	Title       string `json:"title"`
	ViewCount   uint64 `json:"view_count"`
	PublishedAt string `json:"published_at"`
	VideoURL    string `json:"video_url"`
}

func FetchYouTubeVideos

func FetchYouTubeVideos(query string, limit int) ([]YTVideoMetadata, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL