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

Function requestRatings

Disney/DisneyRating.js:27–48  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

25}
26
27const requestRatings = async () => {
28 if (consoleLog) console.log("Disney Original Body:\n" + obj);
29 obj = JSON.parse(obj);
30 const sliced = obj?.data?.page?.actions?.[0]?.internalTitle?.split(' - ');
31 let title = sliced?.[0] || obj?.data?.page?.visuals?.title;
32 if (title) {
33 title = title.replace(/.+?:\s|\s?\(.+?\)\s?/g,'');
34 } else {
35 throw 'NO TITLE';
36 }
37 const year = obj?.data?.page?.visuals?.metastringParts?.releaseYearRange?.startYear;
38 const type = (sliced?.[1]?.startsWith('s') && 'series') || (sliced?.[1] == 'movie' && 'movie');
39 const IMDb = await requestIMDbRating(title, year, type);
40 const Douban = await requestDoubanRating(IMDb.id);
41 const IMDbrating = IMDb.msg.rating;
42 const tomatoes = IMDb.msg.tomatoes;
43 const country = IMDb.msg.country;
44 // const awards = IMDb.msg.awards;
45 const doubanRating = Douban.rating;
46 // const message = `${awards.length > 0 ? awards + "\n" : ""}${country}\n${IMDbrating}\n${doubanRating}${tomatoes.length > 0 ? "\n" + tomatoes + "\n" : "\n"}`;
47 return { country, tomatoes, IMDbrating, doubanRating };
48}
49
50requestRatings()
51 .then(data => {

Callers 1

DisneyRating.jsFile · 0.85

Calls 3

requestIMDbRatingFunction · 0.85
requestDoubanRatingFunction · 0.85
logMethod · 0.45

Tested by

no test coverage detected