Comments (2)
I can confirm this issue, awards()
always returns an empty array.
from imdbphp.
as a courtesy to the users here i will share my awards method that uses GraphQL
I hope that somebody will use it.
If you need additional info i explained it all in my wiki page
https://github.com/duck7000/imdbphp6/wiki/Title-class
Remember that it might be different from the award method use here
#-------------------------------------------------------[ Awards ]---
/**
* Get all awards for a title
* @param $winsOnly Default: false, set to true to only get won awards
* @param $event Default: "" fill eventId Example " ev0000003" to only get Oscars
* Possible values for $event:
* ev0000003 (Oscar)
* ev0000223 (Emmy)
* ev0000292 (Golden Globe)
* @return array[festivalName][0..n] of
* array[awardYear,awardWinner(bool),awardCategory,awardName,awardNotes
* array awardPerons[creditId,creditName,creditNote],awardOutcome]
* Array
(
[Academy Awards, USA] => Array
(
[0] => Array
(
[awardYear] => 1972
[awardWinner] =>
[awardCategory] => Best Picture
[awardName] => Oscar
[awardPerons] => Array
(
[0] => Array
(
[creditId] => nm0000040
[creditName] => Stanley Kubrick
[creditNote] => screenplay/director
)
)
[awardNotes] => Based on the novel
[awardOutcome] => Nominee
)
)
)
* @see IMDB page / (TitlePage)
*/
public function award($winsOnly = false, $event = "")
{
$winsOnly = $winsOnly === true ? "WINS_ONLY" : "null";
$event = !empty($event) ? "events: " . '"' . trim($event) . '"' : "";
if (empty($this->awards)) {
$query = <<<EOF
query Award(\$id: ID!) {
title(id: \$id) {
awardNominations(
first: 9999
sort: {by: PRESTIGIOUS, order: DESC}
filter: {wins: $winsOnly $event}
) {
edges {
node {
award {
event {
text
}
text
category {
text
}
eventEdition {
year
}
notes {
plainText
}
}
isWinner
awardedEntities {
... on AwardedTitles {
secondaryAwardNames {
name {
id
nameText {
text
}
}
note {
plainText
}
}
}
}
}
}
}
}
}
EOF;
$data = $this->graphql->query($query, "Award", ["id" => "tt$this->imdbID"]);
foreach ($data->title->awardNominations->edges as $edge) {
$eventName = isset($edge->node->award->event->text) ? $edge->node->award->event->text : '';
$eventEditionYear = isset($edge->node->award->eventEdition->year) ? $edge->node->award->eventEdition->year : '';
$awardName = isset($edge->node->award->text) ? $edge->node->award->text : '';
$awardCategory = isset($edge->node->award->category->text) ? $edge->node->award->category->text : '';
$awardNotes = isset($edge->node->award->notes->plainText) ? $edge->node->award->notes->plainText : '';
$awardIsWinner = $edge->node->isWinner;
$conclusion = $awardIsWinner === true ? "Winner" : "Nominee";
//credited persons
$persons = array();
if ($edge->node->awardedEntities->secondaryAwardNames !== null) {
foreach ($edge->node->awardedEntities->secondaryAwardNames as $creditor) {
$creditName = isset($creditor->name->nameText->text) ? $creditor->name->nameText->text : '';
$creditId = isset($creditor->name->id) ? $creditor->name->id : '';
$creditNote = isset($creditor->note->plainText) ? $creditor->note->plainText : '';
$persons[] = array(
'creditId' => str_replace('nm', '', $creditId),
'creditName' => $creditName,
'creditNote' => trim($creditNote, " ()")
);
}
}
$this->awards[$eventName][] = array(
'awardYear' => $eventEditionYear,
'awardWinner' => $awardIsWinner,
'awardCategory' => $awardCategory,
'awardName' => $awardName,
'awardNotes' => $awardNotes,
'awardPerons' => $persons,
'awardOutcome' => $conclusion
);
}
}
return $this->awards;
}
from imdbphp.
Related Issues (20)
- New bio page HOT 21
- Cache filesize is too big HOT 2
- Cache: ERROR: unlink(/cache/imdb_cache/title.tt17235912): No such file or directory HOT 1
- Tltle.php of imdbphp gives error! HOT 2
- keywords_all() no longer returns any data? HOT 1
- Some kind of documentation on GraphQL? HOT 6
- Sharing methods that are converted to GraphQL HOT 5
- imdb graphQL possibleTypes HOT 1
- Miscellaneous Sites not parsing / different Markup HOT 1
- PHP Warning: Undefined array key 1 in Title.php on line 2470 HOT 1
- Episode Listing not working HOT 10
- Imdb api image parameters
- Advanced Title Search No Longer Works
- Problem with apostrophe
- Disk quota
- Is searching by type broken? HOT 6
- Trailer method in Title class is broken HOT 5
- Error api.graphql.imdb.com HOT 1
- Help : Failed to connect to .... http://akas.imdb HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from imdbphp.