MCPcopy Index your code
hub / github.com/MALSync/MALSync / addPageUrls

Function addPageUrls

webpackConfig/autoUrls.mjs:128–157  ·  view source on GitHub ↗
(page, urls)

Source from the content-addressed store, hash-verified

126}
127
128function addPageUrls(page, urls) {
129 logFoundUrls(page, urls, URL_TYPES.PAGE);
130
131 let file = JSON.parse(fs.readFileSync(path.resolve(`./src/pages/${page}/meta.json`), 'utf8'));
132
133 let addedCount = 0;
134 const existingUrls = [];
135 for (const url of urls) {
136 if (!file.urls.match.includes(url)) {
137 file.urls.match.push(url);
138 addedCount++;
139 } else {
140 existingUrls.push(url);
141 }
142 }
143
144 if (existingUrls.length > 0) {
145 console.log(`[${page}] URLs already exist:\n ${existingUrls.join(',\n ')}`);
146 }
147
148 if (addedCount > 0) {
149 fs.writeFileSync(
150 path.resolve(`./src/pages/${page}/meta.json`),
151 JSON.stringify(file, null, 2) + '\n',
152 );
153 console.log(`[${page}] Added ${addedCount} new URLs.`);
154 } else {
155 console.log(`[${page}] No new URLs added.`);
156 }
157}
158
159function addChibiUrls(page, urls, mainName = 'main.ts') {
160 logFoundUrls(page, urls, URL_TYPES.CHIBI);

Callers 2

zoroFunction · 0.85
kickassanimeFunction · 0.85

Calls 1

logFoundUrlsFunction · 0.85

Tested by

no test coverage detected