Replies: 3 comments
-
|
If you want to do a PR, I am open to any changes. I don't think I will work on this script myself in the next few months, don't really have much time at the moment and to many other projects. I am not sure if I remember correctly, but I believe when you type in the search field on www.rottentomatoes.com, it uses the Algolia API to show the suggestions and that's how I found it. |
Beta Was this translation helpful? Give feedback.
-
|
The XHR works. I was just blocked. The threshold is very low. Interestingly, Canada allowed for more experimenting. So you saw the request in Network tab, but how did you get the idea to look for the API keys in that global var? |
Beta Was this translation helpful? Give feedback.
-
|
Thanks for the PRs! Probably just recursively looped over |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Edit: see new comment below.
There is a bug at `@739`, repeated in "tv" `@807`. langBefore will include "lc-main=". It's creating a cookie: lc-main=lc-main=en-US
I believe there should be
index [1]I wanted to create a PR, but don't know which way you'd want to go as there is more to the cookie:
The cookie, as it is restored, is valid only for the current IMDb page. It will not be seen by any other page on IMDb.
The `@749`:
document.cookie = 'lc-main=' + langBeforeshould bedocument.cookie = 'lc-main=' + langBefore + ';path=/',also probably an expiration
;expires=<e.g. a year ahead>, as now it's restored to a session cookie.There is a new API now,
cookieStore.set/cookieStore.get, which is easy to use for restoration.But after playing around I realized it does not really matter. The only time the lc-main cookie was doing something, was when I selected e.g. "DE" in top-right option and visited a page without /de/ in path. The cookie caused a redirect:
https://www.imdb.com/title/tt0093409/ -> https://www.imdb.com/de/title/tt0093409/
(btw. Maybe you can add
// @match https://www.imdb.com/*/title/*, it seems to work.)And on the other hand, the cookie is ignored for getting the localized version (which I am after).
So maybe you can remove the cookie stuff all together?
Or, the whole XHR section...
About these two conditions:
if (pageNotEnglish || pageNotMovieHomePage) {When
navigator.language, IP, or logged-in user lang is not en-US (pageNotEnglish), the LD's name property is still "original". EN for EN movie.i.e. There is no difference in name property of LD while visiting the site in various languages.
Instead, the alternateName would hold the localized name. For EN visitor and EN movie, alternateName is undefined.
btw. `@763`, there is a precedence of alternateName, a localized one, over EN name, which I don't think is desirable.
And for the pageNotMovieHomePage, I can't seem to fetch the https://www.imdb.com/title/tt0093409/ from a sub page https://www.imdb.com/title/tt0093409/reference/ or anywhere else at all. I am getting 202 with no usable body. Maybe the IMDb got sick of me playing around, or it's a protection against scraping?
So it seems, the whole XHR is not helpful and could be removed. I found a way around anyway, but I don't think you need this XHR for the purpose of this script.
And some other stuff I noticed:
`@1425`
if (document.location.href === 'https://www.rottentomatoes.com/') {to
if (document.location.hostname.includes('rottentomatoes.com') {I can seem to get the algo keys from any RT subpage.
flixster is gone.
`@622`
arr[0] = await addFlixsterEMS(arr[0])can be commented-out, or just the XHR inside, to let those who have cached some movies to still see cached data.a regex `@730` and `@770`:
document.title.match(/(.+?)\s+(\((\d+)\))? - IMDb/)I guess the idea is to match a title without a year? It does not work without a year because of an extra space. Try
/(.+?)(?:\s+\((\d+)\))? - /(and index on next line 3 -> 2)and for TVShows I would propose:
/(.+?)(?:\s+\(.*?(\d{4}).*\))? - /if more universal is desired too.All line numbers correspond to commit 0e21ec9
But what I really would like to know, how did you managed to find the Algolia?
I was also missing the audience - user score, that's how I ended up here.
Congrats on that. RT does actually hide the score in double DOM Shadow. It's not in fetch/XHR. Can't be scrapped this way.
I do already have two other APIs for RT. But one is missing the audience score and other is only showing it sometimes.
Though I have a lot of other data from those APIs. Some IDs. I wonder if I can use some of it in the search query of Algolia to get 100% and single result.
Beta Was this translation helpful? Give feedback.
All reactions