add prettier config
This commit is contained in:
@ -21,54 +21,54 @@ export default (options = {}) => {
|
||||
category = "overall",
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
substituteVars(RANKING_URL, { category, page }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
const scores = async (
|
||||
playerId,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
substituteVars(PLAYER_SCORES_URL, { playerId, page }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
const playerRankHistory = async (
|
||||
playerId,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
substituteVars(PLAYER_RANK_HISTORY, { playerId }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
const leaderboard = async (
|
||||
leaderboardId,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
substituteVars(LEADERBOARD_URL, { leaderboardId, page }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
const leaderboardInfo = async (
|
||||
leaderboardId,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
substituteVars(LEADERBOARD_INFO_URL, { leaderboardId }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
|
||||
return {
|
||||
|
@ -78,7 +78,7 @@ export default (options = {}) => {
|
||||
fetchFunc,
|
||||
url,
|
||||
options,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
priority = PRIORITY.FG_LOW
|
||||
) => {
|
||||
for (let i = 0; i <= retries; i++) {
|
||||
try {
|
||||
@ -140,11 +140,11 @@ export default (options = {}) => {
|
||||
|
||||
const queuedFetchJson = async (url, options, priority = PRIORITY.FG_LOW) =>
|
||||
resolvePromiseOrWaitForPending(url, () =>
|
||||
retriedFetch(fetchJson, url, options, priority),
|
||||
retriedFetch(fetchJson, url, options, priority)
|
||||
);
|
||||
const queuedFetchHtml = async (url, options, priority = PRIORITY.FG_LOW) =>
|
||||
resolvePromiseOrWaitForPending(url, () =>
|
||||
retriedFetch(fetchHtml, url, options, priority),
|
||||
retriedFetch(fetchHtml, url, options, priority)
|
||||
);
|
||||
|
||||
const getRateLimit = () => currentRateLimit;
|
||||
|
@ -63,10 +63,10 @@ const initQueue = (queue) => {
|
||||
|
||||
export default {
|
||||
SCORESABER_API: initQueue(
|
||||
createScoreSaberApiQueue({ concurrency: 3, timeout: 95000 }),
|
||||
createScoreSaberApiQueue({ concurrency: 3, timeout: 95000 })
|
||||
),
|
||||
SCORESABER_PAGE: initQueue(
|
||||
createScoreSaberPageQueue({ concurrency: 3, timeout: 30000 }),
|
||||
createScoreSaberPageQueue({ concurrency: 3, timeout: 30000 })
|
||||
),
|
||||
BEATMAPS: initQueue(
|
||||
createBeatMapsApiQueue({
|
||||
@ -74,7 +74,7 @@ export default {
|
||||
timeout: 10000,
|
||||
intervalCap: 10,
|
||||
interval: 1000,
|
||||
}),
|
||||
})
|
||||
),
|
||||
BEATSAVIOR: initQueue(
|
||||
createBeatSaviorApiQueue({
|
||||
@ -82,7 +82,7 @@ export default {
|
||||
timeout: 10000,
|
||||
intervalCap: 60,
|
||||
interval: 60000,
|
||||
}),
|
||||
})
|
||||
),
|
||||
TWITCH: initQueue(
|
||||
createTwitchApiQueue({
|
||||
@ -90,10 +90,10 @@ export default {
|
||||
timeout: 8000,
|
||||
intervalCap: 800,
|
||||
interval: 60000,
|
||||
}),
|
||||
})
|
||||
),
|
||||
ACCSABER: initQueue(
|
||||
createAccSaberApiQueue({ concurrency: 2, timeout: 10000 }),
|
||||
createAccSaberApiQueue({ concurrency: 2, timeout: 10000 })
|
||||
),
|
||||
PRIORITY,
|
||||
};
|
||||
|
@ -27,7 +27,7 @@ export default (options = {}) => {
|
||||
playerId,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(substituteVars(baseUrl, { playerId, page }), options, priority);
|
||||
|
||||
@ -35,21 +35,21 @@ export default (options = {}) => {
|
||||
fetchJson(
|
||||
substituteVars(SS_API_PLAYER_INFO_URL, { playerId }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
|
||||
const recentScores = async (
|
||||
playerId,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) => fetchScores(SS_API_RECENT_SCORES_URL, playerId, page, priority, options);
|
||||
|
||||
const topScores = async (
|
||||
playerId,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) => fetchScores(SS_API_TOP_SCORES_URL, playerId, page, priority, options);
|
||||
|
||||
const findPlayer = async (query, priority = PRIORITY.FG_LOW, options = {}) =>
|
||||
@ -58,18 +58,18 @@ export default (options = {}) => {
|
||||
query: encodeURIComponent(query),
|
||||
}),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
|
||||
const rankingGlobal = async (
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
substituteVars(SS_API_RANKING_GLOBAL_URL, { page }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
|
||||
const rankingGlobalPages = async (priority = PRIORITY.FG_LOW, options = {}) =>
|
||||
|
@ -24,7 +24,7 @@ export const parseSsInt = (text) => {
|
||||
export const parseSsFloat = (text) =>
|
||||
text
|
||||
? parseFloat(
|
||||
getFirstRegexpMatch(/([0-9,.]+)\s*$/, text.replace(/[^\d.]/g, "")),
|
||||
getFirstRegexpMatch(/([0-9,.]+)\s*$/, text.replace(/[^\d.]/g, ""))
|
||||
)
|
||||
: null;
|
||||
|
||||
@ -78,32 +78,32 @@ export default (options = {}) => {
|
||||
const rankeds = async (
|
||||
page = 1,
|
||||
priority = PRIORITY.BG_NORMAL,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(substituteVars(RANKEDS_URL, { page }), options, priority).then(
|
||||
(r) => {
|
||||
r.body = processRankeds(r.body);
|
||||
|
||||
return r;
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
const processPlayerProfile = (playerId, doc) => {
|
||||
cfDecryptEmail(doc);
|
||||
|
||||
let avatar = getImgUrl(
|
||||
opt(doc.querySelector(".column.avatar img"), "src", null),
|
||||
opt(doc.querySelector(".column.avatar img"), "src", null)
|
||||
);
|
||||
|
||||
let playerName = opt(
|
||||
doc.querySelector(".content .column:not(.avatar) .title a"),
|
||||
"innerText",
|
||||
"innerText"
|
||||
);
|
||||
playerName = playerName ? playerName.trim() : null;
|
||||
|
||||
let country = getFirstRegexpMatch(
|
||||
/^.*?\/flags\/([^.]+)\..*$/,
|
||||
opt(doc.querySelector(".content .column .title img"), "src"),
|
||||
opt(doc.querySelector(".content .column .title img"), "src")
|
||||
);
|
||||
country = country ? country.toUpperCase() : null;
|
||||
|
||||
@ -111,8 +111,8 @@ export default (options = {}) => {
|
||||
opt(
|
||||
doc.querySelector(".pagination .pagination-list li a.is-current"),
|
||||
"innerText",
|
||||
null,
|
||||
),
|
||||
null
|
||||
)
|
||||
);
|
||||
pageNum = !isNaN(pageNum) ? pageNum : null;
|
||||
|
||||
@ -120,8 +120,8 @@ export default (options = {}) => {
|
||||
opt(
|
||||
doc.querySelector(".pagination .pagination-list li:last-of-type"),
|
||||
"innerText",
|
||||
null,
|
||||
),
|
||||
null
|
||||
)
|
||||
);
|
||||
pageQty = !isNaN(pageQty) ? pageQty : null;
|
||||
|
||||
@ -130,31 +130,31 @@ export default (options = {}) => {
|
||||
/^\s*<strong>(?:[^:]+)\s*:?\s*<\/strong>\s*(.*)$/,
|
||||
opt(
|
||||
doc.querySelector(
|
||||
".columns .column:not(.is-narrow) ul li:nth-of-type(3)",
|
||||
".columns .column:not(.is-narrow) ul li:nth-of-type(3)"
|
||||
),
|
||||
"innerHTML",
|
||||
),
|
||||
),
|
||||
"innerHTML"
|
||||
)
|
||||
)
|
||||
);
|
||||
totalItems = !isNaN(totalItems) ? totalItems : 0;
|
||||
|
||||
let playerRank = parseSsInt(
|
||||
opt(
|
||||
doc.querySelector(
|
||||
".content .column ul li:first-of-type a:first-of-type",
|
||||
".content .column ul li:first-of-type a:first-of-type"
|
||||
),
|
||||
"innerText",
|
||||
),
|
||||
"innerText"
|
||||
)
|
||||
);
|
||||
playerRank = !isNaN(playerRank) ? playerRank : null;
|
||||
|
||||
let countryRank = parseSsInt(
|
||||
opt(
|
||||
doc.querySelector(
|
||||
'.content .column ul li:first-of-type a[href^="/global?country="]',
|
||||
'.content .column ul li:first-of-type a[href^="/global?country="]'
|
||||
),
|
||||
"innerText",
|
||||
),
|
||||
"innerText"
|
||||
)
|
||||
);
|
||||
countryRank = !isNaN(countryRank) ? countryRank : null;
|
||||
|
||||
@ -170,7 +170,7 @@ export default (options = {}) => {
|
||||
[...doc.querySelectorAll(".content .column ul li")]
|
||||
.map((li) => {
|
||||
const matches = li.innerHTML.match(
|
||||
/^\s*<strong>([^:]+)\s*:?\s*<\/strong>\s*(.*)$/,
|
||||
/^\s*<strong>([^:]+)\s*:?\s*<\/strong>\s*(.*)$/
|
||||
);
|
||||
if (!matches) return null;
|
||||
|
||||
@ -219,7 +219,7 @@ export default (options = {}) => {
|
||||
const item = mapping.find((m) => m.key === matches[1]);
|
||||
return item ? { ...item, value } : { label: matches[1], value };
|
||||
})
|
||||
.filter((s) => s),
|
||||
.filter((s) => s)
|
||||
)
|
||||
.reduce(
|
||||
(cum, item) => {
|
||||
@ -255,7 +255,7 @@ export default (options = {}) => {
|
||||
|
||||
return cum;
|
||||
},
|
||||
{ inactiveAccount: false, bannedAccount: false },
|
||||
{ inactiveAccount: false, bannedAccount: false }
|
||||
);
|
||||
|
||||
const scores = [...doc.querySelectorAll("table.ranking tbody tr")].map(
|
||||
@ -274,7 +274,7 @@ export default (options = {}) => {
|
||||
if (song) {
|
||||
const leaderboardId = parseInt(
|
||||
getFirstRegexpMatch(/leaderboard\/(\d+)/, song.href),
|
||||
10,
|
||||
10
|
||||
);
|
||||
ret.leaderboardId = leaderboardId ? leaderboardId : null;
|
||||
} else {
|
||||
@ -293,7 +293,7 @@ export default (options = {}) => {
|
||||
.replace(/&/g, "&")
|
||||
.replace(
|
||||
/<span class="__cf_email__" data-cfemail="[^"]+">\[email protected]<\/span>/g,
|
||||
"",
|
||||
""
|
||||
)
|
||||
.match(/^(.*?)\s*<span[^>]+>(.*?)<\/span>/)
|
||||
: null;
|
||||
@ -328,7 +328,7 @@ export default (options = {}) => {
|
||||
ret.timeSet = songDate ? dateFromString(songDate.title) : null;
|
||||
|
||||
const pp = parseSsFloat(
|
||||
opt(tr.querySelector("th.score .scoreTop.ppValue"), "innerText"),
|
||||
opt(tr.querySelector("th.score .scoreTop.ppValue"), "innerText")
|
||||
);
|
||||
ret.pp = !isNaN(pp) ? pp : null;
|
||||
|
||||
@ -337,9 +337,9 @@ export default (options = {}) => {
|
||||
/^\(([0-9.]+)pp\)$/,
|
||||
opt(
|
||||
tr.querySelector("th.score .scoreTop.ppWeightedValue"),
|
||||
"innerText",
|
||||
),
|
||||
),
|
||||
"innerText"
|
||||
)
|
||||
)
|
||||
);
|
||||
ret.ppWeighted = !isNaN(ppWeighted) ? ppWeighted : null;
|
||||
|
||||
@ -380,7 +380,7 @@ export default (options = {}) => {
|
||||
}
|
||||
|
||||
return ret;
|
||||
},
|
||||
}
|
||||
);
|
||||
const recentPlay =
|
||||
scores && scores.length && scores[0].timeSet ? scores[0].timeSet : null;
|
||||
@ -394,18 +394,18 @@ export default (options = {}) => {
|
||||
externalProfileUrl: opt(
|
||||
doc.querySelector(".content .column:not(.avatar) .title a"),
|
||||
"href",
|
||||
null,
|
||||
null
|
||||
),
|
||||
history: getFirstRegexpMatch(
|
||||
/data:\s*\[([0-9,]+)\]/,
|
||||
doc.body.innerHTML,
|
||||
doc.body.innerHTML
|
||||
),
|
||||
country,
|
||||
badges: [...doc.querySelectorAll(".column.avatar center img")].map(
|
||||
(img) => ({
|
||||
image: getImgUrl(img.src),
|
||||
description: img.title,
|
||||
}),
|
||||
})
|
||||
),
|
||||
rank: stats.rank ? stats.rank : null,
|
||||
countryRank: stats.countryRank ? stats.countryRank : null,
|
||||
@ -435,7 +435,7 @@ export default (options = {}) => {
|
||||
fetchHtml(
|
||||
substituteVars(PLAYER_PROFILE_URL, { playerId }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
).then((r) => {
|
||||
r.body = processPlayerProfile(playerId, r.body);
|
||||
|
||||
@ -451,17 +451,17 @@ export default (options = {}) => {
|
||||
const id = getFirstRegexpMatch(/\/(\d+)$/, a.href);
|
||||
|
||||
const avatar = getImgUrl(
|
||||
opt(tr.querySelector("td.picture img"), "src", null),
|
||||
opt(tr.querySelector("td.picture img"), "src", null)
|
||||
);
|
||||
|
||||
let country = getFirstRegexpMatch(
|
||||
/^.*?\/flags\/([^.]+)\..*$/,
|
||||
opt(tr.querySelector("td.player img"), "src", null),
|
||||
opt(tr.querySelector("td.player img"), "src", null)
|
||||
);
|
||||
country = country ? country.toUpperCase() : null;
|
||||
|
||||
let difference = parseSsInt(
|
||||
opt(tr.querySelector("td.diff"), "innerText", null),
|
||||
opt(tr.querySelector("td.diff"), "innerText", null)
|
||||
);
|
||||
difference = !isNaN(difference) ? difference : null;
|
||||
|
||||
@ -469,15 +469,15 @@ export default (options = {}) => {
|
||||
playerName = playerName || playerName === "" ? playerName.trim() : null;
|
||||
|
||||
let pp = parseSsFloat(
|
||||
opt(tr.querySelector("td.pp .scoreTop.ppValue"), "innerText"),
|
||||
opt(tr.querySelector("td.pp .scoreTop.ppValue"), "innerText")
|
||||
);
|
||||
pp = !isNaN(pp) ? pp : null;
|
||||
|
||||
let rank = parseSsInt(
|
||||
getFirstRegexpMatch(
|
||||
/^\s*#(\d+)\s*$/,
|
||||
opt(tr.querySelector("td.rank"), "innerText", null),
|
||||
),
|
||||
opt(tr.querySelector("td.rank"), "innerText", null)
|
||||
)
|
||||
);
|
||||
rank = !isNaN(rank) ? rank : null;
|
||||
|
||||
@ -491,7 +491,7 @@ export default (options = {}) => {
|
||||
pp,
|
||||
rank,
|
||||
};
|
||||
},
|
||||
}
|
||||
);
|
||||
|
||||
return { players: data };
|
||||
@ -501,12 +501,12 @@ export default (options = {}) => {
|
||||
country,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchHtml(
|
||||
substituteVars(COUNTRY_RANKING_URL, { country, page }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
).then((r) => {
|
||||
r.body = processCountryRanking(country, r.body);
|
||||
|
||||
@ -529,11 +529,11 @@ export default (options = {}) => {
|
||||
};
|
||||
|
||||
ret.player.playerInfo.avatar = getImgUrl(
|
||||
opt(tr.querySelector(".picture img"), "src", null),
|
||||
opt(tr.querySelector(".picture img"), "src", null)
|
||||
);
|
||||
|
||||
ret.score.rank = parseSsInt(
|
||||
opt(tr.querySelector("td.rank"), "innerText"),
|
||||
opt(tr.querySelector("td.rank"), "innerText")
|
||||
);
|
||||
if (isNaN(ret.score.rank)) ret.score.rank = null;
|
||||
|
||||
@ -541,7 +541,7 @@ export default (options = {}) => {
|
||||
if (player) {
|
||||
let country = getFirstRegexpMatch(
|
||||
/^.*?\/flags\/([^.]+)\..*$/,
|
||||
opt(player.querySelector("img"), "src", ""),
|
||||
opt(player.querySelector("img"), "src", "")
|
||||
);
|
||||
country = country ? country.toUpperCase() : null;
|
||||
if (country) {
|
||||
@ -551,14 +551,14 @@ export default (options = {}) => {
|
||||
|
||||
ret.player.name = opt(
|
||||
player.querySelector("span.songTop.pp"),
|
||||
"innerText",
|
||||
"innerText"
|
||||
);
|
||||
ret.player.name = ret.player.name
|
||||
? ret.player.name.trim().replace("'", "'")
|
||||
: null;
|
||||
ret.player.playerId = getFirstRegexpMatch(
|
||||
/\/u\/(\d+)((\?|&|#).*)?$/,
|
||||
opt(player, "href", ""),
|
||||
opt(player, "href", "")
|
||||
);
|
||||
ret.player.playerId = ret.player.playerId
|
||||
? ret.player.playerId.trim()
|
||||
@ -574,7 +574,7 @@ export default (options = {}) => {
|
||||
ret.score.timeSetString = opt(
|
||||
tr.querySelector("td.timeset"),
|
||||
"innerText",
|
||||
null,
|
||||
null
|
||||
);
|
||||
if (ret.score.timeSetString)
|
||||
ret.score.timeSetString = ret.score.timeSetString.trim();
|
||||
@ -602,7 +602,7 @@ export default (options = {}) => {
|
||||
const diffs = [...doc.querySelectorAll(".tabs ul li a")].map((a) => {
|
||||
let leaderboardId = parseInt(
|
||||
getFirstRegexpMatch(/leaderboard\/(\d+)$/, a.href),
|
||||
10,
|
||||
10
|
||||
);
|
||||
if (isNaN(leaderboardId)) leaderboardId = null;
|
||||
|
||||
@ -615,7 +615,7 @@ export default (options = {}) => {
|
||||
const currentDiffHuman = opt(
|
||||
doc.querySelector(".tabs li.is-active a span"),
|
||||
"innerText",
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
let diff = null;
|
||||
@ -628,20 +628,20 @@ export default (options = {}) => {
|
||||
|
||||
const songName = opt(
|
||||
doc.querySelector(
|
||||
".column.is-one-third-desktop .box:first-of-type .title a",
|
||||
".column.is-one-third-desktop .box:first-of-type .title a"
|
||||
),
|
||||
"innerText",
|
||||
null,
|
||||
null
|
||||
);
|
||||
|
||||
const imageUrl = getImgUrl(
|
||||
opt(
|
||||
doc.querySelector(
|
||||
".column.is-one-third-desktop .box:first-of-type .columns .column.is-one-quarter img",
|
||||
".column.is-one-third-desktop .box:first-of-type .columns .column.is-one-quarter img"
|
||||
),
|
||||
"src",
|
||||
null,
|
||||
),
|
||||
null
|
||||
)
|
||||
);
|
||||
|
||||
const songInfo = [
|
||||
@ -656,13 +656,13 @@ export default (options = {}) => {
|
||||
]
|
||||
.map((sid) => {
|
||||
let songInfoBox = doc.querySelector(
|
||||
".column.is-one-third-desktop .box:first-of-type",
|
||||
".column.is-one-third-desktop .box:first-of-type"
|
||||
);
|
||||
return {
|
||||
...sid,
|
||||
value: songInfoBox
|
||||
? songInfoBox.innerHTML.match(
|
||||
new RegExp(sid.label + ":\\s*<b>(.*?)</b>", "i"),
|
||||
new RegExp(sid.label + ":\\s*<b>(.*?)</b>", "i")
|
||||
)
|
||||
: null,
|
||||
};
|
||||
@ -708,7 +708,7 @@ export default (options = {}) => {
|
||||
|
||||
return cum;
|
||||
},
|
||||
{ imageUrl, stats: {} },
|
||||
{ imageUrl, stats: {} }
|
||||
);
|
||||
|
||||
const { stats, ...song } = songInfo;
|
||||
@ -718,9 +718,9 @@ export default (options = {}) => {
|
||||
opt(
|
||||
doc.querySelector(".pagination .pagination-list li:last-of-type"),
|
||||
"innerText",
|
||||
null,
|
||||
null
|
||||
),
|
||||
10,
|
||||
10
|
||||
);
|
||||
if (isNaN(pageQty)) pageQty = null;
|
||||
|
||||
@ -736,7 +736,7 @@ export default (options = {}) => {
|
||||
|
||||
let diffChartText = getFirstRegexpMatch(
|
||||
/'difficulty',\s*([0-9.,\s]+)\s*\]/,
|
||||
doc.body.innerHTML,
|
||||
doc.body.innerHTML
|
||||
);
|
||||
let diffChart = (diffChartText ? diffChartText : "")
|
||||
.split(",")
|
||||
@ -758,12 +758,12 @@ export default (options = {}) => {
|
||||
leaderboardId,
|
||||
page = 1,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchHtml(
|
||||
substituteVars(LEADERBOARD_URL, { leaderboardId, page }),
|
||||
options,
|
||||
priority,
|
||||
priority
|
||||
).then((r) => {
|
||||
r.body = processLeaderboard(leaderboardId, page, r.body);
|
||||
|
||||
|
@ -7,7 +7,7 @@ const CLIENT_ID = "u0swxz56n4iumc634at1osoqdk31qt";
|
||||
const TWITCH_AUTH_URL = "https://id.twitch.tv/oauth2";
|
||||
const AUTHORIZATION_URL =
|
||||
`${TWITCH_AUTH_URL}/authorize?client_id=${CLIENT_ID}&redirect_uri=${encodeURIComponent(
|
||||
ssrConfig.domain + "/twitch",
|
||||
ssrConfig.domain + "/twitch"
|
||||
)}&response_type=token` + "&scope=${scopes}&state=${state}";
|
||||
const VALIDATE_URL = `${TWITCH_AUTH_URL}/validate`;
|
||||
|
||||
@ -26,7 +26,7 @@ export default (options = {}) => {
|
||||
url,
|
||||
accessToken,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
url,
|
||||
@ -37,7 +37,7 @@ export default (options = {}) => {
|
||||
Authorization: `Bearer ${accessToken}`,
|
||||
},
|
||||
},
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
|
||||
const getAuthUrl = (state = "", scopes = "") =>
|
||||
@ -49,25 +49,25 @@ export default (options = {}) => {
|
||||
const validateToken = async (
|
||||
accessToken,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchJson(
|
||||
VALIDATE_URL,
|
||||
{ ...options, headers: { Authorization: `OAuth ${accessToken}` } },
|
||||
priority,
|
||||
priority
|
||||
);
|
||||
|
||||
const profile = async (
|
||||
accessToken,
|
||||
login,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchApi(
|
||||
substituteVars(PROFILE_URL, { login: encodeURIComponent(login) }),
|
||||
accessToken,
|
||||
priority,
|
||||
options,
|
||||
options
|
||||
);
|
||||
|
||||
const videos = async (
|
||||
@ -75,7 +75,7 @@ export default (options = {}) => {
|
||||
userId,
|
||||
type = "archive",
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchApi(
|
||||
substituteVars(VIDEOS_URL, {
|
||||
@ -84,20 +84,20 @@ export default (options = {}) => {
|
||||
}),
|
||||
accessToken,
|
||||
priority,
|
||||
options,
|
||||
options
|
||||
);
|
||||
|
||||
const streams = async (
|
||||
accessToken,
|
||||
userId,
|
||||
priority = PRIORITY.FG_LOW,
|
||||
options = {},
|
||||
options = {}
|
||||
) =>
|
||||
fetchApi(
|
||||
substituteVars(STREAMS_URL, { userId: encodeURIComponent(userId) }),
|
||||
accessToken,
|
||||
priority,
|
||||
options,
|
||||
options
|
||||
);
|
||||
|
||||
return {
|
||||
|
Reference in New Issue
Block a user