parse

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ACLEDEventCategory added in v1.1.0

func ACLEDEventCategory(eventType string) string

ACLEDEventCategory maps ACLED event types to EUOSINT categories.

func ACLEDEventSeverity added in v1.1.0

func ACLEDEventSeverity(eventType string, fatalities int) string

ACLEDEventSeverity infers severity from ACLED event characteristics.

func ACLEDISO2 added in v1.1.0

func ACLEDISO2(iso3 string) string

ACLEDISO2 converts an ACLED ISO3 code to ISO2. Returns "" if unknown.

func EONETSeverity added in v1.3.0

func EONETSeverity(categoryID string) string

EONETSeverity returns severity based on EONET category.

func GDELTCountryISO2 added in v1.3.0

func GDELTCountryISO2(country string) string

GDELTCountryISO2 converts a GDELT sourcecountry string to ISO2.

func NormalizeConflictType added in v1.4.0

func NormalizeConflictType(typeCode string) string

func StripHTML

func StripHTML(value string) string

StripHTML removes script/style tags, strips remaining HTML tags, unescapes entities, and normalizes whitespace.

func USGSSeverity added in v1.3.0

func USGSSeverity(mag float64, alertLevel string) string

USGSSeverity returns severity based on magnitude.

Types

type ACLEDEvent added in v1.1.0

type ACLEDEvent struct {
	DataID       json.Number `json:"data_id"`
	EventDate    string      `json:"event_date"`
	Year         json.Number `json:"year"`
	EventType    string      `json:"event_type"`
	SubEventType string      `json:"sub_event_type"`
	Actor1       string      `json:"actor1"`
	Actor2       string      `json:"actor2"`
	Country      string      `json:"country"`
	ISO3         string      `json:"iso3"`
	Region       string      `json:"region"`
	Admin1       string      `json:"admin1"`
	Admin2       string      `json:"admin2"`
	Admin3       string      `json:"admin3"`
	Location     string      `json:"location"`
	Latitude     string      `json:"latitude"`
	Longitude    string      `json:"longitude"`
	Source       string      `json:"source"`
	SourceScale  string      `json:"source_scale"`
	Notes        string      `json:"notes"`
	Fatalities   json.Number `json:"fatalities"`
	Tags         string      `json:"tags"`
	Timestamp    json.Number `json:"timestamp"`
}

ACLEDEvent is a single conflict event from the ACLED API.

type ACLEDItem added in v1.1.0

type ACLEDItem struct {
	FeedItem
	EventType  string
	Fatalities int
	Country    string // Full country name from ACLED
	ISO3       string // 3-letter ISO code
	Region     string // ACLED region (e.g. "Europe", "Middle East")
}

ACLEDItem extends FeedItem with ACLED-specific metadata needed for category/severity mapping in the normalizer.

func ParseACLED added in v1.1.0

func ParseACLED(body []byte) ([]ACLEDItem, int, error)

ParseACLED parses an ACLED API JSON response into ACLEDItems.

type ACLEDResponse added in v1.1.0

type ACLEDResponse struct {
	Status int          `json:"status"`
	Count  int          `json:"count"`
	Data   []ACLEDEvent `json:"data"`
}

ACLEDResponse is the top-level response from the ACLED API.

type EONETCategory added in v1.3.0

type EONETCategory struct {
	ID    string `json:"id"`
	Title string `json:"title"`
}

type EONETEvent added in v1.3.0

type EONETEvent struct {
	ID         string          `json:"id"`
	Title      string          `json:"title"`
	Link       string          `json:"link"`
	Categories []EONETCategory `json:"categories"`
	Sources    []EONETSource   `json:"sources"`
	Geometry   []EONETGeometry `json:"geometry"`
}

type EONETGeometry added in v1.3.0

type EONETGeometry struct {
	Date        string    `json:"date"`
	Type        string    `json:"type"`        // "Point"
	Coordinates []float64 `json:"coordinates"` // [lng, lat]
}

type EONETItem added in v1.3.0

type EONETItem struct {
	FeedItem
	CategoryID    string
	CategoryTitle string
}

EONETItem extends FeedItem with EONET-specific metadata.

func ParseEONET added in v1.3.0

func ParseEONET(body []byte) ([]EONETItem, error)

ParseEONET parses a NASA EONET v3 JSON response.

type EONETResponse added in v1.3.0

type EONETResponse struct {
	Events []EONETEvent `json:"events"`
}

EONETResponse is the top-level response from NASA EONET v3.

type EONETSource added in v1.3.0

type EONETSource struct {
	ID  string `json:"id"`
	URL string `json:"url"`
}

type FBIWantedEntry

type FBIWantedEntry struct {
	UID                  string   `json:"uid"`
	Title                string   `json:"title"`
	Description          string   `json:"description"`
	Details              string   `json:"details"`
	Caution              string   `json:"caution"`
	WarningMessage       string   `json:"warning_message"`
	Remarks              string   `json:"remarks"`
	Sex                  string   `json:"sex"`
	Nationality          string   `json:"nationality"`
	PlaceOfBirth         string   `json:"place_of_birth"`
	DatesOfBirthUsed     []string `json:"dates_of_birth_used"`
	Aliases              []string `json:"aliases"`
	Subjects             []string `json:"subjects"`
	Status               string   `json:"status"`
	PersonClassification string   `json:"person_classification"`
	PosterClassification string   `json:"poster_classification"`
	RewardText           string   `json:"reward_text"`
	RewardMin            int      `json:"reward_min"`
	RewardMax            int      `json:"reward_max"`
	URL                  string   `json:"url"`
	Path                 string   `json:"path"`
	Publication          string   `json:"publication"`
	Modified             string   `json:"modified"`
	FieldOffices         []string `json:"field_offices"`
	PossibleCountries    []string `json:"possible_countries"`
	PossibleStates       []string `json:"possible_states"`
	Images               []struct {
		Thumb    string `json:"thumb"`
		Original string `json:"original"`
		Large    string `json:"large"`
		Caption  string `json:"caption"`
	} `json:"images"`
}

FBIWantedEntry is a single person/case from the FBI Wanted API.

type FBIWantedResponse

type FBIWantedResponse struct {
	Total int              `json:"total"`
	Page  int              `json:"page"`
	Items []FBIWantedEntry `json:"items"`
}

FBIWantedResponse is the top-level response from the FBI Wanted API.

type FeedItem

type FeedItem struct {
	Title     string
	Link      string
	Published string
	Author    string
	Summary   string
	Tags      []string
	Lat       float64 // from <georss:point> if present
	Lng       float64 // from <georss:point> if present
}

func ParseFBIWanted

func ParseFBIWanted(body []byte) ([]FeedItem, int, error)

ParseFBIWanted parses the FBI Wanted API JSON response into FeedItems.

func ParseFCDOAtom

func ParseFCDOAtom(body []byte) ([]FeedItem, error)

ParseFCDOAtom parses a UK FCDO (Foreign, Commonwealth & Development Office) Atom feed containing travel advice entries. This delegates to the generic Atom parser in ParseFeed and returns the results.

func ParseFeed

func ParseFeed(xml string) []FeedItem

func ParseGDELT added in v1.3.0

func ParseGDELT(body []byte) ([]FeedItem, error)

ParseGDELT parses a GDELT v2 ArtList JSON response.

func ParseGermanAATravelWarnings

func ParseGermanAATravelWarnings(body []byte) ([]FeedItem, error)

ParseGermanAATravelWarnings parses the JSON response from the German Auswärtiges Amt (Federal Foreign Office) travel warning open-data API. The API returns an object whose keys are numeric country IDs and values contain the warning metadata.

func ParseHTMLAnchors

func ParseHTMLAnchors(body string, baseURL string) []FeedItem

func ParseTelegram added in v1.0.4

func ParseTelegram(body string, channel string) []FeedItem

ParseTelegram extracts messages from a Telegram t.me/s/<channel> HTML page. Each message becomes a FeedItem with:

  • Title: first ~200 chars of the text content
  • Link: https://t.me/<channel>/<msgid>
  • Published: datetime from <time> tag

type FeodoEntry added in v1.3.0

type FeodoEntry struct {
	IPAddress  string `json:"ip_address"`
	Port       int    `json:"port"`
	Status     string `json:"status"` // "online" or "offline"
	Hostname   string `json:"hostname"`
	ASNumber   int    `json:"as_number"`
	ASName     string `json:"as_name"`
	Country    string `json:"country"` // 2-letter country code
	FirstSeen  string `json:"first_seen"`
	LastOnline string `json:"last_online"`
	Malware    string `json:"malware"` // e.g. "Dridex", "TrickBot"
}

FeodoEntry is a single entry from the Feodo Tracker IP blocklist.

type FeodoItem added in v1.3.0

type FeodoItem struct {
	FeedItem
	IPAddress string
	Port      int
	Status    string
	Malware   string
	Country   string // 2-letter code
	ASName    string
}

FeodoItem extends FeedItem with Feodo-specific metadata.

func ParseFeodo added in v1.3.0

func ParseFeodo(body []byte) ([]FeodoItem, error)

ParseFeodo parses the Feodo Tracker JSON blocklist, returning only online entries (active C2 servers).

type GDELTArticle added in v1.3.0

type GDELTArticle struct {
	URL           string `json:"url"`
	Title         string `json:"title"`
	Seendate      string `json:"seendate"` // "20260318T120000Z"
	Domain        string `json:"domain"`
	Language      string `json:"language"`
	SourceCountry string `json:"sourcecountry"` // "United States"
}

type GDELTResponse added in v1.3.0

type GDELTResponse struct {
	Articles []GDELTArticle `json:"articles"`
}

GDELTResponse is the top-level response from GDELT v2 ArtList mode.

type UCDPConflict added in v1.4.0

type UCDPConflict struct {
	ConflictID     string
	ConflictName   string
	TypeOfConflict string // "3" = intrastate, "4" = internationalized intrastate, etc.
	IntensityLevel int    // 1 = minor, 2 = war
	GWNoLoc        string // country gwno
	Year           int
	EPEnd          int
	StartDate      string
	Region         string
	SideA          string
	SideB          string
}

func ParseUCDPConflicts added in v1.4.0

func ParseUCDPConflicts(body []byte) ([]UCDPConflict, error)

type UCDPItem added in v1.3.0

type UCDPItem struct {
	FeedItem
	ViolenceType     string
	Fatalities       int
	CivilianDeaths   int
	Country          string
	CountryCode      string
	Region           string
	SideA            string
	SideB            string
	DyadName         string
	Admin1           string
	Admin2           string
	WhereDescription string
	SourceHeadline   string
	SourceArticle    string
	SourceOriginal   string
	WherePrecision   int
	DatePrecision    int
	EventClarity     int
}

UCDPItem extends FeedItem with UCDP conflict metadata.

func ParseUCDP added in v1.3.0

func ParseUCDP(body []byte) ([]UCDPItem, error)

ParseUCDP parses UCDP API responses with flexible envelope keys. Supported envelopes: {"Result":[...]}, {"results":[...]}, {"data":[...]}.

type USGSFeature added in v1.3.0

type USGSFeature struct {
	Properties USGSProperties `json:"properties"`
	Geometry   USGSGeometry   `json:"geometry"`
	ID         string         `json:"id"`
}

type USGSGeoJSON added in v1.3.0

type USGSGeoJSON struct {
	Features []USGSFeature `json:"features"`
}

USGSGeoJSON is the top-level GeoJSON FeatureCollection from the USGS earthquake feed.

type USGSGeometry added in v1.3.0

type USGSGeometry struct {
	Coordinates []float64 `json:"coordinates"` // [lng, lat, depth]
}

type USGSItem added in v1.3.0

type USGSItem struct {
	FeedItem
	Magnitude  float64
	Tsunami    bool
	AlertLevel string // green/yellow/orange/red
}

USGSItem extends FeedItem with earthquake-specific metadata.

func ParseUSGSGeoJSON added in v1.3.0

func ParseUSGSGeoJSON(body []byte) ([]USGSItem, error)

ParseUSGSGeoJSON parses a USGS GeoJSON earthquake feed.

type USGSProperties added in v1.3.0

type USGSProperties struct {
	Mag     float64 `json:"mag"`
	Place   string  `json:"place"`
	Time    int64   `json:"time"` // unix ms
	URL     string  `json:"url"`
	Title   string  `json:"title"`
	Alert   string  `json:"alert"`   // green/yellow/orange/red
	Tsunami int     `json:"tsunami"` // 0 or 1
	Type    string  `json:"type"`    // "earthquake"
}

Jump to

Keyboard shortcuts

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