wikipedia

package
v0.0.0-...-a0d54a6 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2021 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package wikipedia is a simple client driver for the wikipedia HTTP api.

Index

Constants

This section is empty.

Variables

View Source
var Projects = []string{
	"en",
	"fr",
	"es",
	"de",
	"ru",
	"ja",
	"nl",
	"it",
	"sv",
	"pl",
	"vi",
	"pt",
	"ar",
	"zh",
	"uk",
	"ro",
	"bg",
	"th",
	"fa",
}

Functions

func IsProject

func IsProject(project string) bool

Types

type Article

type Article struct {
	Project string
	Article string
	Summary ArticleSummary
	Media   []ArticleMediaItem
}

func (*Article) GetImageURL

func (a *Article) GetImageURL() (string, bool)

type ArticleMediaItem

type ArticleMediaItem struct {
	SectionID int              `json:"section_id"`
	Type      string           `json:"type"`
	Titles    ArticleTitles    `json:"titles"`
	Thumbnail ImageMetadata    `json:"thumbnail"`
	Original  ImageMetadata    `json:"original"`
	SrcSet    []SrcSetMetadata `json:"srcset"`
}

type ArticleSummary

type ArticleSummary struct {
	Type         string `json:"type"`
	Title        string `json:"title"`
	DisplayTitle string `json:"display_title"`
	Titles       ArticleTitles
	WikibaseItem string      `json:"wikibase_item"`
	Lang         string      `json:"lang"`
	Timestamp    time.Time   `json:"time"`
	Extract      string      `json:"extract"`
	ExtractHTML  string      `json:"extract_html"`
	ContentURLs  ContentURLs `json:"content_urls"`
}

type ArticleTitles

type ArticleTitles struct {
	Canonical  string `json:"canonical"`
	Normalized string `json:"normalized"`
	Display    string `json:"display"`
}

type ArticleURLs

type ArticleURLs struct {
	Page string `json:"page"`
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client reads from wikipedia.

func New

func New() *Client

func (*Client) FetchTopArticles

func (c *Client) FetchTopArticles(ctx context.Context, project string) (*TopPageviews, error)

func (*Client) GetArticle

func (c *Client) GetArticle(ctx context.Context, project, articleName string) (Article, error)

func (*Client) GetArticleMedia

func (c *Client) GetArticleMedia(
	ctx context.Context, project, articleName string,
) ([]ArticleMediaItem, error)

func (*Client) GetArticleSummary

func (c *Client) GetArticleSummary(
	ctx context.Context, project string, articleName string,
) (summary ArticleSummary, err error)

type ContentURLs

type ContentURLs struct {
	Desktop ArticleURLs `json:"desktop"`
	Mobile  ArticleURLs `json:"mobile"`
}

type ImageMetadata

type ImageMetadata struct {
	Source string `json:"source"`
	Width  int    `json:"width"`
	Height int    `json:"height"`
	Mime   string `json:"mime"`
}

type PageViewEntry

type PageViewEntry struct {
	Project string `json:"project"`
	Article string `json:"article`
}

type Scale

type Scale string

type SrcSetMetadata

type SrcSetMetadata struct {
	Src   string `json:"src"`
	Scale Scale  `json:"scale"`
}

type TopPageviews

type TopPageviews struct {
	Project  string `json:"project"`
	Access   string `json:"access"`
	Year     string `json:"year"`
	Month    string `json:"month"`
	Day      string `json:"day"`
	Articles []TopPageviewsArticle
}

type TopPageviewsArticle

type TopPageviewsArticle struct {
	Article string `json:"article"`
	Views   int    `json:"views"`
	Rank    int    `json:"rank"`
}

Jump to

Keyboard shortcuts

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