extractor

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func JSONLD

func JSONLD(URL string, htmlContent string) ([]map[string]interface{}, []error)

func ParseOpenGraph

func ParseOpenGraph(URL string, htmlContent string) (interface{}, []error)

func ParseXCards

func ParseXCards(URL string, htmlContent string) (interface{}, []error)

Types

type Article

type Article struct {
	PublishedTime  time.Time `json:"article:published_time,omitempty"`
	ModifiedTime   time.Time `json:"article:modified_time,omitempty"`
	ExpirationTime time.Time `json:"article:expiration_time,omitempty"`
	Author         []string  `json:"article:author,omitempty"`
	Section        string    `json:"article:section,omitempty"`
	Tag            []string  `json:"article:tag,omitempty"`
}

Article represents article-specific metadata

type Book

type Book struct {
	Author      []string  `json:"book:author,omitempty"`
	ISBN        string    `json:"book:isbn,omitempty"`
	ReleaseDate time.Time `json:"book:release_date,omitempty"`
	Tag         []string  `json:"book:tag,omitempty"`
}

Book represents book-specific metadata

type MicrodataItem

type MicrodataItem struct {
	Type       string                 `json:"type,omitempty"`
	ID         *string                `json:"id,omitempty"`
	Properties map[string]interface{} `json:"properties,omitempty"`
}

func W3CMicrodata

func W3CMicrodata(URL string, htmlContent string) ([]MicrodataItem, []error)

type Music

type Music struct {
	Duration    int         `json:"music:duration,omitempty"`
	Album       string      `json:"music:album,omitempty"`
	AlbumDisc   int         `json:"music:album:disc,omitempty"`
	AlbumTrack  int         `json:"music:album:track,omitempty"`
	Musician    []string    `json:"music:musician,omitempty"`
	Song        []MusicSong `json:"music:song,omitempty"`
	Creator     []string    `json:"music:creator,omitempty"`
	ReleaseDate string      `json:"music:release_date,omitempty"`
}

Music represents music-specific metadata

type MusicSong

type MusicSong struct {
	URL   string `json:"url,omitempty"`
	Disc  int    `json:"disc,omitempty"`
	Track int    `json:"track,omitempty"`
}

type OpenGraph

type OpenGraph struct {
	// Basic metadata
	Type  string `json:"og:type"`
	Title string `json:"og:title"`
	URL   string `json:"og:url"`

	// Optional metadata
	Description     string   `json:"og:description,omitempty"`
	Determiner      string   `json:"og:determiner,omitempty"`
	Locale          string   `json:"og:locale,omitempty"`
	LocaleAlternate []string `json:"og:locale:alternate,omitempty"`
	SiteName        string   `json:"og:site_name,omitempty"`

	// Media
	OpenGraphImage []OpenGraphImage `json:"og:image,omitempty"`
	OpenGraphVideo []OpenGraphVideo `json:"og:video,omitempty"`
	OpenGraphAudio []OpenGraphAudio `json:"og:audio,omitempty"`

	// Music specific
	Music *Music `json:"music,omitempty"`

	// Video specific
	Video *Video `json:"video,omitempty"`

	// Article specific
	Article *Article `json:"article,omitempty"`

	// Book specific
	Book *Book `json:"book,omitempty"`

	// Profile specific
	Profile *Profile `json:"profile,omitempty"`
}

func NewOpenGraph

func NewOpenGraph() *OpenGraph

NewOpenGraph creates a new OpenGraph instance with basic initialization

type OpenGraphAudio

type OpenGraphAudio struct {
	URL       string `json:"og:audio"`
	SecureURL string `json:"og:audio:secure_url,omitempty"`
	Type      string `json:"og:audio:type,omitempty"`
}

OpenGraphAudio represents OpenGraph audio object

type OpenGraphImage

type OpenGraphImage struct {
	URL       string `json:"og:image"`
	SecureURL string `json:"og:image:secure_url,omitempty"`
	Type      string `json:"og:image:type,omitempty"`
	Width     int    `json:"og:image:width,omitempty"`
	Height    int    `json:"og:image:height,omitempty"`
	Alt       string `json:"og:image:alt,omitempty"`
}

OpenGraphImage represents OpenGraph image object

type OpenGraphVideo

type OpenGraphVideo struct {
	URL       string `json:"og:video"`
	SecureURL string `json:"og:video:secure_url,omitempty"`
	Type      string `json:"og:video:type,omitempty"`
	Width     int    `json:"og:video:width,omitempty"`
	Height    int    `json:"og:video:height,omitempty"`
}

OpenGraphVideo represents OpenGraph video object

type Profile

type Profile struct {
	FirstName string `json:"profile:first_name,omitempty"`
	LastName  string `json:"profile:last_name,omitempty"`
	Username  string `json:"profile:username,omitempty"`
	Gender    string `json:"profile:gender,omitempty"`
}

Profile represents profile-specific metadata

type Video

type Video struct {
	Duration    int          `json:"video:duration,omitempty"`
	Actor       []VideoActor `json:"video:actor,omitempty"`
	Director    []string     `json:"video:director,omitempty"`
	Writer      []string     `json:"video:writer,omitempty"`
	ReleaseDate time.Time    `json:"video:release_date,omitempty"`
	Tag         []string     `json:"video:tag,omitempty"`
	Series      string       `json:"video:series,omitempty"`
}

type VideoActor

type VideoActor struct {
	URL  string `json:"url,omitempty"`
	Role string `json:"role,omitempty"`
}

type XCards

type XCards struct {
	// X specific metadata
	Card    string `json:"twitter:card,omitempty"`
	Site    string `json:"twitter:site,omitempty"`
	Creator string `json:"twitter:creator,omitempty"`

	// Basic Metadata
	Type  string `json:"twitter:type,omitempty"`
	Title string `json:"twitter:title,omitempty"`
	URL   string `json:"twitter:url,omitempty"`

	// Optional metadata
	Description     string   `json:"twitter:description,omitempty"`
	Determiner      string   `json:"twitter:determiner,omitempty"`
	Locale          string   `json:"twitter:locale,omitempty"`
	LocaleAlternate []string `json:"twitter:locale:alternate,omitempty"`
	SiteName        string   `json:"twitter:site_name,omitempty"`

	// Media
	OpenGraphImage []OpenGraphImage `json:"og:image,omitempty"`
	OpenGraphAudio []OpenGraphAudio `json:"og:audio,omitempty"`
	OpenGraphVideo []OpenGraphVideo `json:"og:video,omitempty"`
	XCardsImage    []XCardsImage    `json:"twitter:image,omitempty"`
	XCardsAudio    []XCardsAudio    `json:"twitter:audio,omitempty"`
	XCardsVideo    []XCardsVideo    `json:"twitter:video,omitempty"`

	// Music specific
	Music *Music `json:"music,omitempty"`

	// Video specific
	Video *Video `json:"video,omitempty"`

	// Article specific
	Article *Article `json:"article,omitempty"`

	// Book specific
	Book *Book `json:"book,omitempty"`

	// Profile specific
	Profile *Profile `json:"profile,omitempty"`
}

func NewXCards

func NewXCards() *XCards

NewXCards creates a new XCards instance with basic initialization

type XCardsAudio

type XCardsAudio struct {
	URL       string `json:"twitter:audio"`
	SecureURL string `json:"twitter:audio:secure_url,omitempty"`
	Type      string `json:"twitter:audio:type,omitempty"`
}

XCardsAudio represents XCards audio object

type XCardsImage

type XCardsImage struct {
	URL       string `json:"twitter:image"`
	SecureURL string `json:"twitter:image:secure_url,omitempty"`
	Type      string `json:"twitter:image:type,omitempty"`
	Width     int    `json:"twitter:image:width,omitempty"`
	Height    int    `json:"twitter:image:height,omitempty"`
	Alt       string `json:"twitter:image:alt,omitempty"`
}

XCardsImage represents XCards image object

type XCardsVideo

type XCardsVideo struct {
	URL       string `json:"twitter:video"`
	SecureURL string `json:"twitter:video:secure_url,omitempty"`
	Type      string `json:"twitter:video:type,omitempty"`
	Width     int    `json:"twitter:video:width,omitempty"`
	Height    int    `json:"twitter:video:height,omitempty"`
}

XCardsVideo represents XCards video object

Jump to

Keyboard shortcuts

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