style: auto format

This commit is contained in:
github-actions[bot]
2024-05-10 14:46:15 +00:00
parent 8fcd6f79c9
commit 9af421ae2f
29 changed files with 43 additions and 43 deletions
+1 -1
View File
@@ -45,7 +45,7 @@ const ProcessItems = async (ctx, title, currentUrl) => {
const images = detailResponse.data.match(/src": '(.*?)',"width/g);
item.description = art(path.join(__dirname, 'templates/description.art'), {
images: images.map((i) => i.split("'")[1].replaceAll('\\/', '/')),
images: images.map((i) => i.split("'")[1].replaceAll(String.raw`\/`, '/')),
});
return item;
+1 -1
View File
@@ -126,7 +126,7 @@ async function handler(ctx) {
item.title = content('meta[property="og:title"]').prop('content');
item.description = '';
const enclosurePattern = '"(?:MIME|content)?Type":"([\\w]+/[\\w]+)".*?"(?:fileS|s)?ize":(\\d+),.*?"url":"([\\w-.:/?]+)"';
const enclosurePattern = String.raw`"(?:MIME|content)?Type":"([\w]+/[\w]+)".*?"(?:fileS|s)?ize":(\d+),.*?"url":"([\w-.:/?]+)"`;
const enclosureMatches = detailResponse.match(new RegExp(enclosurePattern, 'g'));
+2 -2
View File
@@ -85,9 +85,9 @@ const parseNewsList = async (url, ctx) => {
.map((u) => {
u = $(u);
const item = {
title: u.find('news\\:title').text(),
title: u.find(String.raw`news\:title`).text(),
link: u.find('loc').text(),
pubDate: parseDate(u.find('news\\:publication_date').text()),
pubDate: parseDate(u.find(String.raw`news\:publication_date`).text()),
};
return item;
});
+1 -1
View File
@@ -44,7 +44,7 @@ async function handler(ctx) {
url: listUrl,
});
const currentUrl = `${rootUrl}${listResponse.data.match(new RegExp('<span>' + category + '<\\/span><a href="(.*)" rel="tag"><\\/a>'))[1].split('"')[0]}`;
const currentUrl = `${rootUrl}${listResponse.data.match(new RegExp('<span>' + category + String.raw`<\/span><a href="(.*)" rel="tag"><\/a>`))[1].split('"')[0]}`;
const currentResponse = await got({
method: 'get',
+1 -1
View File
@@ -39,7 +39,7 @@ async function handler() {
.toArray()
.map((item) => {
item = $(item);
let description = item.find('dc\\:content').text();
let description = item.find(String.raw`dc\:content`).text();
description = $('<div>').html(description);
description.find('.vanilla-image-block').removeAttr('style');
description.find('.fancy-box').remove();
+1 -1
View File
@@ -23,7 +23,7 @@ const formatDate = (date, format) => dayjs(date).format(format);
const addFilters = (url, filters) => {
const keys = Object.keys(filters);
const filterStr = keys.map((k) => `/${k}/${filters[k]}`).join('');
const newUrl = url.replaceAll(new RegExp(`(/${keys.join('/\\w+|/')}/\\w+)`, 'g'), '');
const newUrl = url.replaceAll(new RegExp(`(/${keys.join(String.raw`/\w+|/`)}/\\w+)`, 'g'), '');
return `${newUrl}${/=/.test(newUrl) ? '' : '/='}${filterStr}`;
};
+1 -1
View File
@@ -37,7 +37,7 @@ function getItemList($, detailUrl, second) {
const data = JSON.parse(
decodeCipherText(encoded[1], encoded[2], encoded[3], encoded[4].split('|'), 0, {})
.match(/var down_urls=\\'(.*)\\'/)[1]
.replaceAll('\\\\"', '"')
.replaceAll(String.raw`\\"`, '"')
.replaceAll(/\\{3}/g, '')
);
// support secondary download address
+2 -2
View File
@@ -73,13 +73,13 @@ function decodeCipherText(p, a, c, k, e, d) {
},
];
e = function () {
return '\\w+';
return String.raw`\w+`;
};
c = 1;
}
while (c--) {
if (k[c]) {
p = p.replaceAll(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
p = p.replaceAll(new RegExp(String.raw`\b` + e(c) + String.raw`\b`, 'g'), k[c]);
}
}
return p;
+2 -2
View File
@@ -81,9 +81,9 @@ async function handler(ctx) {
url: i.link,
});
const description = detailResponse.data.match(/(\\u003C.*?)","/)[1].replaceAll('\\"', '"');
const description = detailResponse.data.match(/(\\u003C.*?)","/)[1].replaceAll(String.raw`\"`, '"');
i.description = description.replaceAll(/\\u[\da-f]{4}/gi, (match) => String.fromCharCode(Number.parseInt(match.replaceAll('\\u', ''), 16)));
i.description = description.replaceAll(/\\u[\da-f]{4}/gi, (match) => String.fromCharCode(Number.parseInt(match.replaceAll(String.raw`\u`, ''), 16)));
return i;
})
+2 -2
View File
@@ -57,9 +57,9 @@ async function handler(ctx) {
const href = $(item).find('a').attr('href');
let absolute_path;
if (href.search('\\./') === 0) {
if (href.search(String.raw`\./`) === 0) {
absolute_path = `${url}${href.slice(2)}`;
} else if (href.search('\\./') === 1) {
} else if (href.search(String.raw`\./`) === 1) {
absolute_path = `${baseUrl}${href.slice(3)}`;
} else {
absolute_path = href;
+1 -1
View File
@@ -39,7 +39,7 @@ async function handler() {
const $ = load(response.data);
const list = $('.lg\\:text-2xl')
const list = $(String.raw`.lg\:text-2xl`)
.toArray()
.map((item) => {
item = $(item).parent();
+1 -1
View File
@@ -95,7 +95,7 @@ async function handler() {
$('script')
.text()
.match(/urlWithParams: "(.*?)"/)[1]
.replaceAll('\\u002F', '/');
.replaceAll(String.raw`\u002F`, '/');
// Cache it again
cache.set(ENTRY_URL, dataSourceUrl);
+1 -1
View File
@@ -49,7 +49,7 @@ export const handler = async (ctx) => {
.match(/{"title":".*?"string":".*?"}}/g)
.slice(0, limit)
.map((item) => {
item = JSON.parse(item.replaceAll('\\\\"', '\\"').replaceAll('\\\\n', '').replaceAll('\\`', '`'));
item = JSON.parse(item.replaceAll(String.raw`\\"`, String.raw`\"`).replaceAll(String.raw`\\n`, '').replaceAll('\\`', '`'));
const $$ = unblurImages(load(item.excerpt));
+1 -1
View File
@@ -5,7 +5,7 @@ function parseJSONP(jsonpData) {
let jsonString = jsonpData.substring(startPos + 1, endPos + 1);
// remove escaped single quotes since they are not valid json
jsonString = jsonString.replaceAll("\\'", "'");
jsonString = jsonString.replaceAll(String.raw`\'`, "'");
return JSON.parse(jsonString);
} catch (error_) {
+1 -1
View File
@@ -56,7 +56,7 @@ async function handler(ctx) {
if (platforms.length || networks.length) {
const labels = {};
const labelPattern = '{label:"([^"]+)",value:(\\d+),href:a,meta:{mcDisplayWeight';
const labelPattern = String.raw`{label:"([^"]+)",value:(\d+),href:a,meta:{mcDisplayWeight`;
for (const m of currentResponse.match(new RegExp(labelPattern, 'g'))) {
const matches = m.match(new RegExp(labelPattern));
+1 -1
View File
@@ -20,7 +20,7 @@ async function handler(ctx) {
if (/^\/cn\/(cn|zh)/.test(path)) {
language = path.match(/^\/cn\/(cn|zh)/)[1];
path = path.match(new RegExp('\\/cn\\/' + language + '(.*)'))[1];
path = path.match(new RegExp(String.raw`\/cn\/` + language + '(.*)'))[1];
} else {
language = 'cn';
}
+1 -1
View File
@@ -55,7 +55,7 @@ async function handler(ctx) {
const content = load(detailResponse.data.match(/"content":"(.*)"}},"secondaryList":/)[1]);
content('img').each(function () {
content(this).attr('src', content(this).attr('src').replaceAll('\\"', ''));
content(this).attr('src', content(this).attr('src').replaceAll(String.raw`\"`, ''));
});
item.description = content.html();
+1 -1
View File
@@ -59,7 +59,7 @@ async function handler(ctx) {
const content = load(detailResponse.data.match(/"content":"(.*)","extraction_tags":/)[1]);
content('img').each(function () {
content(this).attr('src', content(this).attr('src').replaceAll('\\"', ''));
content(this).attr('src', content(this).attr('src').replaceAll(String.raw`\"`, ''));
});
item.description = content.html();
+1 -1
View File
@@ -19,7 +19,7 @@ const getApiUrl = async () => {
const apiBaseUrl = initResponse.data
.toString()
.match(/(?<=TWILL_API_BASE:").+?(?=")/)[0]
.replaceAll('\\u002F', '/');
.replaceAll(String.raw`\u002F`, '/');
return new URL(apiBaseUrl);
};
+1 -1
View File
@@ -63,7 +63,7 @@ async function handler(ctx) {
.match(/window\._rcState_ = (.*);/)[1];
const rcStateJson = JSON.parse(rcState);
const news = Object.values(rcStateJson.pagesV2.pages)[0];
item.description = news.data.newsStory.body.html.replaceAll('\\n', '<br>');
item.description = news.data.newsStory.body.html.replaceAll(String.raw`\n`, '<br>');
return item;
})
+1 -1
View File
@@ -40,7 +40,7 @@ const processItems = async (items, tryGet) =>
const { data: detailResponse } = await got(item.link);
const data = JSON.parse(detailResponse.match(/{\\"topic\\":(.*?)}]\\n"]\)<\/script>/)[1].replaceAll('\\"', '"'));
const data = JSON.parse(detailResponse.match(/{\\"topic\\":(.*?)}]\\n"]\)<\/script>/)[1].replaceAll(String.raw`\"`, '"'));
item.title = data.title;
item.link = data.url ?? new URL(`topic/${data.uid}`, rootUrl).href;
+2 -2
View File
@@ -68,9 +68,9 @@ async function handler(ctx) {
return {
title: item.find('title').text().trim(),
link: item.find('link').text().trim(),
author: item.find('dc\\:creator').text().trim(),
author: item.find(String.raw`dc\:creator`).text().trim(),
pubDate: parseDate(item.find('pubDate').text().trim()),
description: item.find('content\\:encoded').text().trim(),
description: item.find(String.raw`content\:encoded`).text().trim(),
};
});
+2 -2
View File
@@ -42,8 +42,8 @@ async function handler(ctx) {
.map((elem) => {
const item = $(elem);
const enclosure = item.find('enclosure').first();
const mediaContent = item.find('media\\:content').toArray()[0];
const thumbnail = item.find('media\\:thumbnail').toArray()[0];
const mediaContent = item.find(String.raw`media\:content`).toArray()[0];
const thumbnail = item.find(String.raw`media\:thumbnail`).toArray()[0];
return {
title: item.find('title').text(),
description: item.find('description').text(),
+1 -1
View File
@@ -40,7 +40,7 @@ async function handler(ctx) {
title: item.find('title').text(),
link: item.find('guid').text(),
author: item
.find('dc\\:creator')
.find(String.raw`dc\:creator`)
.html()
.match(/CDATA\[(.*?)]/)[1],
category: item
+3 -3
View File
@@ -47,7 +47,7 @@ async function handler(ctx) {
return {
link: item.find('guid').text(),
author: item.find('itunes\\:author').text(),
author: item.find(String.raw`itunes\:author`).text(),
};
});
@@ -85,8 +85,8 @@ async function handler(ctx) {
return {
title: 'SupChina - Podcasts',
link: `${rootUrl}/podcasts`,
itunes_author: $('channel itunes\\:author').first().text(),
image: $('itunes\\:image').attr('href'),
itunes_author: $(String.raw`channel itunes\:author`).first().text(),
image: $(String.raw`itunes\:image`).attr('href'),
item: items,
};
}
+1 -1
View File
@@ -41,7 +41,7 @@ async function handler() {
link,
guid: $item.find('guid').text(),
pubDate: parseDate($item.find('pubDate').text()),
author: $item.find('dc\\:creator').text(),
author: $item.find(String.raw`dc\:creator`).text(),
_header_image: $item.find('enclosure').attr('url'),
};
})
+3 -3
View File
@@ -37,10 +37,10 @@ async function handler() {
.map((item) => {
item = $(item);
return {
title: item.find('news\\:title').text(),
pubDate: parseDate(item.find('news\\:publication_date').text()),
title: item.find(String.raw`news\:title`).text(),
pubDate: parseDate(item.find(String.raw`news\:publication_date`).text()),
category: item
.find('news\\:keywords')
.find(String.raw`news\:keywords`)
.text()
.split(',')
.map((item) => item.trim()),
+1 -1
View File
@@ -5,7 +5,7 @@ function parseJSONP(jsonpData) {
let jsonString = jsonpData.substring(startPos + 1, endPos + 1);
// remove escaped single quotes since they are not valid json
jsonString = jsonString.replaceAll("\\'", "'");
jsonString = jsonString.replaceAll(String.raw`\'`, "'");
return JSON.parse(jsonString);
} catch (error_) {
+5 -5
View File
@@ -132,7 +132,7 @@ class ExtractMetadata {
private static genExtractFunc = (
varName: string,
{
valuePattern = '\\w+',
valuePattern = String.raw`\w+`,
assignPattern = '=',
allowNotFound = false,
multiple = false,
@@ -170,9 +170,9 @@ class ExtractMetadata {
};
private static commonMetadataToBeExtracted = {
showType: this.genExtractFunc('item_show_type', { valuePattern: '\\d+' }),
realShowType: this.genExtractFunc('real_item_show_type', { valuePattern: '\\d+' }),
createTime: this.genExtractFunc('ct', { valuePattern: '\\d+', allowNotFound: true }),
showType: this.genExtractFunc('item_show_type', { valuePattern: String.raw`\d+` }),
realShowType: this.genExtractFunc('real_item_show_type', { valuePattern: String.raw`\d+` }),
createTime: this.genExtractFunc('ct', { valuePattern: String.raw`\d+`, allowNotFound: true }),
sourceUrl: this.genExtractFunc('msg_source_url', { valuePattern: `https?://[^'"]*`, allowNotFound: true }),
};
@@ -207,7 +207,7 @@ class ExtractMetadata {
private static audioMetadataToBeExtracted = {
voiceId: this.genExtractFunc('voiceid', { assignPattern: ':' }),
duration: this.genExtractFunc('duration', { valuePattern: '\\d*', assignPattern: ':', allowNotFound: true }),
duration: this.genExtractFunc('duration', { valuePattern: String.raw`\d*`, assignPattern: ':', allowNotFound: true }),
};
// never seen a audio article containing multiple audio, waiting for examples