Unit WebUnit

Uses
Classes, Interfaces, Objects and Records
Types
Variables

Description

Web Unit

Overview

Functions and Procedures

function GetOrgDataAndLogoURL(const Nickname: string; out OrgName: string; out LogoURL: UnicodeString): Boolean;
function GetOrLoadOrgLogoToStream(const OrgName: string; const LogoURL: UnicodeString; TargetStream: TStream): Boolean;
function GetAvatarDataAndLogoURL(const Nickname: string; out LogoURL: UnicodeString): Boolean;
function GetOrLoadAvatarLogoToStream(const Nickname: string; const LogoURL: UnicodeString; TargetStream: TStream): Boolean;
function RegExOrgLogoURL(OrgName: String): String;

Constants

HTTPSPrefix = UnicodeString('https://');
StarToolsAgent = 'StarTools Agent/' + UnicodeString(StarToolsVersionMM);
RobertsSpaceIndustriesHost = UnicodeString('robertsspaceindustries.com');
RobertsSpaceIndustriesCDNHost = UnicodeString('cdn.robertsspaceindustries.com');
RobertsSpaceIndustriesStatusHost = UnicodeString('status.robertsspaceindustries.com');
ENCitizenPrefix = UnicodeString('/en/citizens/');
ENOrgsPrefix = UnicodeString('/en/orgs/');
RegExAvatarLogoURL = '(?:"\/account\/profile"|id\s*=\s*"public-profile".*?UEE Citizen Record).*?<img\s+src\s*=\s*"([ˆ>\s"]+)';
RegExOrgLogoURLPrefix = '<a\s+href\s*=\s*"\/orgs\/';
RegExOrgLogoURLSuffix = '"\s*>\s*<img\s+src\s*=\s*"([ˆ>\s"]+)"';
RegExOrgSID = '<span[ˆ>]*>\s*Spectrum\s+Identification\s+\(SID\)\s*<\/span>\s*<strong[ˆ>]*>\s*([ˆ<\s]+)';

Description

Functions and Procedures

function GetOrgDataAndLogoURL(const Nickname: string; out OrgName: string; out LogoURL: UnicodeString): Boolean;

Scrapes the public dossier of a user to retrieve Organization details.

Parameters
Nickname
The Star Citizen Nickname to look up.
OrgName
Output parameter for the Organization SID/Name.
LogoURL
Output parameter for the absolute URL of the organization's logo.
Returns

True if the organization data was successfully parsed.

function GetOrLoadOrgLogoToStream(const OrgName: string; const LogoURL: UnicodeString; TargetStream: TStream): Boolean;

Retrieves an organization logo, prioritising the local cache over the network. If the file exists in the cache, it is loaded into the stream. Otherwise, it is downloaded and saved locally.

Parameters
OrgName
The name of the organization (used for cache filename).
LogoURL
The remote URL of the image.
TargetStream
The destination TStream where the image data will be written.
Returns

True if the data was successfully loaded from cache or downloaded.

function GetAvatarDataAndLogoURL(const Nickname: string; out LogoURL: UnicodeString): Boolean;

Scrapes the public dossier of a user to retrieve the Avatar logo URL.

Parameters
Nickname
The Star Citizen Nickname to look up.
LogoURL
Output parameter for the absolute URL of the avatar image.
Returns

True if the avatar URL was successfully parsed.

function GetOrLoadAvatarLogoToStream(const Nickname: string; const LogoURL: UnicodeString; TargetStream: TStream): Boolean;

Retrieves a citizen's avatar logo, prioritising the local cache over the network. If the file exists in the cache, it is loaded into the stream. Otherwise, it is downloaded and saved locally.

Parameters
Nickname
The Star Citizen Nickname (used for cache filename).
LogoURL
The remote URL of the image.
TargetStream
The destination TStream where the image data will be written.
Returns

True if the data was successfully loaded from cache or downloaded.

function RegExOrgLogoURL(OrgName: String): String;

Constructs a complete regular expression to find an organization's logo URL based on its name.

Parameters
OrgName
The Organization SID/Name to include in the regex pattern.
Returns

A string containing the formatted Regular Expression.

Constants

HTTPSPrefix = UnicodeString('https://');

Standard HTTPS protocol prefix.

StarToolsAgent = 'StarTools Agent/' + UnicodeString(StarToolsVersionMM);

User-Agent string used for WinHttp requests.

RobertsSpaceIndustriesHost = UnicodeString('robertsspaceindustries.com');

Main RSI website domain.

RobertsSpaceIndustriesCDNHost = UnicodeString('cdn.robertsspaceindustries.com');

RSI Content Delivery Network domain.

RobertsSpaceIndustriesStatusHost = UnicodeString('status.robertsspaceindustries.com');

RSI Service Status domain.

ENCitizenPrefix = UnicodeString('/en/citizens/');

URL path prefix for public citizen profiles.

ENOrgsPrefix = UnicodeString('/en/orgs/');

URL path prefix for public organization profiles.

RegExAvatarLogoURL = '(?:"\/account\/profile"|id\s*=\s*"public-profile".*?UEE Citizen Record).*?<img\s+src\s*=\s*"([ˆ>\s"]+)';

Regular expression to extract the Avatar image URL from a citizen's dossier page.

RegExOrgLogoURLPrefix = '<a\s+href\s*=\s*"\/orgs\/';

Prefix for the regular expression used to find the organization logo link.

RegExOrgLogoURLSuffix = '"\s*>\s*<img\s+src\s*=\s*"([ˆ>\s"]+)"';

Suffix for the regular expression used to find the organization logo link.

RegExOrgSID = '<span[ˆ>]*>\s*Spectrum\s+Identification\s+\(SID\)\s*<\/span>\s*<strong[ˆ>]*>\s*([ˆ<\s]+)';

Regular expression to extract the Spectrum Identification (SID) from an organization block.