()
| 25 | } |
| 26 | |
| 27 | const 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 | |
| 50 | requestRatings() |
| 51 | .then(data => { |
no test coverage detected