MCPcopy Create free account
hub / github.com/NobyDa/Script / QueryRating

Function QueryRating

Surge/JS/Bili_Auto_Regions.js:156–189  ·  view source on GitHub ↗
(body, play)

Source from the content-addressed store, hash-verified

154}
155
156async function QueryRating(body, play) {
157 try {
158 const ratingEnabled = $.read('BiliDoubanRating') === 'false';
159 if (!ratingEnabled && play.title && body.data && body.data.badge_info) {
160 const [t1, t2] = await Promise.all([
161 GetRawInfo(play.title.replace(/\uff08[\u4e00-\u9fa5]+\u5340\uff09/, '')),
162 GetRawInfo(play.origin_name)
163 ]);
164 const exYear = body.data.publish.release_date_show.split(/^(\d{4})/)[1];
165 const info1 = (play.staff && play.staff.info) || '';
166 const info2 = (play.actor && play.actor.info) || '';
167 const info3 = (play.celebrity && play.celebrity.map(n => n.name).join('/')) || '';
168 const filterInfo = [play.title, play.origin_name, info1 + info2 + info3, exYear];
169 const [rating, folk, name, id, other] = ExtractMovieInfo([...t1, ...t2], filterInfo);
170 const limit = JSON.stringify(body.data.modules)
171 .replace(/"\u53d7\u9650"/g, `""`).replace(/("area_limit":)1/g, '$10');
172 body.data.modules = JSON.parse(limit);
173 body.data.detail = body.data.new_ep.desc.replace(/连载中,/, '');
174 body.data.badge_info.text = `⭐️ 豆瓣:${!$.is403 ? `${rating || '无评'}分 (${folk || '无评价'})` : `查询频繁!`}`;
175 body.data.evaluate = `${body.data.evaluate || ''}\n\n豆瓣评分搜索结果: ${JSON.stringify(other, 0, 1)}`;
176 body.data.new_ep.desc = name;
177 body.data.styles.unshift({
178 name: "⭐️ 点击此处打开豆瓣剧集详情页",
179 url: `https://m.douban.com/${id ? `movie/subject/${id}/` : `search/?query=${encodeURI(play.title)}`}`
180 });
181 }
182 } catch (err) {
183 console.log(`Douban rating: \n${err}\n`);
184 } finally {
185 $done({
186 body: JSON.stringify(body)
187 });
188 }
189}
190
191function ExtractMovieInfo(ret, fv) {
192 const sole = new Set(ret.map(s => JSON.stringify(s))); //delete duplicate

Callers 1

EnvInfoFunction · 0.85

Calls 5

GetRawInfoFunction · 0.85
ExtractMovieInfoFunction · 0.85
readMethod · 0.45
stringifyMethod · 0.45
logMethod · 0.45

Tested by

no test coverage detected