-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting series imdbid by episode id #37
Comments
Mm i don't think that is possible, the GraphQL API query only is possible on Title and Name not on Episode In other words a query on episode is not possible AFAIK What might be possible is to use the search on the series name (if you know that) to get the series id GraphQL API also has a advanced search maybe you can use that? I didn't include this in this version as nobody uses this here |
Got it. Following works fine if the queried content is
|
Full PHP code (may be not fitting 100% into this project but for documentation purposes may be helpful). Still work in progress. public function getBaseData() {
$query = "query TitleYear(\$id: ID!)
{
title(id: \$id) {
countriesOfOrigin {
countries {
id
text
}
}
ratingsSummary {
aggregateRating
voteCount
}
titleGenres {
genres {
genre {
text
}
}
}
plot {
plotText {
plainText
}
}
titleText {
text
}
originalTitleText {
text
}
titleType {
text
}
releaseYear {
year
endYear
}
series {
episodeNumber {
episodeNumber
seasonNumber
}
series {
id
}
}
}
}";
$data = $this->sendRequest($query, "TitleYear", ["id" => $this->imdbId]);
[...] |
Mm you query this all with a imdbid, so yes that works. $this->imdbid is used in this case Or did you use that epidsode id to query above function? As a matter of fact such episode is also an title id of course so yes that might be working. Never thought of it this way before I don't see any language or country related in your code? |
Exactly. I used the episode id for that query and it works fine. Reply is (used {
"data": {
"title": {
"countriesOfOrigin": null,
"ratingsSummary": {
"aggregateRating": null,
"voteCount": 0
},
"titleGenres": {
"genres": [
{
"genre": {
"text": "Adventure"
}
},
{
"genre": {
"text": "Drama"
}
},
{
"genre": {
"text": "Sci-Fi"
}
}
]
},
"plot": {
"plotText": {
"plainText": "The 2005 series of Doctor Who ended in 2021 series 13. The new Doctor Who is Doctor Who 2023 - Series 1, with the first 4 episodes in 2023 and returning in May 2024"
}
},
"titleText": {
"text": "Folge #14.1"
},
"originalTitleText": {
"text": "Episode #14.1"
},
"titleType": {
"text": "TV Episode",
"id": "tvEpisode"
},
"releaseYear": {
"year": 2024,
"endYear": null
},
"series": {
"episodeNumber": {
"episodeNumber": 1,
"seasonNumber": 14
},
"series": {
"id": "tt0436992"
}
}
}
},
"extensions": {
"disclaimer": "Public, commercial, and/or non-private use of the IMDb data provided by this API is not allowed. For limited non-commercial use of IMDb data and the associated requirements see https://help.imdb.com/article/imdb/general-information/can-i-use-imdb-data-in-my-software/G5JTRESSHJBBHTGX#",
"experimentalFields": {
"janet": [],
"markdown": [],
"ratings": []
}
}
}
I'm handling the http request curl stuff upstream in another function. As I said, I started to writting my own lib so everything fits best. Furthermore I'm trying to simplify some things. Curl is initialized like that (with the language headers). private function initCurl() {
$this->ch = curl_init();
curl_setopt($this->ch, CURLOPT_URL, $this->baseurl);
curl_setopt($this->ch, CURLOPT_POST, true);
curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($this->ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:47.0) Gecko/20100101 Firefox/47.0");
$headers = [
"Content-Type: application/json",
"X-Imdb-User-Language: de-DE",
"X-Imdb-User-Country: DE"
];
curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers);
} |
oh i see, you add the language and country to the headers array of course.. Did you check which fields are affected by those headers? Like i said before some fields are affected some are not so it is unclear when it does or not. Sometimes imdb states that it is affected but the results are the same. I can implant those headers in my version but i doubt that anyone is going to use it (at least not the current users that i know of) |
Supported languages can be extracted by language picker on the website easily. Full supported
Partial supported
This gives us following valid language codes.
As far I've seen it affects only plots ( I'm a bit unsure about genres because the website translates them (I'm not interested into translated genres). But looks like they are still in original language and are not affected by the language headers. For the following response the {
"data": {
"title": {
"countriesOfOrigin": {
"countries": [
{
"id": "US",
"text": "United States"
}
]
},
"ratingsSummary": {
"aggregateRating": 9,
"voteCount": 852345
},
"titleGenres": {
"genres": [
{
"genre": {
"text": "Crime"
}
},
{
"genre": {
"text": "Drama"
}
}
]
},
"plot": {
"plotText": {
"plainText": "Un miembro del jurado trata de evitar un error judicial obligando al resto del jurado a reconsiderar las pruebas."
}
},
"titleText": {
"text": "12 hombres sin piedad"
},
"originalTitleText": {
"text": "12 Angry Men"
},
"titleType": {
"text": "Movie",
"id": "movie"
},
"releaseYear": {
"year": 1957,
"endYear": null
},
"series": null
}
},
"extensions": {
"disclaimer": "Public, commercial, and/or non-private use of the IMDb data provided by this API is not allowed. For limited non-commercial use of IMDb data and the associated requirements see https://help.imdb.com/article/imdb/general-information/can-i-use-imdb-data-in-my-software/G5JTRESSHJBBHTGX#",
"experimentalFields": {
"janet": [],
"markdown": [],
"ratings": []
}
}
} |
I added language to some fields in the GraphQL query. It's easier to see which content is affected by the language headers. Request with {
"data":{
"title":{
"countriesOfOrigin":{
"countries":[
{
"id":"US",
"text":"United States"
},
{
"id":"CN",
"text":"China"
}
]
},
"ratingsSummary":{
"aggregateRating":7.3,
"voteCount":693894
},
"titleGenres":{
"genres":[
{
"genre":{
"text":"Action",
"language":{
"id":"en-US"
}
}
},
{
"genre":{
"text":"Adventure",
"language":{
"id":"en-US"
}
}
},
{
"genre":{
"text":"Fantasy",
"language":{
"id":"en-US"
}
}
},
{
"genre":{
"text":"Sci-Fi",
"language":{
"id":"en-US"
}
}
},
{
"genre":{
"text":"War",
"language":{
"id":"en-US"
}
}
}
]
},
"plot":{
"plotText":{
"plainText":"Eine Amazonenprinzessin verlässt ihre Insel, um die Welt zu erkunden, und wird zur Superheldin."
},
"language":{
"id":"de-DE"
}
},
"titleText":{
"text":"Wonder Woman"
},
"originalTitleText":{
"text":"Wonder Woman"
},
"titleType":{
"text":"Movie",
"id":"movie"
},
"releaseYear":{
"year":2017,
"endYear":null
},
"series":null
}
},
"extensions":{
"disclaimer":"Public, commercial, and/or non-private use of the IMDb data provided by this API is not allowed. For limited non-commercial use of IMDb data and the associated requirements see https://help.imdb.com/article/imdb/general-information/can-i-use-imdb-data-in-my-software/G5JTRESSHJBBHTGX#",
"experimentalFields":{
"janet":[
],
"ratings":[
],
"markdown":[
]
}
}
} As you can see |
Ah i see, thanks! I did get the impression that all languages are supported but as far as i can see now there are only a few languages, i didn't know that. So even if you add a language that is supported there is still no guarantee that you will get it translated as it might not be available. I'm already implanting this in my version (I'm not sure it ever will be used by a user, but just in case) so i will add the short list of languages and a warning about not being translated. |
Checking the language id in response should help for reliable results. As far I remember fallback language is always |
Did you use both country and language in headers? if both can i have the country codes you find as well? |
Just to be sure I'm always use both language headers.
The value for the second header should be the second part of the language code always. I'm wondering GraphQL API will deliver translated genres in the future. If yes, it can be easily checked by genre's language id. |
Ah i didn't think it would be that easy about the country codes though I don't think genres will be translated as everybody knows them by their English name i guess |
Thought the same until IMDb website started to translate them as well which looks very akward... |
I tested my language and country implantation and it only seems to work on title, plotoutline and more like this (only titles) You might be using this version now this hurtle is out of the way, but i aspect that you are rather using your own version Well thanks again for your support! |
Maybe more fields in the future. I think IMDb tries going more international and covering localized content (like TheTBDB). We will see.
Yep, it's better for me to use my own code. I always try to use as less dependencies as possible.
You're welcome. Thank you too for the support and all the provided information. Your project is very helpful for my own stuff and saved me a lot of time. Just ping me if I can help with something else here. :) |
Sure will do |
Is there an elegant way to get the imdbid by only knowing the id of a specific episode? In the old project I used the
get_episode_details()
method but this method is broken for a while and doesn't rely on graphQL queries.For example I only have
tt28289436
(episode) and wantstt0436992
(series).I searched in this project but couldn't find a fitting graphQL query so far.
The text was updated successfully, but these errors were encountered: