rlprice

package module
v0.0.0-...-9608778 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: GPL-3.0 Imports: 22 Imported by: 0

README

#+title: RLPrice
#+author: Bulkosoft

* RLPrice

RLPrice is a Go module that provides useful functions/methods for finding prices
for Rocket League, using its own, innovative algorithm, better than any of the
competitors'.

Documentation

Index

Constants

View Source
const (
	CREDITSYMBOL = "cr"

	QUALITYNONE = "none"
	QUALITYANY  = "any"
)
View Source
const (
	TRADINGURL = "https://rocket-league.com/trading?filterItem=" +
		ITEMNUMBERREPLACEINDICATOR +
		"&filterCertification=" + CERTNUMBERREPLACEINDICATOR +
		"&filterPaint=" + COLOURNUMBERREPLACEINDICATOR +
		"&filterRarity=" + QUALITYNUMBERREPLACEINDICATOR +
		"&filterTradeType=0" +
		"&filterMinCredits=0" +
		"&filterMaxCredits=100000" +
		"&filterPlatform[]=" + PLATFORMNUMBERREPLACEINDICATOR +
		"&filterSearchType=" + SEARCHTYPENUMBERREPLACEINDICATOR +
		"&filterItemType=1" // 0 = any; 1 = items only; 2 = blueprints only
	// the following URL is used in a POST request to get other pages @ RL
	// Garage
	TRADINGURL2 = "https://rocket-league.com/ajaxfunctions/loadAdditionalTrades.php?filterItem=" +
		ITEMNUMBERREPLACEINDICATOR +
		"&filterCertification=" + CERTNUMBERREPLACEINDICATOR +
		"&filterPaint=" + COLOURNUMBERREPLACEINDICATOR +
		"&filterSeries=A" +
		"&filterRarity=" + QUALITYNUMBERREPLACEINDICATOR +
		"&filterTradeType=0" +
		"&filterMinCredits=0" +
		"&filterMaxCredits=100000" +
		"&filterPlatform[]=" + PLATFORMNUMBERREPLACEINDICATOR +
		"&filterSearchType=" + SEARCHTYPENUMBERREPLACEINDICATOR +
		"&filterItemType=1" // 0 = any; 1 = items only; 2 = blueprints only
	ITEMNUMBERREPLACEINDICATOR       = "ITEM"
	COLOURNUMBERREPLACEINDICATOR     = "PAINT"
	CERTNUMBERREPLACEINDICATOR       = "CERT"
	QUALITYNUMBERREPLACEINDICATOR    = "QUALITY" // a.k.a. rarity
	PLATFORMNUMBERREPLACEINDICATOR   = "PLATFORM"
	SEARCHTYPENUMBERREPLACEINDICATOR = "SEARCHTYPE"
	POSTCLASS                        = "rlg-trade"             // HTML/CSS class identifying posts
	HASCLASS                         = "rlg-trade__itemshas"   // HTML/CSS class for offered items in posts
	WANTSCLASS                       = "rlg-trade__itemswants" // HTML/CSS class for requested items in posts
	ITEMCLASS                        = "rlg-item"
	ITEMNAMECLASS                    = "rlg-item__name"
	ITEMCERTCLASS                    = "rlg-item__cert"
	ITEMCOLOURCLASS                  = "rlg-item__paint"
	CREDITSNAME                      = "Credits"
	ITEMQUANTITYCLASS                = "rlg-item__quantity"
	USERNAMECLASS                    = "rlg-trade__username"
	DESCRIPTIONCLASS                 = "rlg-trade__note"
	PLATFORMCLASS                    = "rlg-trade__platformlogo"
	PLATFORMATTR                     = "alt"

	STRGLOBAL = "(Global)"

	STRINGCONTAINEDINNCOFFERNAMES = "offer"
)
View Source
const (
	PLACEHOLDERPRICE = ERRORF

	// URL is usable for every platform:
	INSIDERBASEURL = "https://rl.insider.gg/en/" + INSIDERPLATFORMREPLACEINDICATOR
	INSIDERITEMURL = INSIDERBASEURL +
		"/" + INSIDERCATEGORYREPLACEINDICATOR +
		"/" + INSIDERITEMREPLACEINDICATOR +
		"/" + INSIDERCOLOURREPLACEINDICATOR
	INSIDERPLATFORMSNUMBER = 4 // number of platforms supported by Rocket League
	// and therefore by RL Insider
	INSIDERITEMREPLACEINDICATOR              = "ITEM" // string to look for and to replace in URL below
	INSIDERCOLOURREPLACEINDICATOR            = "PAINT"
	INSIDERCATEGORYREPLACEINDICATOR          = "CATEGORY"
	INSIDERPLATFORMREPLACEINDICATOR          = "PLATFORM"
	INSIDERPRICEROWID                        = "matrixRow0"
	INSIDERPRICEROWCHILD                     = TABLECELL
	INSIDERPRICEINTABLEFORMAT                = "%g" + SPACEDASHSPACE + "%g"
	INSIDERSTRINGSTOREMOVEFROMNAMESSEPARATOR = COMMA
	INSIDERSTRINGSTOREMOVEFROMNAMES          = STRGLOBAL // NOTE: case-sensitive

	NCEROWCLASS  = "ncExotic"
	NCIROWCLASS  = "ncImport"
	NCVRROWCLASS = "ncVeryRare"
	NCRROWCLASS  = "ncRare"
	NCPRICEELEM  = TABLECELL
	NCPRICECLASS = "ncData"
)
View Source
const (
	GENERICTRADINGURL = "https://rocket-league.com/trading"

	IDCONTAINERELEMENT   = "optgroup"
	IDCONTAINERATTR      = "label"
	IDCONTAINERCHILD     = "option"
	IDCONTAINERCHILDATTR = "value"
)
View Source
const (
	// characters
	NEWLINE      = "\n"
	COMMA        = ","
	SPACE        = " "
	STRNIL       = ""
	DASH         = "-"
	UNDERSCORE   = "_"
	DOT          = "."
	COLON        = ":"
	COLONSPACE   = COLON + SPACE
	OPARENTHESIS = "("
	CPARENTHESIS = ")"
	OSQUAREB     = "["
	CSQUAREB     = "]"
	EQUAL        = "="
	SLASH        = "/"
	SAFESLASH    = "§" // gets replaced with "/" if found by RL
	// Insider string cleaner methods
	GT             = ">"
	LT             = "<"
	SPACEDASHSPACE = SPACE + DASH + SPACE
	TRIPLEDASH     = DASH + DASH + DASH
	STRIPLEDASHS   = SPACE + TRIPLEDASH + SPACE
	ARROW          = TRIPLEDASH + GT
	LONGARROW      = TRIPLEDASH + ARROW

	ERRORI = -1     // error integer return value
	ERRORF = ERRORI // error float return value
	ERRORB = false  // error boolean return value

	// extensions
	TEXT = DOT + "txt"
	CSV  = DOT + "csv"
	TOML = DOT + "toml"

	// HTML elements
	TABLECELL = "td"

	// Colly utils
	CHILDELEMENT = SPACE + GT + SPACE
)

Variables

View Source
var (
	// --- RL Garage misc ---
	SEARCHDESCRIPTIONSFORREALPRICE = true // 'true' makes the program look in
	// post descriptions for variations of already found price, and use those
	HARDENMINPRICEANTISCAM float64 = 10000 // default: 10000 --- when this threshold is
	// reached, the program will be much more aggressive when doing anti-scam
	// checks, and will only consider "OK" prices that aren't below 50% of
	// Insider's price, instead of just 10%
	RLGARAGELIMIT         float64 = 100000 // max item/credit quantity allowed by RL Garage
	REQUIREDSIMILAROFFERS         = 2      // minimum number of similar offers to find, to
	// consider one real
	DIVIDECREDITSBYITEMSN = true // when offer/price with item quantity != 1 is found

	// --- RL Garage post description word blacklist ---
	WORDSBLACKLISTSEPARATOR = COMMA
	WORDSBLACKLIST          = "trust trade,dupe,carry,for free"

	// --- RL Garage users blacklist ---
	ENABLEUSERSBLACKLIST = true

	// --- RL Insider ---
	NCMAXRETRIES = 3 // getting non-crate prices often fails (JS...)

	// --- percentages ---
	INSIDERPRICEPERCENTFORMAXOFFER float64 = 10 // when looking for scam credit
	// offers, offers > insiderPrice-(INSIDERPRICEPERCENTFORMINPRICE% of insiderPrice) will be removed
	INSIDERPRICEPERCENTFORMINPRICE float64 = 5 // when looking for scam selling
	// prices, prices < INSIDERPRICEPERCENTFORMINPRICE% of insiderPrice will be removed
	INSIDERPRICEPERCENTFORMINPRICE_TRENDING float64 = 5 // when looking for scam
	// selling prices, prices < INSIDERPRICEPERCENTFORMINPRICE% of insiderPrice
	// will be removed (used when an item is trending) ------------------
	CLOSEPERCENT float64 = 15 // used for determining margins inside which two
	// prices are considered similar/close to one another
	ISIMPOSSIBLEPERCENT float64 = 85 // used for getting ranges for comparisons between

	// --- Colly scraper ---
	LIMITDOMAINS               = "*" // domains to which the following variables apply (* = all)
	DELAY        time.Duration = 3   // in seconds
	RANDDELAY    time.Duration = 3   // =

	OTHERDIR                       = "other" + SLASH
	DEFAULTPERMISSIONS fs.FileMode = 0644

	// SI prefixes
	SIPREFIXESFILE      = OTHERDIR + "siprefixes" + CSV // only from deca to quetta
	SYMBOLPOSITIONINCSV = 0                             // indexes:    0   ,  1
	VALUEPOSITIONINCSV  = 1                             // contents: symbol,value

	// users blacklist
	USERSBLACKLISTFILE            = OTHERDIR + "usersblacklist" + TEXT
	USERSBLACKLISTFILEPERMISSIONS = DEFAULTPERMISSIONS

	// RL Garage
	RLGARAGEDIR = "rlgarage" + SLASH

	ITEMNUMBERSDIR             = RLGARAGEDIR + "items" + SLASH // for URLs
	ITEMNUMBERSFILEPERMISSIONS = DEFAULTPERMISSIONS

	COLOURNUMBERSFILE     = RLGARAGEDIR + "colours" + CSV        // for URLs
	CERTNUMBERSFILE       = RLGARAGEDIR + "certifications" + CSV // for URLs
	PLATFORMNUMBERSFILE   = RLGARAGEDIR + "platforms" + CSV      // for URLs
	SEARCHTYPENUMBERSFILE = RLGARAGEDIR + "searchtypes" + CSV    // for URLs
	QUALITYNUMBERSFILE    = RLGARAGEDIR + "qualities" + CSV
	INTPOSITIONINCSV      = 0
	STRINGPOSITIONINCSV   = 1

	CATEGORIESFILE = RLGARAGEDIR + "categories" + TEXT

	// other
	ALIASESFILE           = OTHERDIR + "aliases" + CSV // e.g.: alpha cap -> gold cap (alpha reward)
	REALNAMEPOSITIONINCSV = 1
)
View Source
var SIPrefixes []string

variable used for saving SI prefixes for later, so we don't have to open and read file all the time

Functions

func Contains

func Contains(string, substring string, caseSensitive bool) bool

if caseSensitive == true, returns strings.Contains() result, otherwise it uses ContainsFold

func ContainsFold

func ContainsFold(string, substring string) bool

strings.Contains but case-insensitive

func Equals

func Equals(str1, str2 string, caseSensitive bool, contains bool) bool

if caseSensitive == true, returns str1 == str2 result, otherwise it uses strings.EqualsFold. Ic contains == true, ContainsFold/strings.Contains will be used instead.

func GetData

func GetData(itemName, itemColour, itemCert, itemCategory, itemQuality, pricePlatform string) (float64, float64, float64, error)

returns, respectively:

1. current item price from RL Garage trading posts; 2. max offer at RL Garage; 3. min price at RL Garage.

Returns ERRORF instead of each one of these if err != nil

func GetInsiderPrice

func GetInsiderPrice(itemName, itemColour, itemCategory, pricePlatform string) (float64, error)

get RL Insider's not so accurate price; or ERRORF if no price is found a.k.a. "base price"

func GetInsiderURL

func GetInsiderURL(itemName, itemColour, itemCategory, pricePlatform string) (string, error)

return given item's page at RL Insider

func GetMaxOffer

func GetMaxOffer(itemName, itemColour, itemQuality, itemCategory, itemCert, URL, platformHR string,
	insiderPrice, minPrice float64, ignoreColour, anyQuantity, divide bool) (float64, error)

get maximum credits offer at RL Garage for given item

func GetMinPrice

func GetMinPrice(itemName, itemColour, itemQuality, itemCategory, itemCert, URL, platformHR string,
	insiderPrice float64, ignoreColour, anyQuantity, divide bool) (float64, error)

get minimum sell price at RL Garage for given item

func GetPrice

func GetPrice(itemName, itemColour, itemCert, itemCategory, itemQuality, pricePlatform string) (float64, error)

like GetData, but it only returns an item's price

func GetRLGarageURL

func GetRLGarageURL(itemName, itemColour, itemCert, itemQuality, itemNameQuality,
	itemCategory, pricePlatform string) (string, error)

returns an item's trading URL.

itemQuality is the quality to use in the URL; itemNameQuality is the one that will be put inside parentheses next to the item name, when looking for its ID in the CSV files.

NOTE: 1. itemName must be run through ReturnAndRemoveQualityRLGarage() first NOTE: returned URL still IS NOT VALID! SEARCHTYPENUMBERREPLACEINDICATOR (by default = "SEARCHTYPE") still needs to be replaced according to your needs!

func ReturnAndRemoveQualityRLGarage

func ReturnAndRemoveQualityRLGarage(name string) (string, string, error)

remove quality/rarity from item name and return (if it does get found), respectively, clean item name and found rarity

func ScrapeRLGarageItemIDs

func ScrapeRLGarageItemIDs(outDir string) error

parse item identifiers used in RL Garage trading URLs and save them to multiple files in given directory (CSV). E.g.: Fennec -> 1892

Types

This section is empty.

Jump to

Keyboard shortcuts

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