diff --git a/Tests/MovieParser/Imdb/Matcher/AntMan-awards.html b/Tests/MovieParser/Imdb/Matcher/AntMan-awards.html new file mode 100644 index 0000000..8bc77ce --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/AntMan-awards.html @@ -0,0 +1,2479 @@ + + + + + + + + + + + + + + + + + Ant-Man - Awards - IMDb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+ + +
+
+ + + + + + +
+ + + +
+ + +
+
+ + + + +
+
+
+
+
+ Ant-Man Poster + +
+

+ + (2015) + +

+
+ +

Awards

+
+
+ +
+

+ BAFTA Awards + 2016 +

+ + + + + +
+ Nominated
+ BAFTA Film Award +
+ Best Achievement in Special Visual Effects
+ Jake Morrison +
+ Greg Steele +
+ Daniel Sudick +
+ Alex Wuttke +
+
+
+

+ Academy of Science Fiction, Fantasy & Horror Films, USA + 2016 +

+ + + + + + + + + + + + + + + + + + + + + +
+ Won
+ Saturn Award +
+ Best Comic-to-Film Motion Picture
+
+ Nominated
+ Saturn Award +
+ Best Director
+ Peyton Reed +
+
+ Best Actor
+ Paul Rudd +
+
+ Best Supporting Actress
+ Evangeline Lilly +
+
+ Best Supporting Actor
+ Michael Douglas +
+
+ Best Editing
+ Dan Lebental +
+ Colby Parker Jr. +
+
+
+

+ American Cinema Editors, USA + 2016 +

+ + + + + +
+ Nominated
+ Eddie +
+ Best Edited Feature Film - Comedy
+ Dan Lebental +
+ Colby Parker Jr. +
+
+
+

+ Broadcast Film Critics Association Awards + 2016 +

+ + + + + +
+ Nominated
+ Critics Choice Award +
+ Best Actor in an Action Movie
+ Paul Rudd +
+
+
+

+ Edda Awards, Iceland + 2016 +

+ + + + + +
+ Nominated
+ Edda Award +
+ Best Make Up (Gerfi ársins)
+ Heba Thorisdottir +
+
+
+

+ Empire Awards, UK + 2016 +

+ + + + + + + + +
+ Nominated
+ Empire Award +
+ Best Comedy
+
+ Best Visual Effects
+
+
+

+ Georgia Film Critics Association (GFCA) + 2016 +

+ + + + + +
+ Won
+ Oglethorpe Award for Excellence in Georgia Cinema +
+ + Peyton Reed +
+ Edgar Wright +
+ Joe Cornish +
+ Adam McKay +
+ Paul Rudd +
+
+
+

+ Golden Schmoes Awards + 2015 +

+ + + + + + + + + + + +
+ Nominated
+ Golden Schmoes +
+ Biggest Surprise of the Year
+
+ Favorite Movie Poster of the Year
+
+ Best Line of the Year
+
+ "Baskin Robbins always finds out." +
+
+
+

+ Hollywood Music In Media Awards (HMMA) + 2015 +

+ + + + + +
+ Nominated
+ HMMA Award +
+ Best Original Score - Sci-Fi/Fantasy Film
+ Christophe Beck +
+
+
+

+ IGN Summer Movie Awards + 2015 +

+ + + + + +
+ Nominated
+ IGN People's Choice Award +
+ Best Comic Book Adaptation Movie
+
+
+

+ Jupiter Award + 2016 +

+ + + + + + + + +
+ Nominated
+ Jupiter Award +
+ Best International Actor
+ Paul Rudd +
+
+ Best International Film
+
+
+

+ Kids' Choice Awards, USA + 2016 +

+ + + + + +
+ Nominated
+ Blimp Award +
+ Favorite Movie
+ Marvel Studios +
+
+
+

+ Motion Picture Sound Editors, USA + 2016 +

+ + + + + +
+ Nominated
+ Golden Reel Award +
+ Best Sound Editing - Sound Effects and Foley in a Feature Film
+ Shannon Mills + (supervising sound editor) +
+ Daniel Laurie + (supervising sound editor) +
+ James Likowski + (supervising foley editor) +
+ David Farmer + (sound designer) +
+ David C. Hughes + (sound designer) +
+ Dan O'Connell + (foley artist) +
+ John T. Cucci + (foley artist) +
+ Sean England + (foley artist) +
+ Ronni Brown + (foley artist) +
+ Josh Gold + (sound effects editor) +
+ Jack Whittaker + (sound effects editor) +
+ Bob Kellough + (sound effects editor) +
+ Nia Hansen + (sound effects editor) +
+ Jeremy Bowker + (sound effects editor) +
+ Dee Selby + (foley editor) +
+
+
+

+ MTV Movie Awards + 2016 +

+ + + + + +
+ Nominated
+ MTV Movie Award +
+ Best Hero
+ Paul Rudd +
+
+
+

+ North Carolina Film Critics Association + 2016 +

+ + + + + +
+ Nominated
+ Tar Heel Award +
+ + Peyton Reed +
+
+
+

+ Online Film & Television Association + 2016 +

+ + + + + +
+ 2nd place
+ OFTA Film Award +
+ Best Titles Sequence
+
+ For the closing credits. +
+
+
+

+ Teen Choice Awards + 2015 +

+ + + + + + + + +
+ Nominated
+ Teen Choice Award +
+ Choice Summer Movie Star: Male
+ Paul Rudd +
+
+ Choice Summer Movie Star: Female
+ Evangeline Lilly +
+
+
+

+ Telly Awards + 2016 +

+ + + + + +
+ Won
+ Bronze Telly +
+ Best Action TV Spot
+ R.D. Womack II +
+
+
+

+ Visual Effects Society Awards + 2016 +

+ + + + + + + + +
+ Nominated
+ VES Award +
+ Outstanding Created Environment in a Photoreal Feature
+ Florian Witzel +
+ Taylor Shaw +
+ Alexis Hall +
+ Heath Kraynak +
+
+ The Microverse +
+
+ Outstanding Virtual Cinematography in a Photoreal Project
+ James Baker +
+ Alex Khan +
+ Thomas Luff +
+ Rebecca Baehler +
+
+ Macro Action +
+
+
+

+ World Stunt Awards + 2016 +

+ + + + + + + + + +
+ Nominated
+ Taurus Award +
+ Best Stunt Rigging
+ Richard Epper +
+
+ Nominated
+ Taurus World Stunt Award +
+ Best Stunt Rigging
+ James M. Churchman +
+
+
+

+ Young Entertainer Awards + 2016 +

+ + + + + +
+ Nominated
+ Young Entertainer Award +
+ Best Supporting Young Actress- Feature Film
+ Abby Ryder Fortson +
+
+
+
+
+ + +
+

See also

+

+ +FAQ +| +User Reviews +| +User Ratings +| +External Reviews +| +Metacritic Reviews +

+
+ + +
+ +

Contribute to This Page

+ + + Please see our guide to updating + awards +
+ + + +
+ + + + +
+ +
+
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + diff --git a/Tests/MovieParser/Imdb/Matcher/AntMan-crazyCredits.html b/Tests/MovieParser/Imdb/Matcher/AntMan-crazyCredits.html new file mode 100644 index 0000000..30b6729 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/AntMan-crazyCredits.html @@ -0,0 +1,2004 @@ + + + + + + + + + + + + + + + + + Ant-Man (2015) - Crazy Credits - IMDb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+ + +
+
+ + + + + + +
+ + + +
+ + +
+
+ + + + +
+
+ +
+ + Edit + +
+ Ant-Man (2015) Poster + +
+

+ + (2015) + +

+
+ +

Crazy Credits

+
+ +
+
+ +
+
+
+
+ SPOILER: There is a scene at the end of the closing credits: Steve Rogers and + Sam Wilson have Bucky Barnes in their custody, and debate on what to do. This + leads into Captain America: Obcanská válka + (2016).
+
+ 176 of 177 found this interesting + + Interesting? + + + + | Share this +
+ Share this: Facebook + +  |  + Twitter + +  |  + Permalink + +
+
+ +
+
+
+ SPOILER: Mid credits scene: Hank Pym talks to his daughter, showing her a secret + room in his basement, containing a prototype Wasp suit that was never completed. + The two decide to resume work on it for her use.
+
+ 144 of 145 found this interesting + + Interesting? + + + + | Share this +
+ Share this: Facebook + +  |  + Twitter + +  |  + Permalink + +
+
+ +
+
+
+ There is a statement at the end of the closing credits: "Ant-Man will + return."
+
+ 128 of 133 found this interesting + + Interesting? + + + + | Share this +
+ Share this: Facebook + +  |  + Twitter + +  |  + Permalink + +
+
+ +
+
+
+ "Nitrospray is a product of Premier Medical Products and is not intended to be + used as shown herein." (i.e., to crack safes)
+
+ 1 of 1 found this interesting + + Interesting? + + + + | Share this +
+ Share this: Facebook + +  |  + Twitter + +  |  + Permalink + +
+
+ +
+
+
+
+ + +
+

See also

+

+ +Trivia +| +Goofs +| +Quotes +| +Alternate Versions +| +Connections +| +Soundtracks +

+
+ + +
+ +

Contribute to This Page

+ + +
+ + + +
+ + + + +
+ +
+
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + diff --git a/Tests/MovieParser/Imdb/Matcher/AntMan-video.html b/Tests/MovieParser/Imdb/Matcher/AntMan-video.html new file mode 100644 index 0000000..52d57c4 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/AntMan-video.html @@ -0,0 +1,1805 @@ + + + + + + + + + Ant-Man Clip (Youre Like A Bullet) - IMDb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +
+ + + + + + + + + + +
+ + +
+ + + + + +
+ + +
+
+

+ + + + Clip + (Youre Like A Bullet) + + +

+
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ Title: + + Ant-Man Clip (Youre Like A Bullet) +
Description: + Armed with a super-suit with the astonishing ability to shrink in scale but increase in strength, con-man Scott Lang must embrace his inner hero and help his mentor, Dr. Hank Pym, plan and pull off a heist that will save the world. +
Related + Titles:Ant-Man +
Content + Rating:Not Rated
Video + URL: + http://www.imdb.com/video/imdb/vi3109793817/ +
+
+ + +
+ + + + + +
+ + + +
+ + +
+ + + +
+
+
+ + + + + +
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/MovieParser/Imdb/Matcher/AntMan-videoGallery.html b/Tests/MovieParser/Imdb/Matcher/AntMan-videoGallery.html new file mode 100644 index 0000000..06b9438 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/AntMan-videoGallery.html @@ -0,0 +1,2435 @@ + + + + + + + + + + + + + + + + + Ant-Man (2015) - Video Gallery - IMDb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+ + +
+
+ + + + + + +
+ + + +
+ + +
+
+ + + + +
+
+ +
+
+ Ant-Man (2015) Poster + +
+

+ + (2015) + +

+
+ +

Video Gallery

+ + +
+ + +
+ + +
+

See also

+

+ +Photo Gallery +

+
+ + +
+ + + + +
+ +
+
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + diff --git a/Tests/MovieParser/Imdb/Matcher/AntMan-videoObject.html b/Tests/MovieParser/Imdb/Matcher/AntMan-videoObject.html new file mode 100644 index 0000000..db73720 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/AntMan-videoObject.html @@ -0,0 +1,314 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
+ +
+
+
+
+ +
+ Youre Like A Bullet + (0:24) +
+ + +
+
+
QUALITY
+
+ SD +
+
+
Auto
+
+
+ 720p HD +
+
+
+ +
+ + +
+ +
+ + +
+ +
+ +
+ + +
+ +
+
+
+
+
+
+ Ant-Man (2015) Poster +
+
+ +
+
+
+ + + + +
+
+
+ + +
+
+
+ + + + + + + + + diff --git a/Tests/MovieParser/Imdb/Matcher/BvS-alternate.html b/Tests/MovieParser/Imdb/Matcher/BvS-alternate.html new file mode 100644 index 0000000..6448c87 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/BvS-alternate.html @@ -0,0 +1,1887 @@ + + + + + + + + + + + + + + + + + Batman vs. Superman: Úsvit spravedlnosti (2016) - Alternate Versions - IMDb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+ + +
+
+ + + + + + +
+ + + +
+ + +
+
+ + + + +
+
+
+ + Edit + +
+ Batman vs. Superman: Úsvit spravedlnosti (2016) Poster + + + +

Alternate Versions

+
+
+
+ +
+
+ The theatrical release (rated "PG-13") is 151 minutes in length. The "ultimate edition" + director's cut (rated "R" for scenes of violence) is 183 minutes in length. +
+
+
+ + +
+

See also

+

+ +Trivia +| +Goofs +| +Crazy Credits +| +Quotes +| +Connections +| +Soundtracks +

+
+ + +
+ +

Contribute to This Page

+ +
+
+ + + +
+
+ + +
+ + + +
+ + + + +
+ +
+
+ +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessAlternateVersions.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessAlternateVersions.phpt new file mode 100644 index 0000000..e3aa4bf --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/ProcessAlternateVersions.phpt @@ -0,0 +1,31 @@ +process($html); + + \Tester\Assert::same('tt2975590', $data['id']); + \Tester\Assert::count(3, $data['alternate']); + } + +} + + +(new ProcessAlternateVersions())->run(); diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessAwards.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessAwards.phpt new file mode 100644 index 0000000..9efd9e8 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/ProcessAwards.phpt @@ -0,0 +1,38 @@ +process($html); + + \Tester\Assert::same('tt0478970', $data['id']); + \Tester\Assert::count(21, $data['awards']); + \Tester\Assert::same('Academy of Science Fiction, Fantasy & Horror Films, USA', $data['awards'][1]['event']); + \Tester\Assert::same('Won', $data['awards'][1]['status']); + \Tester\Assert::same('Saturn Award', $data['awards'][1]['award']); + \Tester\Assert::count(6 , $data['awards'][1]['category']); + \Tester\Assert::same('Best Director', $data['awards'][1]['category'][1]['name']); + \Tester\Assert::count(1, $data['awards'][1]['category'][1]['people']); + \Tester\Assert::same('/name/nm0715636?ref_=ttawd_awd_3', $data['awards'][1]['category'][1]['people'][0]); + } + +} + + +(new ProcessAwards())->run(); diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessCompanyCredits.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessCompanyCredits.phpt index cb8070d..d9cb671 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessCompanyCredits.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessCompanyCredits.phpt @@ -2,46 +2,33 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessCompanyCredits.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessCompanyCredits extends Tester\TestCase +class ProcessCompanyCredits extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessCompanyCredits(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-companyCredits.html'); - $data = $matcher->processCompanyCredits($html); + $data = $matcher->process($html); - var_dump($data); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::same($data['credits'][1]['name'], 'Distributors'); + \Tester\Assert::count(25, $data['credits'][1]['companies']); + \Tester\Assert::count(4, $data['credits']); } - - - protected function tearDown() - { - parent::tearDown(); - } - } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessConnections.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessConnections.phpt index 8ee13fd..c046b3c 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessConnections.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessConnections.phpt @@ -2,41 +2,32 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessConnections.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -class ProcessConnections extends Tester\TestCase +class ProcessConnections extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessConnections(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-connection.html'); - $data = $matcher->processConnections($html); - - var_dump($data); - } + $data = $matcher->process($html); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(63, $data['connections']); - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['connections'][0]['id'], '/title/tt0371746'); + \Tester\Assert::same($data['connections'][0]['group'], 'Follows '); + \Tester\Assert::same($data['connections'][0]['note'], NULL); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessCrazyCredits.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessCrazyCredits.phpt index 654e3ca..c9179d0 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessCrazyCredits.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessCrazyCredits.phpt @@ -2,44 +2,31 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessCrazyCredits.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/CrazyCredit.php'; -class ProcessCrazyCredit extends Tester\TestCase +class ProcessCrazyCredit extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessCrazyCredits(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-crazyCredits.html'); - $data = $matcher->processCrazyCredits($html); + $data = $matcher->process($html); - var_dump($data); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(4, $data['credits']); + \Tester\Assert::count(3, $data['credits'][0]); + \Tester\Assert::same($data['credits'][0]['id'], 'cz0033005'); } - - - protected function tearDown() - { - parent::tearDown(); - } - } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessEpisode.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessEpisode.phpt new file mode 100644 index 0000000..622bc14 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/ProcessEpisode.phpt @@ -0,0 +1,38 @@ +process($html); + + \Tester\Assert::same('tt5207756', $data['id']); + \Tester\Assert::same('Say Yes ', $data['title']); + \Tester\Assert::same('7,5', $data['rating']); + \Tester\Assert::same('https://images-na.ssl-images-amazon.com/images/M/MV5BMGRmNmI2OGYtNjk4ZC00N2ZhLTg3OGItM2UxOGUxMDAxNjFiXkEyXkFqcGdeQXVyNzI2MDU5NTg@._V1_UX182_CR0,0,182,268_AL_.jpg', $data['poster']); + \Tester\Assert::count(3, $data['genres']); + \Tester\Assert::count(14, $data['links']); + \Tester\Assert::same('/title/tt5207756/technical?ref_=tt_ql_dt_7', $data['links'][3]); + \Tester\Assert::same('/title/tt1520211?ref_=tt_ov_inf', $data['show']); + \Tester\Assert::same('Season 7', $data['season']); + \Tester\Assert::same('Episode 12', $data['episode']); + } +} + + +(new ProcessEpisode())->run(); diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessFullCredits.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessFullCredits.phpt index 05541b8..aa2be1f 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessFullCredits.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessFullCredits.phpt @@ -2,60 +2,50 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessFullCredits.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessFullCredits extends Tester\TestCase +class ProcessFullCredits extends \Tester\TestCase { - - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); - $urlBuilder = new MovieParser\IMDB\UrlBuilder(); + $matcher = new \MovieParser\IMDB\Matcher\ProcessFullCredits(new \MovieParser\IMDB\UrlBuilder()); + $urlBuilder = new \MovieParser\IMDB\UrlBuilder(); $html = file_get_contents(__DIR__ . '/AntMan-fullcredits.html'); - $data = $matcher->processFullCredits($html); - $entity = new MovieParser\IMDB\DTO\Movie([]); + $data = $matcher->process($html); + $entity = new \MovieParser\IMDB\DTO\Movie([]); foreach ($data['cast'] as $personData) { - $role = new MovieParser\IMDB\DTO\Role(); + $role = new \MovieParser\IMDB\DTO\Role(); $role->setName('Cast'); $role->setType('Cast'); $role->setDescription($personData['description']); if ($personData['person']) { - $person = new MovieParser\IMDB\DTO\Person(); + $person = new \MovieParser\IMDB\DTO\Person(); $person->setId($urlBuilder->getId($personData['person'])); $person->setName($personData['person_name']); $role->setPerson($person); }; if ($personData['character']) { - $character = new MovieParser\IMDB\DTO\Character(); + $character = new \MovieParser\IMDB\DTO\Character(); $character->setId($urlBuilder->getId($personData['character'])); $character->setName($personData['character_name']); $role->setCharacter($character); } if ($personData['alias']) { - $alias = new MovieParser\IMDB\DTO\Character(); + $alias = new \MovieParser\IMDB\DTO\Character(); $alias->setId($urlBuilder->getId($personData['alias'])); $alias->setName($personData['alias_name']); $role->setAlias($alias); @@ -66,12 +56,12 @@ class ProcessFullCredits extends Tester\TestCase foreach ($data['crew'] as $crewData) { foreach ($crewData['people'] as $crewPerson) { if ( ! $crewPerson['person']) continue; - $role = new MovieParser\IMDB\DTO\Role(); + $role = new \MovieParser\IMDB\DTO\Role(); $role->setName($crewData['role_name']); $role->setType('Crew'); $role->setDescription($crewPerson['description']); - $person = new MovieParser\IMDB\DTO\Person(); + $person = new \MovieParser\IMDB\DTO\Person(); $person->setId($urlBuilder->getId($crewPerson['person'])); $person->setName($crewPerson['person_name']); $role->setPerson($person); @@ -79,15 +69,11 @@ class ProcessFullCredits extends Tester\TestCase $entity->addPerson($role); } } - var_dump($entity); - } - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(2123, $entity->getPeople()); + \Tester\Assert::true($entity->getPeople()[1] instanceof \MovieParser\IMDB\DTO\Role); } - } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessGoofs.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessGoofs.phpt index bc346db..531a66f 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessGoofs.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessGoofs.phpt @@ -2,44 +2,27 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessGoofs.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -class ProcessGoofs extends Tester\TestCase +class ProcessGoofs extends \Tester\TestCase { - - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessGoofs(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-goofs.html'); - $data = $matcher->processGoofs($html); + $data = $matcher->process($html); - var_dump($data); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(27, $data['goofs']); + \Tester\Assert::same('gf2564130', $data['goofs'][0]['id']); } - - - protected function tearDown() - { - parent::tearDown(); - } - } - (new ProcessGoofs())->run(); diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessImage.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessImage.phpt index 9668c0a..263d2fd 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessImage.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessImage.phpt @@ -2,47 +2,32 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessImage.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Image.php'; -class ProcessImage extends Tester\TestCase +class ProcessImage extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessImage(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-image.html'); - $data = $matcher->processImage($html); + $data = $matcher->process($html); - $jsonDecode = json_decode($data['image']); + $jsonDecode = json_decode($data['imageData']); - var_dump($jsonDecode); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::type('object', $jsonDecode); + \Tester\Assert::count(242, $jsonDecode->mediaViewerModel->allImages); } - - - protected function tearDown() - { - parent::tearDown(); - } - } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessKeyWords.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessKeyWords.phpt index 5d8b6a3..5815bc9 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessKeyWords.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessKeyWords.phpt @@ -2,46 +2,31 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessKeywords.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessKeyWords extends Tester\TestCase +class ProcessKeyWords extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessKeywords(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-keyWords.html'); - $data = $matcher->processKeywords($html); + $data = $matcher->process($html); - var_dump($data); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(127, $data['keywords']); + \Tester\Assert::same('sabotage', $data['keywords'][0]); } - - - protected function tearDown() - { - parent::tearDown(); - } - } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessLocations.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessLocations.phpt index 986964c..78d7f6d 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessLocations.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessLocations.phpt @@ -2,44 +2,31 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessLocations.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessLocations extends Tester\TestCase +class ProcessLocations extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessLocations(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-location.html'); - $data = $matcher->processLocations($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(7, $data['locations']); + \Tester\Assert::same('Atlanta, Georgia, USA', $data['locations'][1]); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessMedia.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessMedia.phpt index 0381993..c81c1b0 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessMedia.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessMedia.phpt @@ -2,42 +2,29 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessMedia.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -class ProcessMedia extends Tester\TestCase +class ProcessMedia extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessMedia(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-media.html'); - $data = $matcher->processMedia($html); - - var_dump($data); - } + $data = $matcher->process($html); - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(48, $data['media']); + \Tester\Assert::count(5, $data['mediaTypes']); + \Tester\Assert::same('/title/tt0478970/mediaindex?refine=production_art&ref_=ttmi_ref_art', $data['mediaTypes'][4]); + \Tester\Assert::count(5, $data['pages']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessMovie.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessMovie.phpt index d065529..95762dd 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessMovie.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessMovie.phpt @@ -2,44 +2,33 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessMovie.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -class ProcessMovie extends Tester\TestCase +class ProcessMovie extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessMovie(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan.html'); - $data = $matcher->processMovie($html); + $data = $matcher->process($html); - $movie = new MovieParser\IMDB\DTO\Movie($data); - var_dump($data); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::same($data['year'], '2015'); + \Tester\Assert::same($data['rating'], '7.4'); + \Tester\Assert::same($data['poster'], 'http://ia.media-imdb.com/images/M/MV5BMjM2NTQ5Mzc2M15BMl5BanBnXkFtZTgwNTcxMDI2NTE@._V1_UX182_CR0,0,182,268_AL_.jpg'); + \Tester\Assert::count(3, $data['genres']); + \Tester\Assert::count(29, $data['links']); + \Tester\Assert::same('/title/tt0478970/business?ref_=tt_ql_dt_4', $data['links'][3]); } - - - protected function tearDown() - { - parent::tearDown(); - } - } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessPlotSummary.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessPlotSummary.phpt index 72341f4..a671c53 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessPlotSummary.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessPlotSummary.phpt @@ -2,44 +2,30 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessPlotSummary.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessPlotSummary extends Tester\TestCase +class ProcessPlotSummary extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessPlotSummary(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-plotSummary.html'); - $data = $matcher->processPlotSummary($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(4, $data['plotSummary']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessQuotes.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessQuotes.phpt index 7ca3900..0809cd3 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessQuotes.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessQuotes.phpt @@ -2,41 +2,28 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessQuotes.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -class ProcessQuotes extends Tester\TestCase +class ProcessQuotes extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessQuotes(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-quotes.html'); - $data = $matcher->processQuotes($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(52, $data['quotes']); + \Tester\Assert::same('qt2555139', $data['quotes'][0]['id']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessReleaseInfo.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessReleaseInfo.phpt index 439f6b7..962e0d8 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessReleaseInfo.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessReleaseInfo.phpt @@ -2,44 +2,32 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessReleaseInfo.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessReleaseInfo extends Tester\TestCase +class ProcessReleaseInfo extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessReleaseInfo(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-release.html'); - $data = $matcher->processReleaseInfo($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(75, $data['release']); + \Tester\Assert::same('USA', $data['release'][0]['country']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessSynopsis.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessSynopsis.phpt index 03151aa..eeaba05 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessSynopsis.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessSynopsis.phpt @@ -2,44 +2,29 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessSynopsis.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessSynopsis extends Tester\TestCase +class ProcessSynopsis extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessSynopsis(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-synopsis.html'); - $data = $matcher->processSynopsis($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::count(34, $data['synopsis']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessTagLines.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessTagLines.phpt index e328b0f..008484c 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessTagLines.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessTagLines.phpt @@ -2,44 +2,30 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessTagLines.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessTagLines extends Tester\TestCase +class ProcessTagLines extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessTagLines(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-tagLines.html'); - $data = $matcher->processTagLines($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(2, $data['tagLines']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessTechnical.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessTechnical.phpt index 73dc156..947e789 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessTechnical.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessTechnical.phpt @@ -2,44 +2,31 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessTechnical.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; -class ProcessTechnical extends Tester\TestCase +class ProcessTechnical extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessTechnical(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-technical.html'); - $data = $matcher->processTechnical($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::same($data['runtime'], '1 hr 57 min (117 min)'); + \Tester\Assert::count(4, $data['camera']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessTrivia.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessTrivia.phpt index 843ec18..5f6331c 100644 --- a/Tests/MovieParser/Imdb/Matcher/ProcessTrivia.phpt +++ b/Tests/MovieParser/Imdb/Matcher/ProcessTrivia.phpt @@ -2,41 +2,27 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessTrivia.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -class ProcessTrivia extends Tester\TestCase +class ProcessTrivia extends \Tester\TestCase { - protected function setUp() - { - parent::setUp(); - } - - public function testProcessMovie() { - $matcher = new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder()); + $matcher = new \MovieParser\IMDB\Matcher\ProcessTrivia(new \MovieParser\IMDB\UrlBuilder()); $html = file_get_contents(__DIR__ . '/AntMan-trivia.html'); - $data = $matcher->processTrivia($html); + $data = $matcher->process($html); - var_dump($data); - } - - - protected function tearDown() - { - parent::tearDown(); + \Tester\Assert::same($data['id'], 'tt0478970'); + \Tester\Assert::count(134, $data['trivia']); } } diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessVideo.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessVideo.phpt new file mode 100644 index 0000000..573042f --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/ProcessVideo.phpt @@ -0,0 +1,43 @@ +process($html); + + \Tester\Assert::same('http://www.imdb.com/video/imdb/vi3109793817/imdb/single?vPage=1', $data['videoObject']); + \Tester\Assert::count(5, $data['description']); + } + + + public function testProcessObject() + { + $matcher = new \MovieParser\IMDB\Matcher\ProcessVideo(new \MovieParser\IMDB\UrlBuilder()); + + $html = file_get_contents(__DIR__ . '/AntMan-videoObject.html'); + + $data = $matcher->processObject($html); + + \Tester\Assert::same('http://video-http.media-imdb.com/MV5BZjk0YzI1YTYtMzEyMS00ZWEwLTkyZGUtYTExZmY0ZDNhNjcwXkExMV5BbXA0XkFpbWRiLWV0cy10cmFuc2NvZGU@.mp4?Expires=1489267144&Signature=QGuPXCAmfBQPOpHFkHuz2ZrYacKl5PS8pEpcsgoNbqFJAVajI3TZBqJ5Ystorisdinbb3indLC5JuhaS7W096jgRM2sYPJdwkB8dLZsaXUXb2vj2rqc20mfM-CrDYAM9EMTvB2yF5iz2NpvYAG2JJhLvVtslUHApG8dSuCX7mtw_&Key-Pair-Id=APKAILW5I44IHKUN2DYA', + json_decode($data['videoObject'])->videoPlayerObject->video->videoInfoList[1]->videoUrl); + } +} + + +(new ProcessVideo())->run(); diff --git a/Tests/MovieParser/Imdb/Matcher/ProcessVideoGallery.phpt b/Tests/MovieParser/Imdb/Matcher/ProcessVideoGallery.phpt new file mode 100644 index 0000000..c89c89a --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/ProcessVideoGallery.phpt @@ -0,0 +1,32 @@ +process($html); + + \Tester\Assert::same('tt0478970', $data['id']); + \Tester\Assert::count(30, $data['videos']); + \Tester\Assert::count(2, $data['pages']); + } + +} + + +(new ProcessVideoGallery())->run(); diff --git a/Tests/MovieParser/Imdb/Matcher/WalkingDead-episode.html b/Tests/MovieParser/Imdb/Matcher/WalkingDead-episode.html new file mode 100644 index 0000000..3e8ca25 --- /dev/null +++ b/Tests/MovieParser/Imdb/Matcher/WalkingDead-episode.html @@ -0,0 +1,3204 @@ + + + + + + + + + + + + + + + + + "Ziví mrtví" Say Yes (TV Episode 2017) - IMDb + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + + + +
+ + +
+
+ + + + + + +
+ + + +
+ + +
+
+ + + + + + + + + + + +
+
+ + +
+ + + +
+
+ +
+
+ + +
+
+
+ Ziví mrtví + (2010– ) +
+
+
+ +
+
+
+ 7,5/10
+ 2 732 +
+ 27 user + 16 critic +
+
+
+
+ +
+
+
+
+
+
+
+ +
+ +
+

Say Yes 

+
+ + 15 + | + + | + Drama, + Horror, + Thriller + | + Episode aired 5 March 2017 + +
+
+
+
+
+ + + + + +
+
+
+ Say Yes Poster +
+
+ +
+
+ The group scavenge for supplies. Back in Alexandria, Tara must make a + morally challenging decision. +
+ +
+

Director:

+ + +
+
+

Writers:

+ + (developed by), + + (based on the series of graphic novels by) + | + 3 more credits » +
+ +
+ + +
+ +
+
+ Reviews +
+
+ + 27 user + | + 16 critic + +
+
+ +
+ +
+
+ + +
+ +
+ + + + +
+ + + + + + +
+ + + + + + + + +
+
+
+

Photos

+
+ + + + + +
+
+
+ + 14 photos + + »
+
+
+ + + + + + + + + + + + + + + + +
+ + Edit + +

Cast

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Episode cast overview, first billed only:
+ + + + ... + +
+ Rick Grimes + +
+
+ + + + ... + +
+ Daryl Dixon + + + (credit only) + + +
+
+ + + + ... + +
+ Maggie Greene + + + (credit only) + + +
+
+ + + + ... + +
+ Carl Grimes + + + (credit only) + + +
+
+ + + + ... + +
+ Michonne + +
+
+ + + + ... + +
+ Carol Peletier + + + (credit only) + + +
+
+ + + + ... + +
+ Morgan Jones + + + (credit only) + + +
+
+ + + + ... + + +
+ + + + ... + + +
+ + + + ... + +
+ Dr. Eugene Porter + + + (credit only) + + +
+
+ + + + ... + + +
+ + + + ... + + +
+ + + + ... + +
+ Negan + + + (credit only) + + +
+
+ + + + ... + +
+ Aaron + + + (credit only) + + +
+
+ + + + ... + +
+ Dwight + + + (credit only) + + +
+
+
+ See full cast » +
+
+ + + + + + + + + + +
+ + Edit + + +

Storyline

+ +
+

+ The group scavenge for supplies. Back in Alexandria, Tara must make a morally + challenging decision.

+
+ + + Plot Summary + | + Add Synopsis + +
+
+

Plot Keywords:

+ falling off a ferris wheel + | + black bra + | + deer + | + hiding in a car + | + assembling a rifle + |  + See All (45) » + +
+
+
+

Genres:

+ Drama | + Horror | + Thriller +
+ +
+ +
+

Certificate:

+ + See all certifications » + +
+
+

Parents Guide:

+ + Add content advisory for parents » + +
+
+ + + + + + + + +
+ + Edit + +

Details

+ +
+

Country:

+ +
+ +
+

Language:

+ +
+ + +
+

Release Date:

5 March 2017 (USA) + +  » + +
+ + +
+

Company Credits

+
+ Show detailed + + on +  » +
+ + +
+

Technical Specs

+ +
+

Runtime:

+ +
+ +
+

Sound Mix:

+ +
+ +
+

Color:

+ +
+ + + See  » +
+ + + + + + + + +
+ + Edit + +

Did You Know?

+
+

Trivia

+ Ricks iconic weapon of choice, is his Colt Python which has been Ricks trademark ever since + season 1. In this episode, Rick fires the weapon for the first time since the 15th episode + of season 6. See more » +
+
+
+

Goofs

+ Michonne is seen jumping into the back of the Ford Crown Victoria and closing the trunk. + Later, walkers surround the car and Rick and Michonne escape through the sun roof. Michonne + wouldn't be able to get into the car through the trunk since the seats don't fold down + allowing access to the passenger portion of the car. See more » +
+
+
+

Connections

+ Referenced in Talking Dead: Hostiles and + Calamities (2017) + + + See more » +
+
+ + + + + +
+

Frequently Asked Questions

+ This FAQ is empty. Add the first question. +
+ + + + +
+

User Reviews

+
+
+
 
+
+ + Power Couple Richonne Slays Together + + + + + +
+ 7 March 2017 | by + + (United States) + – See all my reviews +
+
+

This episode was refreshing because it finally got a look at the Richonne relationship as it continues to grow stronger and in a ZA no less.

I have been one of those who have been mentally tortured from 7A and all the Negan and Savior showcase. The lead character himself Rick was narrowed down to a back drop and Michonne not having a chance to be seen using her signature weapon. Well finally "Say Yes" had these two together getting things down slaying together, protecting each other and actually having adult conversation about things happening in the apocalypse. Yes it was slow paced but it was a nice slow pace with the right mixture of everything this couple encompasses. Nice to see some humor, tension, excitement, hear some laughter, notice fear and address what is ahead for them and everyone else in regards to this battle with Negan. I honestly believe the Rick and Michonne union is one of the best if not of all time, they add the happiness and light that the show desperately needed after all this depressing overload of Negan and the sanctuary. To me the show is still suffering from that aspect and it does not help that the lead up to everything is taking a bit longer.

Regardless of the episode mainly showcasing Richonne it still progresses the story knowing where and how they got the guns while also revealing how Rick is coping. Plus we got to see a new side of Michonne who has shown some vulnerabilities which is human, we don't get to see enough of this coming from her. She is bad ass in her own right but she too has fears especially now with the possibility of losing Rick.

Either way for me it was a 10. I should subtract 2 points just for all the angry rosita and her lashing out at Father G, which made no sense. The garbage people I don't trust either. If it wasn't for richonne I would have happily left it at a 6 at best lol

+
+
+
+
+ 11 of 17 people found this review helpful.  + Was this review helpful to you? + + +
+ +
+
+ + + + + + + +
+ +

Contribute to This Page

+ +
+
+ + + +
+
+ + + + + +
+ + + + +
+
+
+ + +
+
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + diff --git a/Tests/MovieParser/Imdb/Parser/Get.phpt b/Tests/MovieParser/Imdb/Parser/Get.phpt index 32a1e6a..6873487 100644 --- a/Tests/MovieParser/Imdb/Parser/Get.phpt +++ b/Tests/MovieParser/Imdb/Parser/Get.phpt @@ -2,49 +2,112 @@ namespace Tests\MovieParser\IMDB\Parser; -use Tester; -use MovieParser; -use Atrox; - include __DIR__ . '/../../../Bootstrap.php'; include __DIR__ . '/../../../../src/IMDB/Parser.php'; -include __DIR__ . '/../../../../src/IMDB/Matcher.php'; include __DIR__ . '/../../../../src/IMDB/UrlBuilder.php'; + +include __DIR__ . '/../../../../src/IMDB/DTO/Dto.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Alias.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Company.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Connection.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/CrazyCredit.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Credit.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Episode.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Goof.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Image.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Movie.php'; -include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Person.php'; -include __DIR__ . '/../../../../src/IMDB/DTO/Character.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Quote.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Release.php'; -include __DIR__ . '/../../../../src/IMDB/DTO/Alias.php'; -include __DIR__ . '/../../../../src/IMDB/DTO/Credit.php'; -include __DIR__ . '/../../../../src/IMDB/DTO/Company.php'; +include __DIR__ . '/../../../../src/IMDB/DTO/Role.php'; include __DIR__ . '/../../../../src/IMDB/DTO/Trivia.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadAlternativeVersions.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadAwards.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadBusiness.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadCompanyCredits.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadConnections.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadCrazyCredits.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadFullCredits.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadGoofs.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadKeywords.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadLocations.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadMedia.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadMovie.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadPlotSummary.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadQuotes.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadRatings.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadReleaseInfo.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadReviews.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadSoundtrack.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadSynopsis.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadTagLines.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadTechnical.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadTrivia.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadVideo.php'; +include __DIR__ . '/../../../../src/IMDB/Parser/LoadVideoGallery.php'; -class Get extends Tester\TestCase -{ +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessAlternativeVersions.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessAwards.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessBusiness.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessCompanyCredits.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessConnections.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessCrazyCredits.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessFullCredits.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessGoofs.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessImage.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessKeywords.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessLocations.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessMedia.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessMovie.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessPlotSummary.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessQuotes.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessReleaseInfo.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessSynopsis.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessTagLines.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessTechnical.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessTrivia.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessVideo.php'; +include __DIR__ . '/../../../../src/IMDB/Matcher/ProcessVideoGallery.php'; - protected function setUp() - { - parent::setUp(); - } +class Get extends \Tester\TestCase +{ public function testSuccessFullGet() { - $parser = new MovieParser\IMDB\Parser(new MovieParser\IMDB\UrlBuilder(), new MovieParser\IMDB\Matcher(new MovieParser\IMDB\UrlBuilder())); + $parser = new \MovieParser\IMDB\Parser( + new \MovieParser\IMDB\UrlBuilder(), + new \MovieParser\IMDB\Parser\LoadMovie(new \MovieParser\IMDB\Matcher\ProcessMovie()), + new \MovieParser\IMDB\Parser\LoadAlternativeVersions(new \MovieParser\IMDB\Matcher\ProcessAlternativeVersions()), + new \MovieParser\IMDB\Parser\LoadAwards(new \MovieParser\IMDB\Matcher\ProcessAwards()), + new \MovieParser\IMDB\Parser\LoadBusiness(), + new \MovieParser\IMDB\Parser\LoadCompanyCredits(new \MovieParser\IMDB\UrlBuilder(), new \MovieParser\IMDB\Matcher\ProcessCompanyCredits()), + new \MovieParser\IMDB\Parser\LoadConnections(new \MovieParser\IMDB\Matcher\ProcessConnections()), + new \MovieParser\IMDB\Parser\LoadCrazyCredits(new \MovieParser\IMDB\Matcher\ProcessCrazyCredits()), + new \MovieParser\IMDB\Parser\LoadFullCredits(new \MovieParser\IMDB\UrlBuilder(), new \MovieParser\IMDB\Matcher\ProcessFullCredits()), + new \MovieParser\IMDB\Parser\LoadGoofs(new \MovieParser\IMDB\Matcher\ProcessGoofs()), + new \MovieParser\IMDB\Parser\LoadKeywords(new \MovieParser\IMDB\Matcher\ProcessKeywords()), + new \MovieParser\IMDB\Parser\LoadLocations(new \MovieParser\IMDB\Matcher\ProcessLocations()), + new \MovieParser\IMDB\Parser\LoadMedia(new \MovieParser\IMDB\UrlBuilder(), new \MovieParser\IMDB\Matcher\ProcessMedia(), new \MovieParser\IMDB\Matcher\ProcessImage()), + new \MovieParser\IMDB\Parser\LoadPlotSummary(new \MovieParser\IMDB\Matcher\ProcessPlotSummary()), + new \MovieParser\IMDB\Parser\LoadQuotes(new \MovieParser\IMDB\Matcher\ProcessQuotes()), + new \MovieParser\IMDB\Parser\LoadRatings(), + new \MovieParser\IMDB\Parser\LoadReleaseInfo(new \MovieParser\IMDB\Matcher\ProcessReleaseInfo()), + new \MovieParser\IMDB\Parser\LoadReviews(), + new \MovieParser\IMDB\Parser\LoadSoundtrack(), + new \MovieParser\IMDB\Parser\LoadSynopsis(new \MovieParser\IMDB\Matcher\ProcessSynopsis()), + new \MovieParser\IMDB\Parser\LoadTagLines(new \MovieParser\IMDB\Matcher\ProcessTagLines()), + new \MovieParser\IMDB\Parser\LoadTechnical(new \MovieParser\IMDB\Matcher\ProcessTechnical()), + new \MovieParser\IMDB\Parser\LoadTrivia(new \MovieParser\IMDB\Matcher\ProcessTrivia()), + new \MovieParser\IMDB\Parser\LoadVideoGallery(new \MovieParser\IMDB\Matcher\ProcessVideoGallery(), new \MovieParser\IMDB\UrlBuilder(), new \MovieParser\IMDB\Parser\LoadVideo(new \MovieParser\IMDB\Matcher\ProcessVideo())) + ); - $entity = $parser->get('http://www.imdb.com/title/tt0478970/', TRUE); + $entity = $parser->get('http://www.imdb.com/title/tt0478970/'); - var_dump($entity); + \Tester\Assert::type(\MovieParser\IMDB\DTO\Movie::class, $entity); } - - - protected function tearDown() - { - parent::tearDown(); - } - } (new Get())->run(); diff --git a/composer.lock b/composer.lock new file mode 100644 index 0000000..6852f8f --- /dev/null +++ b/composer.lock @@ -0,0 +1,335 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", + "This file is @generated automatically" + ], + "hash": "d12ab5ab18ef3c90e537898695fe5b5b", + "content-hash": "2c1a512a76545b47185762e34dba89d3", + "packages": [ + { + "name": "atrox/matcher", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/kaja47/Matcher.git", + "reference": "72659bb37c8e807d3feb4f9f3c5ad2426e88e0c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/kaja47/Matcher/zipball/72659bb37c8e807d3feb4f9f3c5ad2426e88e0c2", + "reference": "72659bb37c8e807d3feb4f9f3c5ad2426e88e0c2", + "shasum": "" + }, + "type": "library", + "autoload": { + "psr-4": { + "Atrox\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "New BSD" + ], + "authors": [ + { + "name": "Karel Čížek", + "email": "kaja47@k47.cz", + "homepage": "http://funkcionalne.cz" + } + ], + "description": "Powerful XML and HTML matching library", + "keywords": [ + "Xpath", + "html", + "xml" + ], + "time": "2014-06-19 19:56:37" + }, + { + "name": "guzzlehttp/guzzle", + "version": "6.1.1", + "source": { + "type": "git", + "url": "https://github.com/guzzle/guzzle.git", + "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/c6851d6e48f63b69357cbfa55bca116448140e0c", + "reference": "c6851d6e48f63b69357cbfa55bca116448140e0c", + "shasum": "" + }, + "require": { + "guzzlehttp/promises": "~1.0", + "guzzlehttp/psr7": "~1.1", + "php": ">=5.5.0" + }, + "require-dev": { + "ext-curl": "*", + "phpunit/phpunit": "~4.0", + "psr/log": "~1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.1-dev" + } + }, + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "GuzzleHttp\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle is a PHP HTTP client library", + "homepage": "http://guzzlephp.org/", + "keywords": [ + "client", + "curl", + "framework", + "http", + "http client", + "rest", + "web service" + ], + "time": "2015-11-23 00:47:50" + }, + { + "name": "guzzlehttp/promises", + "version": "1.0.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/promises.git", + "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/promises/zipball/b1e1c0d55f8083c71eda2c28c12a228d708294ea", + "reference": "b1e1c0d55f8083c71eda2c28c12a228d708294ea", + "shasum": "" + }, + "require": { + "php": ">=5.5.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Promise\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "Guzzle promises library", + "keywords": [ + "promise" + ], + "time": "2015-10-15 22:28:00" + }, + { + "name": "guzzlehttp/psr7", + "version": "1.2.3", + "source": { + "type": "git", + "url": "https://github.com/guzzle/psr7.git", + "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/guzzle/psr7/zipball/2e89629ff057ebb49492ba08e6995d3a6a80021b", + "reference": "2e89629ff057ebb49492ba08e6995d3a6a80021b", + "shasum": "" + }, + "require": { + "php": ">=5.4.0", + "psr/http-message": "~1.0" + }, + "provide": { + "psr/http-message-implementation": "1.0" + }, + "require-dev": { + "phpunit/phpunit": "~4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "GuzzleHttp\\Psr7\\": "src/" + }, + "files": [ + "src/functions_include.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Michael Dowling", + "email": "mtdowling@gmail.com", + "homepage": "https://github.com/mtdowling" + } + ], + "description": "PSR-7 message implementation", + "keywords": [ + "http", + "message", + "stream", + "uri" + ], + "time": "2016-02-18 21:54:00" + }, + { + "name": "psr/http-message", + "version": "1.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "reference": "85d63699f0dbedb190bbd4b0d2b9dc707ea4c298", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "time": "2015-05-04 20:22:00" + } + ], + "packages-dev": [ + { + "name": "nette/tester", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/nette/tester.git", + "reference": "efbc31ff4ee0bef28da712a726316e8b0b5bf262" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/nette/tester/zipball/efbc31ff4ee0bef28da712a726316e8b0b5bf262", + "reference": "efbc31ff4ee0bef28da712a726316e8b0b5bf262", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "bin": [ + "src/tester" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.7-dev" + } + }, + "autoload": { + "classmap": [ + "src/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "BSD-3-Clause", + "GPL-2.0", + "GPL-3.0" + ], + "authors": [ + { + "name": "David Grudl", + "homepage": "https://davidgrudl.com" + }, + { + "name": "Nette Community", + "homepage": "https://nette.org/contributors" + } + ], + "description": "An easy-to-use PHP unit testing framework.", + "homepage": "https://tester.nette.org", + "keywords": [ + "nette", + "testing", + "unit" + ], + "time": "2016-02-08 10:30:15" + } + ], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [] +} diff --git a/src/DI/MovieParserExtension.php b/src/DI/MovieParserExtension.php new file mode 100644 index 0000000..ff029fe --- /dev/null +++ b/src/DI/MovieParserExtension.php @@ -0,0 +1,25 @@ +getContainerBuilder(); + + $this->compiler->parseServices($builder, $this->loadFromFile(__DIR__ . '/config.neon.neon'), $this->name); + } + + + public static function register(\Nette\Configurator $configurator) + { + $configurator->onCompile[] = function ($config, \Nette\DI\Compiler $compiler) { + $compiler->addExtension('movieParser', new MovieParserExtension()); + }; + } +} \ No newline at end of file diff --git a/src/DI/config.neon b/src/DI/config.neon new file mode 100644 index 0000000..d9cdf9e --- /dev/null +++ b/src/DI/config.neon @@ -0,0 +1,52 @@ +services: + - MovieParser\IMDB\Parser + - MovieParser\IMDB\UrlBuilder + + - MovieParser\IMDB\Matcher\ProcessAlternativeVersions + - MovieParser\IMDB\Matcher\ProcessAwards + - MovieParser\IMDB\Matcher\ProcessBusiness + - MovieParser\IMDB\Matcher\ProcessCompanyCredits + - MovieParser\IMDB\Matcher\ProcessConnections + - MovieParser\IMDB\Matcher\ProcessCompanyCredits + - MovieParser\IMDB\Matcher\ProcessCrazyCredits + - MovieParser\IMDB\Matcher\ProcessFullCredits + - MovieParser\IMDB\Matcher\ProcessGoofs + - MovieParser\IMDB\Matcher\ProcessImage + - MovieParser\IMDB\Matcher\ProcessKeywords + - MovieParser\IMDB\Matcher\ProcessLocations + - MovieParser\IMDB\Matcher\ProcessMedia + - MovieParser\IMDB\Matcher\ProcessMovie + - MovieParser\IMDB\Matcher\ProcessPlotSummary + - MovieParser\IMDB\Matcher\ProcessQuotes + - MovieParser\IMDB\Matcher\ProcessReleaseInfo + - MovieParser\IMDB\Matcher\ProcessSynopsis + - MovieParser\IMDB\Matcher\ProcessTagLines + - MovieParser\IMDB\Matcher\ProcessTechnical + - MovieParser\IMDB\Matcher\ProcessTrivia + - MovieParser\IMDB\Matcher\ProcessVideo + - MovieParser\IMDB\Matcher\ProcessVideoGallery + + - MovieParser\IMDB\Parser\LoadAlternativeVersions + - MovieParser\IMDB\Parser\LoadAwards + - MovieParser\IMDB\Parser\LoadBusiness + - MovieParser\IMDB\Parser\LoadCompanyCredits + - MovieParser\IMDB\Parser\LoadConnections + - MovieParser\IMDB\Parser\LoadCrazyCredits + - MovieParser\IMDB\Parser\LoadFullCredits + - MovieParser\IMDB\Parser\LoadGoofs + - MovieParser\IMDB\Parser\LoadKeywords + - MovieParser\IMDB\Parser\LoadLocations + - MovieParser\IMDB\Parser\LoadMedia + - MovieParser\IMDB\Parser\LoadMovie + - MovieParser\IMDB\Parser\LoadPlotSummary + - MovieParser\IMDB\Parser\LoadQuotes + - MovieParser\IMDB\Parser\LoadRatings + - MovieParser\IMDB\Parser\LoadReleaseInfo + - MovieParser\IMDB\Parser\LoadReviews + - MovieParser\IMDB\Parser\LoadSoundtrack + - MovieParser\IMDB\Parser\LoadSynopsis + - MovieParser\IMDB\Parser\LoadTagLines + - MovieParser\IMDB\Parser\LoadTechnical + - MovieParser\IMDB\Parser\LoadTrivia + - MovieParser\IMDB\Parser\LoadVideo + - MovieParser\IMDB\Parser\LoadVideoGallery \ No newline at end of file diff --git a/src/IMDB/DTO/Movie.php b/src/IMDB/DTO/Movie.php index 207eb6f..af932ee 100644 --- a/src/IMDB/DTO/Movie.php +++ b/src/IMDB/DTO/Movie.php @@ -18,6 +18,12 @@ class Movie extends Dto private $description; /** @var array */ private $genres; + /** @var string */ + private $show; + /** @var int */ + private $season; + /** @var int */ + private $episode; /** @var array */ private $people; /** @var array */ @@ -68,6 +74,20 @@ class Movie extends Dto private $images; /** @var array */ private $links; + /** + * @var array + */ + private $alternativeVersions; + + /** + * @var array + */ + private $awards; + + /** + * @var array + */ + private $videos; public function __construct($data) @@ -75,12 +95,24 @@ public function __construct($data) if (isset($data['id'])) $this->setId($data['id']); if (isset($data['title'])) $this->setTitle($data['title']); if (isset($data['year'])) $this->setYear((int) $data['year']); - if (isset($data['rating'])) $this->setRating(((int) str_replace('.', '', $data['rating']))); + if (isset($data['rating'])) $this->setRating((int) str_replace('.', '', $data['rating'])); if (isset($data['ratingCount'])) $this->setRatingCount((int) str_replace(',', '', $data['ratingCount'])); if (isset($data['poster'])) $this->setPoster($data['poster']); if (isset($data['description'])) $this->setDescription($data['description']); if (isset($data['genres'])) $this->setGenres($data['genres']); if (isset($data['links'])) $this->setLinks($data['links']); + if (isset($data['show'])) { + preg_match('/\d+/', $data['show'], $output); + $this->setShow($output[0]); + } + if (isset($data['season'])) { + preg_match('/\d+/', $data['season'], $output); + $this->setSeason($output[0]); + } + if (isset($data['episode'])) { + preg_match('/\d+/', $data['episode'], $output); + $this->setEpisode($output[0]); + } } @@ -676,4 +708,112 @@ public function setLinks(array $links) { $this->links = $links; } + + + /** + * @return array + */ + public function getAlternativeVersions() : array + { + return $this->alternativeVersions; + } + + + /** + * @param array $alternativeVersions + */ + public function setAlternativeVersions(array $alternativeVersions) + { + $this->alternativeVersions = $alternativeVersions; + } + + + /** + * @return array + */ + public function getAwards() : array + { + return $this->awards; + } + + + /** + * @param array $awards + */ + public function setAwards(array $awards) + { + $this->awards = $awards; + } + + + /** + * @return array + */ + public function getVideos() : array + { + return $this->videos; + } + + + /** + * @param array $videos + */ + public function setVideos(array $videos) + { + $this->videos = $videos; + } + + + /** + * @return string + */ + public function getShow() : string + { + return $this->show; + } + + + /** + * @param string $show + */ + public function setShow(string $show) + { + $this->show = $show; + } + + + /** + * @return int + */ + public function getSeason() : int + { + return $this->season; + } + + + /** + * @param int $season + */ + public function setSeason(int $season) + { + $this->season = $season; + } + + + /** + * @return int + */ + public function getEpisode() : int + { + return $this->episode; + } + + + /** + * @param int $episode + */ + public function setEpisode(int $episode) + { + $this->episode = $episode; + } } \ No newline at end of file diff --git a/src/IMDB/DTO/Series.php b/src/IMDB/DTO/Series.php deleted file mode 100644 index 24ef9d2..0000000 --- a/src/IMDB/DTO/Series.php +++ /dev/null @@ -1,13 +0,0 @@ -urlBuilder = $urlBuilder; - } - - - /** - * @param string $response - * @return array - */ - public function process($response) - { - $processedData = []; - - $type = $this->getType($response); - switch ($type) { - case self::TYPE_MOVIE: - $processedData = $this->processMovie($response); - break; - } - $processedData['type'] = $type; - - return $processedData; - } - - - /** - * @param string $response - * @return int self::TYPE_* - */ - public function getType($response) - { - return self::TYPE_MOVIE; - } - - - /** - * @param string $response - * @return array - */ - public function processMovie($response) - { - $match = Atrox\Matcher::multi([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'title' => Atrox\Matcher::single('//h1/text()'), - 'year' => Atrox\Matcher::single('//span[@id="titleYear"]/a/text()'), - 'rating' => Atrox\Matcher::single('//span[@itemprop="ratingValue"]/text()'), - 'ratingCount' => Atrox\Matcher::single('//span[@itemprop="ratingCount"]/text()'), - 'poster' => Atrox\Matcher::single('//img[@itemprop="image"]/@src'), - 'description' => Atrox\Matcher::single('//div[@itemprop="description"]/text()'), - 'genres' => Atrox\Matcher::multi('//div[@itemprop="genre"]/a/text()'), - 'links' => Atrox\Matcher::multi('//div[@class="quicklinkSectionItem"]/a[@class="quicklink"]/@href'), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processFullCredits($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'cast' => Atrox\Matcher::multi('//table[@class="cast_list"]/tr', [ - 'person' => Atrox\Matcher::single('./td[1]/a/@href'), - 'person_name' => Atrox\Matcher::single('.//span[@itemprop="name"]'), - 'character' => Atrox\Matcher::single('./td[@class="character"]/div/a[1]/@href'), - 'character_name' => Atrox\Matcher::single('./td[@class="character"]/div/a[1]'), - 'alias' => Atrox\Matcher::single('./td[@class="character"]/div/a[2]/@href'), - 'alias_name' => Atrox\Matcher::single('./td[@class="character"]/div/a[2]'), - 'description' => Atrox\Matcher::single('./td[@class="character"]/div/text()[last()]'), - ]), - 'crew' => Atrox\Matcher::multi('//h4[@class="dataHeaderWithBorder"]', [ - 'role_name' => Atrox\Matcher::single('./text()'), - 'people' => Atrox\Matcher::multi('following-sibling::table[@class="simpleTable simpleCreditsTable"][1]/tbody/tr', [ - 'person' => Atrox\Matcher::single('./td[1]/a/@href'), - 'person_name' => Atrox\Matcher::single('./td[1]/a/text()'), - 'description' => Atrox\Matcher::single('./td[3]/text()'), - ]), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processReleaseInfo($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'release' => Atrox\Matcher::multi('//table[@id="release_dates"]/tr', [ - 'country' => Atrox\Matcher::single('td[1]/a/text()'), - 'date' => Atrox\Matcher::single('td[2]/text()'), - 'year' => Atrox\Matcher::single('td[2]/a/text()'), - 'note' => Atrox\Matcher::single('td[3]/text()'), - ]), - 'alias' => Atrox\Matcher::multi('//table[@id="akas"]/tr', [ - 'country' => Atrox\Matcher::single('td[1]/text()'), - 'name' => Atrox\Matcher::single('td[2]/text()'), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processCompanyCredits($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'credits' => Atrox\Matcher::multi('//h4[@class="dataHeaderWithBorder"]', [ - 'name' => Atrox\Matcher::single('text()'), - 'companies' => Atrox\Matcher::multi('following-sibling::ul[1]/li', [ - 'companyName' => Atrox\Matcher::single('a/text()'), - 'companyLink' => Atrox\Matcher::single('a/@href'), - 'companyNote' => Atrox\Matcher::single('text()[last()]'), - ]), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processLocations($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'locations' => Atrox\Matcher::multi('//div[contains(@class, "soda sodavote")]/dt/a/text()') - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processTechnical($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'runtime' => Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Runtime")]/following-sibling::td/text()'), - 'color' => Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Color")]/following-sibling::td/a/text()'), - 'ratio' => Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Aspect Ratio")]/following-sibling::td/text()'), - 'camera' => Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Camera")]/following-sibling::td/text()'), - 'laboratory' => Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Laboratory")]/following-sibling::td/text()'), - 'filmLength' => Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Film Length")]/following-sibling::td/text()'), - 'negativeFormat' => Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Negative Format")]/following-sibling::td/text()'), - 'cineProcess' => Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Cinematographic Process")]/following-sibling::td/text()'), - 'printed' => Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Printed Film Format")]/following-sibling::td/text()'), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processTagLines($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'tagLines' => Atrox\Matcher::multi('//div[@id="taglines_content"]/div[contains(@class, "soda")]/text()'), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processPlotSummary($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'plotSummary' => Atrox\Matcher::multi('//ul[@class="zebraList"]/li/p/text()'), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processSynopsis($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'synopsis' => Atrox\Matcher::multi('//div[@id="swiki.2.1"]/text()'), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processKeywords($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'keywords' => Atrox\Matcher::multi('//table[@class="dataTable evenWidthTable2Col"]/tbody/tr/td[1]/div/a/text()'), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processTrivia($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'trivia' => Atrox\Matcher::multi('//div[@id="trivia_content"]/div[@class="list"]/div', [ - 'id' => Atrox\Matcher::single('@id'), - 'text' => Atrox\Matcher::multi('div[@class="sodatext"]/descendant-or-self::text()'), - 'relevancy' => Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processGoofs($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'goofs' => Atrox\Matcher::multi('//div[@id="goofs_content"]/div[@class="list"]/div', [ - 'id' => Atrox\Matcher::single('@id'), - 'text' => Atrox\Matcher::multi('div[@class="sodatext"]/descendant-or-self::text()'), - 'relevancy' => Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processCrazyCredits($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'credits' => Atrox\Matcher::multi('//div[@id="crazycredits_content"]/div[@class="list"]/div', [ - 'id' => Atrox\Matcher::single('@id'), - 'text' => Atrox\Matcher::multi('div[@class="sodatext"]/descendant-or-self::text()'), - 'relevancy' => Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param string $response - * @return array - */ - public function processQuotes($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'quotes' => Atrox\Matcher::multi('//div[@id="quotes_content"]/div[@class="list"]/div', [ - 'id' => Atrox\Matcher::single('@id'), - 'text' => Atrox\Matcher::multi('div[@class="sodatext"]/p/descendant-or-self::text()'), - 'relevancy' => Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param $response - * @return array - */ - public function processConnections($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - 'connections' => Atrox\Matcher::multi('//div[@id="connections_content"]/div[@class="list"]/div', [ - 'id' => Atrox\Matcher::single('a/@href'), - 'group' => Atrox\Matcher::single('preceding-sibling::h4[1]/text()'), - 'note' => Atrox\Matcher::single('descendant-or-self::text()[position() > 2]'), - ]), - ]) - ->fromHtml(); - - return $match($response); - } - - - /** - * @param $response - * @return array - */ - public function processImages($response) - { - $match = Atrox\Matcher::single([ - 'id' => Atrox\Matcher::single('//meta[@property="pageId"]/@content'), - ]) - ->fromHtml(); - - return $match($response); - } -} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessAlternativeVersions.php b/src/IMDB/Matcher/ProcessAlternativeVersions.php new file mode 100644 index 0000000..0bebed9 --- /dev/null +++ b/src/IMDB/Matcher/ProcessAlternativeVersions.php @@ -0,0 +1,19 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'alternate' => \Atrox\Matcher::multi('//div[@id="alternateversions_content"]/div/text()') + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessAwards.php b/src/IMDB/Matcher/ProcessAwards.php new file mode 100644 index 0000000..94cbd7d --- /dev/null +++ b/src/IMDB/Matcher/ProcessAwards.php @@ -0,0 +1,27 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'awards' => \Atrox\Matcher::multi('//div[@class="article listo"]/h3', [ + 'event' => \Atrox\Matcher::single('text()'), + 'status' => \Atrox\Matcher::single('following-sibling::table/tr/td/b/text()'), + 'award' => \Atrox\Matcher::single('following-sibling::table/tr/td/span/text()'), + 'category' => \Atrox\Matcher::multi('following-sibling::table[1]/tr/td[@class="award_description"]', [ + 'name' => \Atrox\Matcher::single('text()'), + 'people' => \Atrox\Matcher::multi('a/@href'), + ]), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessBusiness.php b/src/IMDB/Matcher/ProcessBusiness.php new file mode 100644 index 0000000..b1e7d3b --- /dev/null +++ b/src/IMDB/Matcher/ProcessBusiness.php @@ -0,0 +1,18 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessCompanyCredits.php b/src/IMDB/Matcher/ProcessCompanyCredits.php new file mode 100644 index 0000000..e3ed625 --- /dev/null +++ b/src/IMDB/Matcher/ProcessCompanyCredits.php @@ -0,0 +1,26 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'credits' => \Atrox\Matcher::multi('//h4[@class="dataHeaderWithBorder"]', [ + 'name' => \Atrox\Matcher::single('text()'), + 'companies' => \Atrox\Matcher::multi('following-sibling::ul[1]/li', [ + 'companyName' => \Atrox\Matcher::single('a/text()'), + 'companyLink' => \Atrox\Matcher::single('a/@href'), + 'companyNote' => \Atrox\Matcher::single('text()[last()]'), + ]), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessConnections.php b/src/IMDB/Matcher/ProcessConnections.php new file mode 100644 index 0000000..a5ac3a4 --- /dev/null +++ b/src/IMDB/Matcher/ProcessConnections.php @@ -0,0 +1,23 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'connections' => \Atrox\Matcher::multi('//div[@id="connections_content"]/div[@class="list"]/div', [ + 'id' => \Atrox\Matcher::single('a/@href'), + 'group' => \Atrox\Matcher::single('preceding-sibling::h4[1]/text()'), + 'note' => \Atrox\Matcher::single('descendant-or-self::text()[position() > 2]'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessCrazyCredits.php b/src/IMDB/Matcher/ProcessCrazyCredits.php new file mode 100644 index 0000000..26498c4 --- /dev/null +++ b/src/IMDB/Matcher/ProcessCrazyCredits.php @@ -0,0 +1,23 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'credits' => \Atrox\Matcher::multi('//div[@id="crazycredits_content"]/div[@class="list"]/div', [ + 'id' => \Atrox\Matcher::single('@id'), + 'text' => \Atrox\Matcher::multi('div[@class="sodatext"]/descendant-or-self::text()'), + 'relevancy' => \Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessFullCredits.php b/src/IMDB/Matcher/ProcessFullCredits.php new file mode 100644 index 0000000..c88cb85 --- /dev/null +++ b/src/IMDB/Matcher/ProcessFullCredits.php @@ -0,0 +1,33 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'cast' => \Atrox\Matcher::multi('//table[@class="cast_list"]/tr', [ + 'person' => \Atrox\Matcher::single('./td[1]/a/@href'), + 'person_name' => \Atrox\Matcher::single('.//span[@itemprop="name"]'), + 'character' => \Atrox\Matcher::single('./td[@class="character"]/div/a[1]/@href'), + 'character_name' => \Atrox\Matcher::single('./td[@class="character"]/div/a[1]'), + 'alias' => \Atrox\Matcher::single('./td[@class="character"]/div/a[2]/@href'), + 'alias_name' => \Atrox\Matcher::single('./td[@class="character"]/div/a[2]'), + 'description' => \Atrox\Matcher::single('./td[@class="character"]/div/text()[last()]'), + ]), + 'crew' => \Atrox\Matcher::multi('//h4[@class="dataHeaderWithBorder"]', [ + 'role_name' => \Atrox\Matcher::single('./text()'), + 'people' => \Atrox\Matcher::multi('following-sibling::table[@class="simpleTable simpleCreditsTable"][1]/tbody/tr', [ + 'person' => \Atrox\Matcher::single('./td[1]/a/@href'), + 'person_name' => \Atrox\Matcher::single('./td[1]/a/text()'), + 'description' => \Atrox\Matcher::single('./td[3]/text()'), + ]), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessGoofs.php b/src/IMDB/Matcher/ProcessGoofs.php new file mode 100644 index 0000000..d9dd193 --- /dev/null +++ b/src/IMDB/Matcher/ProcessGoofs.php @@ -0,0 +1,23 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'goofs' => \Atrox\Matcher::multi('//div[@id="goofs_content"]/div[@class="list"]/div', [ + 'id' => \Atrox\Matcher::single('@id'), + 'text' => \Atrox\Matcher::multi('div[@class="sodatext"]/descendant-or-self::text()'), + 'relevancy' => \Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessImage.php b/src/IMDB/Matcher/ProcessImage.php new file mode 100644 index 0000000..3d070de --- /dev/null +++ b/src/IMDB/Matcher/ProcessImage.php @@ -0,0 +1,19 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'imageData' => \Atrox\Matcher::single('//script[@id="imageJson"]/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessKeywords.php b/src/IMDB/Matcher/ProcessKeywords.php new file mode 100644 index 0000000..0cbd51b --- /dev/null +++ b/src/IMDB/Matcher/ProcessKeywords.php @@ -0,0 +1,19 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'keywords' => \Atrox\Matcher::multi('//table[@class="dataTable evenWidthTable2Col"]/tbody/tr/td[1]/div/a/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessLocations.php b/src/IMDB/Matcher/ProcessLocations.php new file mode 100644 index 0000000..9c95d62 --- /dev/null +++ b/src/IMDB/Matcher/ProcessLocations.php @@ -0,0 +1,19 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'locations' => \Atrox\Matcher::multi('//div[contains(@class, "soda sodavote")]/dt/a/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessMedia.php b/src/IMDB/Matcher/ProcessMedia.php new file mode 100644 index 0000000..77d85cb --- /dev/null +++ b/src/IMDB/Matcher/ProcessMedia.php @@ -0,0 +1,24 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'media' => \Atrox\Matcher::multi('//div[@id="media_index_thumbnail_grid"]/a', [ + 'link' => \Atrox\Matcher::single('@href'), + 'title' => \Atrox\Matcher::single('@title'), + ]), + 'mediaTypes' => \Atrox\Matcher::multi('//div[@id="media_index_type_filters"]/ul/li/a/@href'), + 'pages' => \Atrox\Matcher::multi('//div[@class="media_index_pagination leftright"][1]/div[@id="right"]/span/a/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessMovie.php b/src/IMDB/Matcher/ProcessMovie.php new file mode 100644 index 0000000..d5304f8 --- /dev/null +++ b/src/IMDB/Matcher/ProcessMovie.php @@ -0,0 +1,30 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'title' => \Atrox\Matcher::single('//h1/text()'), + 'year' => \Atrox\Matcher::single('//span[@id="titleYear"]/a/text()'), + 'rating' => \Atrox\Matcher::single('//span[@itemprop="ratingValue"]/text()'), + 'ratingCount' => \Atrox\Matcher::single('//span[@itemprop="ratingCount"]/text()'), + 'poster' => \Atrox\Matcher::single('//img[@itemprop="image"]/@src'), + 'description' => \Atrox\Matcher::single('//div[@itemprop="description"]/text()'), + 'genres' => \Atrox\Matcher::multi('//div[@itemprop="genre"]/a/text()'), + 'links' => \Atrox\Matcher::multi('//div[@class="quicklinkSectionItem"]/a[@class="quicklink"]/@href'), + + 'season' => \Atrox\Matcher::single('//div[@class="button_panel navigation_panel"]/div/div/div/div/text()[1]'), + 'episode' => \Atrox\Matcher::single('//div[@class="button_panel navigation_panel"]/div/div/div/div/text()[2]'), + 'show' => \Atrox\Matcher::single('//div[@class="titleParent"]/a/@href'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessPlotSummary.php b/src/IMDB/Matcher/ProcessPlotSummary.php new file mode 100644 index 0000000..4e6be11 --- /dev/null +++ b/src/IMDB/Matcher/ProcessPlotSummary.php @@ -0,0 +1,18 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'plotSummary' => \Atrox\Matcher::multi('//ul[@class="zebraList"]/li/p/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessQuotes.php b/src/IMDB/Matcher/ProcessQuotes.php new file mode 100644 index 0000000..88a0b78 --- /dev/null +++ b/src/IMDB/Matcher/ProcessQuotes.php @@ -0,0 +1,22 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'quotes' => \Atrox\Matcher::multi('//div[@id="quotes_content"]/div[@class="list"]/div', [ + 'id' => \Atrox\Matcher::single('@id'), + 'text' => \Atrox\Matcher::multi('div[@class="sodatext"]/p/descendant-or-self::text()'), + 'relevancy' => \Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessReleaseInfo.php b/src/IMDB/Matcher/ProcessReleaseInfo.php new file mode 100644 index 0000000..6f13150 --- /dev/null +++ b/src/IMDB/Matcher/ProcessReleaseInfo.php @@ -0,0 +1,28 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'release' => \Atrox\Matcher::multi('//table[@id="release_dates"]/tr', [ + 'country' => \Atrox\Matcher::single('td[1]/a/text()'), + 'date' => \Atrox\Matcher::single('td[2]/text()'), + 'year' => \Atrox\Matcher::single('td[2]/a/text()'), + 'note' => \Atrox\Matcher::single('td[3]/text()'), + ]), + 'alias' => \Atrox\Matcher::multi('//table[@id="akas"]/tr', [ + 'country' => \Atrox\Matcher::single('td[1]/text()'), + 'name' => \Atrox\Matcher::single('td[2]/text()'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessSynopsis.php b/src/IMDB/Matcher/ProcessSynopsis.php new file mode 100644 index 0000000..34f3c5f --- /dev/null +++ b/src/IMDB/Matcher/ProcessSynopsis.php @@ -0,0 +1,16 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'synopsis' => \Atrox\Matcher::multi('//div[@id="swiki.2.1"]/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessTagLines.php b/src/IMDB/Matcher/ProcessTagLines.php new file mode 100644 index 0000000..e37b5ac --- /dev/null +++ b/src/IMDB/Matcher/ProcessTagLines.php @@ -0,0 +1,18 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'tagLines' => \Atrox\Matcher::multi('//div[@id="taglines_content"]/div[contains(@class, "soda")]/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessTechnical.php b/src/IMDB/Matcher/ProcessTechnical.php new file mode 100644 index 0000000..d833ebf --- /dev/null +++ b/src/IMDB/Matcher/ProcessTechnical.php @@ -0,0 +1,27 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'runtime' => \Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Runtime")]/following-sibling::td/text()'), + 'color' => \Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Color")]/following-sibling::td/a/text()'), + 'ratio' => \Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Aspect Ratio")]/following-sibling::td/text()'), + 'camera' => \Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Camera")]/following-sibling::td/text()'), + 'laboratory' => \Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Laboratory")]/following-sibling::td/text()'), + 'filmLength' => \Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Film Length")]/following-sibling::td/text()'), + 'negativeFormat' => \Atrox\Matcher::single('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Negative Format")]/following-sibling::td/text()'), + 'cineProcess' => \Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Cinematographic Process")]/following-sibling::td/text()'), + 'printed' => \Atrox\Matcher::multi('//table[@class="dataTable labelValueTable"]/tbody/tr/td[contains(text(), "Printed Film Format")]/following-sibling::td/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessTrivia.php b/src/IMDB/Matcher/ProcessTrivia.php new file mode 100644 index 0000000..91fda7b --- /dev/null +++ b/src/IMDB/Matcher/ProcessTrivia.php @@ -0,0 +1,23 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'trivia' => \Atrox\Matcher::multi('//div[@id="trivia_content"]/div[@class="list"]/div', [ + 'id' => \Atrox\Matcher::single('@id'), + 'text' => \Atrox\Matcher::multi('div[@class="sodatext"]/descendant-or-self::text()'), + 'relevancy' => \Atrox\Matcher::single('div[@class="did-you-know-actions"]/a/text()'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Matcher/ProcessVideo.php b/src/IMDB/Matcher/ProcessVideo.php new file mode 100644 index 0000000..f029420 --- /dev/null +++ b/src/IMDB/Matcher/ProcessVideo.php @@ -0,0 +1,34 @@ + \Atrox\Matcher::single('//iframe[@id="video-player-container"]/@src'), + 'description' => \Atrox\Matcher::multi('//table[@id="video-details"]/tr', [ + 'title' => \Atrox\Matcher::single('td/strong/text()'), + 'description' => \Atrox\Matcher::single('td[2]/span/text()'), + 'links' => \Atrox\Matcher::single('td[2]/a/@href'), + ]), + ]) + ->fromHtml(); + + return $match($response); + } + + + public function processObject(string $response) : array + { + $match = \Atrox\Matcher::single([ + 'videoObject' => \Atrox\Matcher::single('//script[@class="imdb-player-data"]/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} diff --git a/src/IMDB/Matcher/ProcessVideoGallery.php b/src/IMDB/Matcher/ProcessVideoGallery.php new file mode 100644 index 0000000..7af48cf --- /dev/null +++ b/src/IMDB/Matcher/ProcessVideoGallery.php @@ -0,0 +1,21 @@ + \Atrox\Matcher::single('//meta[@property="pageId"]/@content'), + 'videos' => \Atrox\Matcher::multi('//div[@class="search-results"]/ol/li/div/a/@data-video'), + 'pages' => \Atrox\Matcher::multi('//div[@id="video_gallery_content"]/div[@class="pagination video-search-navigation"][1]' + . '/span[@class="pagination"]/span[@class="pagination"]/a/text()'), + ]) + ->fromHtml(); + + return $match($response); + } +} \ No newline at end of file diff --git a/src/IMDB/Parser.php b/src/IMDB/Parser.php index 12d6391..9b883b1 100644 --- a/src/IMDB/Parser.php +++ b/src/IMDB/Parser.php @@ -2,481 +2,178 @@ namespace MovieParser\IMDB; -use MovieParser; -use GuzzleHttp; class Parser { const STATUS_OK = 200; - /** @var GuzzleHttp\Client */ - private $client; - /** @var UrlBuilder */ - private $urlBuilder; - /** @var Matcher */ - private $matcher; - /** @var string */ - private $url; - - - public function __construct( - UrlBuilder $urlBuilder - , Matcher $matcher - ) { - $this->urlBuilder = $urlBuilder; - $this->matcher = $matcher; - } - - - /** - * @param string $input Input string - id, link or whatever - * @param bool $full load all dependencies? - * @return DTO\* - * @throws Exception\BadResponseException - */ - public function get($input, $full = FALSE) - { - // 1. get client - $this->setUpClient(); - - // 2. build url - $this->url = $this->urlBuilder->buildUrl($input); - - // 3. Get content - $content = $this->client->get($this->url); - if ($content->getStatusCode() !== self::STATUS_OK) { - throw new MovieParser\IMDB\Exception\BadResponseException; - } - - // 4. Process content - $data = $this->matcher->process($content->getBody()->getContents()); - - // 5. Map to entity - $entity = $this->createEntity($data); - - if ($full) { - // 6. Get Links - // 7. foreach links get content - // 8. map to entities - foreach ($data['links'] as $link) { - $this->loadFullCredits($link, $entity); - $this->loadReleaseInfo($link, $entity); - $this->loadCompanyCredits($link, $entity); - $this->loadLocations($link, $entity); - $this->loadTechnical($link, $entity); - $this->loadTagLines($link, $entity); - $this->loadPlotSummary($link, $entity); - $this->loadTrivia($link, $entity); - $this->loadGoofs($link, $entity); - $this->loadCrazyCredits($link, $entity); - $this->loadQuotes($link, $entity); - $this->loadConnections($link, $entity); - $this->loadImages($link, $entity); - } - } - - // 9. return main entity - - return $entity; - } - - - public function setUpClient() - { - $this->client = new GuzzleHttp\Client(); - } - - /** - * @param array $data - * @return MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series + * @var \GuzzleHttp\Client */ - public function createEntity($data) - { - switch ($data['type']) { - case Matcher::TYPE_SERIES: - $entity = new MovieParser\IMDB\DTO\Series($data); - break; - - case Matcher::TYPE_MOVIE: - default: - $entity = new MovieParser\IMDB\DTO\Movie($data); - break; - } - - return $entity; - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadTechnical($link, $entity) - { - if (strpos($link, UrlBuilder::URL_TECHNICAL)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_TECHNICAL); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processTechnical($content->getBody()->getContents()); - if (strpos($data['runtime'], 'hr')) { - $exploded = explode('min', $data['runtime']); - unset($exploded[2]); - preg_match("/[0-9]+/", end($exploded), $runtime); - } else { - preg_match("/[0-9]+/", $data['runtime'], $runtime); - } - $entity->setRuntime($runtime[0]); - $entity->setColor($data['color']); - $entity->setRatio($data['ratio']); - $entity->setCamera($data['camera']); - $entity->setLaboratory($data['laboratory']); - $entity->setFilmLength($data['filmLength']); - $entity->setNegativeFormat($data['negativeFormat']); - $entity->setCineProcess($data['cineProcess']); - $entity->setPrinted($data['printed']); - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadLocations($link, $entity) - { - if (strpos($link, UrlBuilder::URL_LOCATIONS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_LOCATIONS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processLocations($content->getBody()->getContents()); - $entity->setLocations($data['locations']); - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - * @throws Exception\IncompleteId - */ - public function loadCompanyCredits($link, $entity) - { - if (strpos($link, UrlBuilder::URL_COMPANY_CREDITS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_COMPANY_CREDITS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processCompanyCredits($content->getBody()->getContents()); - foreach ($data['credits'] as $creditData) { - foreach ($creditData['companies'] as $companyData) { - $company = new MovieParser\IMDB\DTO\Company([]); - $company->setName($companyData['companyName']); - $company->setId('co' . $this->urlBuilder->getId($companyData['companyLink'])); - $credit = new MovieParser\IMDB\DTO\Credit(); - $credit->setCompany($company); - $credit->setNote($companyData['companyNote']); - $entity->addCredit($credit); - } - } - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadReleaseInfo($link, $entity) - { - if (strpos($link, UrlBuilder::URL_RELEASE_INFO)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_RELEASE_INFO); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processReleaseInfo($content->getBody()->getContents()); - foreach ($data['release'] as $releaseData) { - $release = new MovieParser\IMDB\DTO\Release($releaseData); - $entity->addRelease($release); - } - foreach ($data['alias'] as $aliasData) { - $alias = new MovieParser\IMDB\DTO\Alias($aliasData); - $entity->addAlias($alias); - } - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadFullCredits($link, $entity) - { - if (strpos($link, UrlBuilder::URL_FULL_CREDITS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_FULL_CREDITS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processFullCredits($content->getBody()->getContents()); - foreach ($data['cast'] as $personData) { - $role = new MovieParser\IMDB\DTO\Role(); - $role->setName('Cast'); - $role->setType('Cast'); - $role->setDescription($personData['description']); - - if ($personData['person']) { - $person = new MovieParser\IMDB\DTO\Person(); - $person->setId(UrlBuilder::TYPE_PERSON . $this->urlBuilder->getId($personData['person'])); - $person->setName($personData['person_name']); - $role->setPerson($person); - } - - if ($personData['character']) { - $character = new MovieParser\IMDB\DTO\Character(); - $character->setId(UrlBuilder::TYPE_CHARACTER . $this->urlBuilder->getId($personData['character'])); - $character->setName($personData['character_name']); - $role->setCharacter($character); - } - - if ($personData['alias']) { - $alias = new MovieParser\IMDB\DTO\Character(); - $alias->setId(UrlBuilder::TYPE_CHARACTER . $this->urlBuilder->getId($personData['alias'])); - $alias->setName($personData['alias_name']); - $role->setAlias($alias); - } - - $entity->addPerson($role); - } - foreach ($data['crew'] as $crewData) { - foreach ($crewData['people'] as $crewPerson) { - if ( ! $crewPerson['person']) { - continue; - } - $role = new MovieParser\IMDB\DTO\Role(); - $role->setName($crewData['role_name']); - $role->setType('Crew'); - $role->setDescription($crewPerson['description']); - - $person = new MovieParser\IMDB\DTO\Person(); - $person->setId(UrlBuilder::TYPE_PERSON . $this->urlBuilder->getId($crewPerson['person'])); - $person->setName($crewPerson['person_name']); - $role->setPerson($person); - - $entity->addPerson($role); - } - } - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadTagLines($link, $entity) - { - if (strpos($link, UrlBuilder::URL_TAG_LINE)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_TAG_LINE); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processTagLines($content->getBody()->getContents()); - $entity->setTagLines($data['tagLines']); - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadPlotSummary($link, $entity) - { - if (strpos($link, UrlBuilder::URL_PLOT_SUMMARY)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_PLOT_SUMMARY); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processPlotSummary($content->getBody()->getContents()); - $entity->setPlotSummary($data['plotSummary']); - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadSynopsis($link, $entity) - { - if (strpos($link, UrlBuilder::URL_SYNOPSIS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_SYNOPSIS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processSynopsis($content->getBody()->getContents()); - $synopsis = ''; - foreach ($data['synopsis'] as $item) { - $synopsis .= str_replace(['(', ')'], '', $item); - } - $synopsis = str_replace(' ', ' ', $synopsis); - $entity->setSynopsis($synopsis); - } - } - } - - - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadKeywords($link, $entity) - { - if (strpos($link, UrlBuilder::URL_KEYWORDS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_KEYWORDS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processKeywords($content->getBody()->getContents()); - $entity->setKeyWords($data['keywords']); - } - } - } - + private $client; /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity + * @var UrlBuilder */ - public function loadTrivia($link, $entity) - { - if (strpos($link, UrlBuilder::URL_TRIVIA)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_TRIVIA); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processTrivia($content->getBody()->getContents()); - $triviaData = []; - foreach ($data['trivia'] as $value) { - $trivia = new MovieParser\IMDB\DTO\Trivia(); - $trivia->setId($value['id']); - $trivia->setText(implode(' ', $value['text'])); - $trivia->setVideo($entity->getId()); - preg_match("/[0-9]+/", $value['relevancy'], $relevancy); - $trivia->setRelevancy(reset($relevancy)); - $triviaData[] = $trivia; - } - $entity->setTrivia($triviaData); - } - } - } - + private $urlBuilder; /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity + * @var string */ - public function loadGoofs($link, $entity) - { - if (strpos($link, UrlBuilder::URL_GOOFS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_GOOFS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processGoofs($content->getBody()->getContents()); - $goofsData = []; - foreach ($data['goofs'] as $value) { - $goof = new MovieParser\IMDB\DTO\Goof(); - $goof->setId($value['id']); - $goof->setText(implode(' ', $value['text'])); - $goof->setVideo($entity->getId()); - preg_match("/[0-9]+/", $value['relevancy'], $relevancy); - $goof->setRelevancy(reset($relevancy)); - $goofsData[] = $goof; - } - $entity->setGoofs($goofsData); - } - } - } - + private $url; /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadCrazyCredits($link, $entity) - { - if (strpos($link, UrlBuilder::URL_CRAZY_CREDITS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_CRAZY_CREDITS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processCompanyCredits($content->getBody()->getContents()); - $crazyData = []; - foreach ($data['credits'] as $value) { - $crazyCredit = new MovieParser\IMDB\DTO\CrazyCredit(); - $crazyCredit->setId($value['id']); - $crazyCredit->setText(implode(' ', $value['text'])); - $crazyCredit->setVideo($entity->getId()); - preg_match("/[0-9]+/", $value['relevancy'], $relevancy); - $crazyCredit->setRelevancy(reset($relevancy)); - $crazyData[] = $crazyCredit; - } - $entity->setCrazyCredits($crazyData); - } - } - } + * @var \MovieParser\IMDB\Parser\LoadMovie + */ + private $loadMovie; + /** @var \MovieParser\IMDB\Parser\LoadAlternativeVersions */ + private $loadAlternativeVersions; + /** @var \MovieParser\IMDB\Parser\LoadAwards */ + private $loadAwards; + /** @var \MovieParser\IMDB\Parser\LoadBusiness */ + private $loadBusiness; + /** @var \MovieParser\IMDB\Parser\LoadCompanyCredits */ + private $loadCompanyCredits; + /** @var \MovieParser\IMDB\Parser\LoadConnections */ + private $loadConnections; + /** @var \MovieParser\IMDB\Parser\LoadCrazyCredits */ + private $loadCrazyCredits; + /** @var \MovieParser\IMDB\Parser\LoadFullCredits */ + private $loadFullCredits; + /** @var \MovieParser\IMDB\Parser\LoadGoofs */ + private $loadGoofs; + /** @var \MovieParser\IMDB\Parser\LoadKeywords */ + private $loadKeywords; + /** @var \MovieParser\IMDB\Parser\LoadLocations */ + private $loadLocations; + /** @var \MovieParser\IMDB\Parser\LoadMedia */ + private $loadMedia; + /** @var \MovieParser\IMDB\Parser\LoadPlotSummary */ + private $loadPlotSummary; + /** @var \MovieParser\IMDB\Parser\LoadQuotes */ + private $loadQuotes; + /** @var \MovieParser\IMDB\Parser\LoadRatings */ + private $loadRatings; + /** @var \MovieParser\IMDB\Parser\LoadReleaseInfo */ + private $loadReleaseInfo; + /** @var \MovieParser\IMDB\Parser\LoadReviews */ + private $loadReviews; + /** @var \MovieParser\IMDB\Parser\LoadSoundtrack */ + private $loadSoundtrack; + /** @var \MovieParser\IMDB\Parser\LoadSynopsis */ + private $loadSynopsis; + /** @var \MovieParser\IMDB\Parser\LoadTagLines */ + private $loadTagLines; + /** @var \MovieParser\IMDB\Parser\LoadTechnical */ + private $loadTechnical; + /** @var \MovieParser\IMDB\Parser\LoadTrivia */ + private $loadTrivia; + /** @var \MovieParser\IMDB\Parser\LoadVideoGallery */ + private $loadVideoGallery; - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadQuotes($link, $entity) + public function __construct( + UrlBuilder $urlBuilder + , \MovieParser\IMDB\Parser\LoadMovie $loadMovie + , \MovieParser\IMDB\Parser\LoadAlternativeVersions $loadAlternativeVersions + , \MovieParser\IMDB\Parser\LoadAwards $loadAwards + , \MovieParser\IMDB\Parser\LoadBusiness $loadBusiness + , \MovieParser\IMDB\Parser\LoadCompanyCredits $loadCompanyCredits + , \MovieParser\IMDB\Parser\LoadConnections $loadConnections + , \MovieParser\IMDB\Parser\LoadCrazyCredits $loadCrazyCredits + , \MovieParser\IMDB\Parser\LoadFullCredits $loadFullCredits + , \MovieParser\IMDB\Parser\LoadGoofs $loadGoofs + , \MovieParser\IMDB\Parser\LoadKeywords $loadKeywords + , \MovieParser\IMDB\Parser\LoadLocations $loadLocations + , \MovieParser\IMDB\Parser\LoadMedia $loadMedia + , \MovieParser\IMDB\Parser\LoadPlotSummary $loadPlotSummary + , \MovieParser\IMDB\Parser\LoadQuotes $loadQuotes + , \MovieParser\IMDB\Parser\LoadRatings $loadRatings + , \MovieParser\IMDB\Parser\LoadReleaseInfo $loadReleaseInfo + , \MovieParser\IMDB\Parser\LoadReviews $loadReviews + , \MovieParser\IMDB\Parser\LoadSoundtrack $loadSoundtrack + , \MovieParser\IMDB\Parser\LoadSynopsis $loadSynopsis + , \MovieParser\IMDB\Parser\LoadTagLines $loadTagLines + , \MovieParser\IMDB\Parser\LoadTechnical $loadTechnical + , \MovieParser\IMDB\Parser\LoadTrivia $loadTrivia + , \MovieParser\IMDB\Parser\LoadVideoGallery $loadVideoGallery + ) { + $this->client = new \GuzzleHttp\Client(); + $this->urlBuilder = $urlBuilder; + $this->loadMovie = $loadMovie; + $this->loadAlternativeVersions = $loadAlternativeVersions; + $this->loadAwards = $loadAwards; + $this->loadBusiness = $loadBusiness; + $this->loadCompanyCredits = $loadCompanyCredits; + $this->loadConnections = $loadConnections; + $this->loadCrazyCredits = $loadCrazyCredits; + $this->loadFullCredits = $loadFullCredits; + $this->loadGoofs = $loadGoofs; + $this->loadKeywords = $loadKeywords; + $this->loadLocations = $loadLocations; + $this->loadMedia = $loadMedia; + $this->loadPlotSummary = $loadPlotSummary; + $this->loadQuotes = $loadQuotes; + $this->loadRatings = $loadRatings; + $this->loadReleaseInfo = $loadReleaseInfo; + $this->loadReviews = $loadReviews; + $this->loadSoundtrack = $loadSoundtrack; + $this->loadSynopsis = $loadSynopsis; + $this->loadTagLines = $loadTagLines; + $this->loadTechnical = $loadTechnical; + $this->loadTrivia = $loadTrivia; + $this->loadVideoGallery = $loadVideoGallery; + } + + public function get(string $input) : \MovieParser\IMDB\DTO\Movie + { + $this->setUpUrl($input); + + $movie = $this->loadMovie->load($this->getUrl()); + $this->loadAlternativeVersions->load($this->getUrl(UrlBuilder::URL_ALTERNATE), $movie); + $this->loadAwards->load($this->getUrl(UrlBuilder::URL_AWARDS), $movie); + $this->loadBusiness->load($this->getUrl(UrlBuilder::URL_BUSINESS), $movie); + $this->loadCompanyCredits->load($this->getUrl(UrlBuilder::URL_COMPANY_CREDITS), $movie); + $this->loadConnections->load($this->getUrl(UrlBuilder::URL_MOVIE_CONNECTIONS), $movie); + $this->loadCrazyCredits->load($this->getUrl(UrlBuilder::URL_CRAZY_CREDITS), $movie); + $this->loadFullCredits->load($this->getUrl(UrlBuilder::URL_FULL_CREDITS), $movie); + $this->loadGoofs->load($this->getUrl(UrlBuilder::URL_GOOFS), $movie); + $this->loadKeywords->load($this->getUrl(UrlBuilder::URL_KEYWORDS), $movie); + $this->loadLocations->load($this->getUrl(UrlBuilder::URL_LOCATIONS), $movie); + $this->loadMedia->loadMedia($this->getUrl(UrlBuilder::URL_MEDIA_INDEX), $movie); + $this->loadPlotSummary->load($this->getUrl(UrlBuilder::URL_PLOT_SUMMARY), $movie); + $this->loadQuotes->load($this->getUrl(UrlBuilder::URL_QUOTES), $movie); + $this->loadRatings->load($this->getUrl(UrlBuilder::URL_RATINGS), $movie); + $this->loadReleaseInfo->load($this->getUrl(UrlBuilder::URL_RELEASE_INFO), $movie); + $this->loadReviews->load($this->getUrl(UrlBuilder::URL_REVIEWS), $movie); + $this->loadSoundtrack->load($this->getUrl(UrlBuilder::URL_SOUNDTRACK), $movie); + $this->loadSynopsis->load($this->getUrl(UrlBuilder::URL_SYNOPSIS), $movie); + $this->loadTagLines->load($this->getUrl(UrlBuilder::URL_TAG_LINE), $movie); + $this->loadTechnical->load($this->getUrl(UrlBuilder::URL_TECHNICAL), $movie); + $this->loadTrivia->load($this->getUrl(UrlBuilder::URL_TRIVIA), $movie); + $this->loadVideoGallery->load($this->getUrl(UrlBuilder::URL_VIDEO_GALLERY), $movie); + + return $movie; + } + + + public function setUpUrl(string $input) { - if (strpos($link, UrlBuilder::URL_QUOTES)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_QUOTES); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processQuotes($content->getBody()->getContents()); - $quotesData = []; - foreach ($data['quotes'] as $value) { - $quote = new MovieParser\IMDB\DTO\Quote(); - $quote->setId($value['id']); - $quote->setText(implode(' ', $value['text'])); - $quote->setVideo($entity->getId()); - preg_match("/[0-9]+/", $value['relevancy'], $relevancy); - $quote->setRelevancy(reset($relevancy)); - $quotesData[] = $quote; - } - $entity->setQuotes($quotesData); - } - } + $this->url = $this->urlBuilder->buildUrl($input); } - /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity - */ - public function loadConnections($link, $entity) + public function getUrl(string $append = '') : string { - if (strpos($link, UrlBuilder::URL_MOVIE_CONNECTIONS)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_MOVIE_CONNECTIONS); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processConnections($content->getBody()->getContents()); - $connectionData = []; - foreach ($data['connections'] as $value) { - $connection = new MovieParser\IMDB\DTO\Connection(); - $connection->setConnection($value['id']); - $connection->setNote(implode(' ', $value['note'])); - $connection->setType(chop($value['group'], ' ')); - $connectionData[] = $connection; - } - $entity->setConnections($connectionData); - } - } + return $this->url . $append; } /** - * @param string $link - * @param MovieParser\IMDB\DTO\Movie|MovieParser\IMDB\DTO\Series $entity + * @param string $url */ - public function loadImages($link, $entity) + public function setUrl(string $url) { - if (strpos($link, UrlBuilder::URL_MEDIA_INDEX)) { - $content = $this->client->get($this->url . '/' . UrlBuilder::URL_MEDIA_INDEX); - if ($content->getStatusCode() === self::STATUS_OK) { - $data = $this->matcher->processImages($content->getBody()->getContents()); - - $entity->setImages($imageData); - } - } + $this->url = $url; } -} \ No newline at end of file +} diff --git a/src/IMDB/Parser/LoadAlternativeVersions.php b/src/IMDB/Parser/LoadAlternativeVersions.php new file mode 100644 index 0000000..7d6d67b --- /dev/null +++ b/src/IMDB/Parser/LoadAlternativeVersions.php @@ -0,0 +1,36 @@ +processAlternativeVersions = $processAlternativeVersions; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_ALTERNATE)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processAlternativeVersions->process($content->getBody()->getContents()); + + $movie->setAlternativeVersions($data['alternate']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadAwards.php b/src/IMDB/Parser/LoadAwards.php new file mode 100644 index 0000000..679c7bd --- /dev/null +++ b/src/IMDB/Parser/LoadAwards.php @@ -0,0 +1,37 @@ +processAwards = $processAwards; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_AWARDS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processAwards->process($content->getBody()->getContents()); + + $movie->setAwards($data['awards']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadBusiness.php b/src/IMDB/Parser/LoadBusiness.php new file mode 100644 index 0000000..20ca0ad --- /dev/null +++ b/src/IMDB/Parser/LoadBusiness.php @@ -0,0 +1,13 @@ +processCompanyCredits = $processCompanyCredits; + $this->client = new \GuzzleHttp\Client(); + $this->urlBuilder = $urlBuilder; + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_COMPANY_CREDITS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processCompanyCredits->process($content->getBody()->getContents()); + foreach ($data['credits'] as $creditData) { + foreach ($creditData['companies'] as $companyData) { + $company = new \MovieParser\IMDB\DTO\Company([]); + $company->setName($companyData['companyName']); + $company->setId('co' . $this->urlBuilder->getId($companyData['companyLink'])); + $credit = new \MovieParser\IMDB\DTO\Credit(); + $credit->setCompany($company); + $credit->setNote($companyData['companyNote']); + $movie->addCredit($credit); + } + } + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadConnections.php b/src/IMDB/Parser/LoadConnections.php new file mode 100644 index 0000000..143888e --- /dev/null +++ b/src/IMDB/Parser/LoadConnections.php @@ -0,0 +1,47 @@ +processConnections = $processConnections; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_MOVIE_CONNECTIONS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processConnections->process($content->getBody()->getContents()); + $connectionData = []; + foreach ($data['connections'] as $value) { + $connection = new \MovieParser\IMDB\DTO\Connection(); + $connection->setConnection($value['id']); + $connection->setType(rtrim($value['group'], ' ')); + $note = $value['note']; + if (is_array($value['note'])) { + $note = implode(' ', $value['note']); + } + $connection->setNote($note); + $connectionData[] = $connection; + } + $movie->setConnections($connectionData); + } + } + + return $movie; + } +} diff --git a/src/IMDB/Parser/LoadCrazyCredits.php b/src/IMDB/Parser/LoadCrazyCredits.php new file mode 100644 index 0000000..48733d2 --- /dev/null +++ b/src/IMDB/Parser/LoadCrazyCredits.php @@ -0,0 +1,46 @@ +processCrazyCredits = $processCrazyCredits; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_CRAZY_CREDITS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processCrazyCredits->process($content->getBody()->getContents()); + $crazyData = []; + foreach ($data['credits'] as $value) { + $crazyCredit = new \MovieParser\IMDB\DTO\CrazyCredit(); + $crazyCredit->setId($value['id']); + $crazyCredit->setText(implode(' ', $value['text'])); + $crazyCredit->setVideo($movie->getId()); + preg_match("/[0-9]+/", $value['relevancy'], $relevancy); + $crazyCredit->setRelevancy(reset($relevancy)); + $crazyData[] = $crazyCredit; + } + $movie->setCrazyCredits($crazyData); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadFullCredits.php b/src/IMDB/Parser/LoadFullCredits.php new file mode 100644 index 0000000..f51d9ab --- /dev/null +++ b/src/IMDB/Parser/LoadFullCredits.php @@ -0,0 +1,89 @@ +processFullCredits = $processFullCredits; + $this->urlBuilder = $urlBuilder; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_FULL_CREDITS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processFullCredits->process($content->getBody()->getContents()); + foreach ($data['cast'] as $personData) { + $role = new \MovieParser\IMDB\DTO\Role(); + $role->setName('Cast'); + $role->setType('Cast'); + $role->setDescription($personData['description']); + + if ($personData['person']) { + $person = new \MovieParser\IMDB\DTO\Person(); + $person->setId(\MovieParser\IMDB\UrlBuilder::TYPE_PERSON . $this->urlBuilder->getId($personData['person'])); + $person->setName($personData['person_name']); + $role->setPerson($person); + } + + if ($personData['character']) { + $character = new \MovieParser\IMDB\DTO\Character(); + $character->setId(\MovieParser\IMDB\UrlBuilder::TYPE_CHARACTER . $this->urlBuilder->getId($personData['character'])); + $character->setName($personData['character_name']); + $role->setCharacter($character); + } + + if ($personData['alias']) { + $alias = new \MovieParser\IMDB\DTO\Character(); + $alias->setId(\MovieParser\IMDB\UrlBuilder::TYPE_CHARACTER . $this->urlBuilder->getId($personData['alias'])); + $alias->setName($personData['alias_name']); + $role->setAlias($alias); + } + + $movie->addPerson($role); + } + foreach ($data['crew'] as $crewData) { + foreach ($crewData['people'] as $crewPerson) { + if ( ! $crewPerson['person']) { + continue; + } + $role = new \MovieParser\IMDB\DTO\Role(); + $role->setName($crewData['role_name']); + $role->setType('Crew'); + $role->setDescription($crewPerson['description']); + + $person = new \MovieParser\IMDB\DTO\Person(); + $person->setId(\MovieParser\IMDB\UrlBuilder::TYPE_PERSON . $this->urlBuilder->getId($crewPerson['person'])); + $person->setName($crewPerson['person_name']); + $role->setPerson($person); + + $movie->addPerson($role); + } + } + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadGoofs.php b/src/IMDB/Parser/LoadGoofs.php new file mode 100644 index 0000000..4646a29 --- /dev/null +++ b/src/IMDB/Parser/LoadGoofs.php @@ -0,0 +1,45 @@ +processGoofs = $processGoofs; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_GOOFS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processGoofs->process($content->getBody()->getContents()); + $goofsData = []; + foreach ($data['goofs'] as $value) { + $goof = new \MovieParser\IMDB\DTO\Goof(); + $goof->setId($value['id']); + $goof->setText(implode(' ', $value['text'])); + $goof->setVideo($movie->getId()); + preg_match('/\d+/', $value['relevancy'], $relevancy); + $goof->setRelevancy(reset($relevancy)); + $goofsData[] = $goof; + } + $movie->setGoofs($goofsData); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadKeywords.php b/src/IMDB/Parser/LoadKeywords.php new file mode 100644 index 0000000..c3a8fa9 --- /dev/null +++ b/src/IMDB/Parser/LoadKeywords.php @@ -0,0 +1,35 @@ +processKeywords = $processKeywords; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_KEYWORDS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processKeywords->process($content->getBody()->getContents()); + $movie->setKeyWords($data['keywords']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadLocations.php b/src/IMDB/Parser/LoadLocations.php new file mode 100644 index 0000000..81ca2d5 --- /dev/null +++ b/src/IMDB/Parser/LoadLocations.php @@ -0,0 +1,51 @@ +processLocations = $processLocations; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_TECHNICAL)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processLocations->process($content->getBody()->getContents()); + if (strpos($data['runtime'], 'hr')) { + $exploded = explode('min', $data['runtime']); + unset($exploded[2]); + preg_match('/\d+/', end($exploded), $runtime); + } else { + preg_match('/\d+/', $data['runtime'], $runtime); + } + $movie->setRuntime($runtime[0]); + $movie->setColor($data['color']); + $movie->setRatio($data['ratio']); + $movie->setCamera($data['camera']); + $movie->setLaboratory($data['laboratory']); + $movie->setFilmLength($data['filmLength']); + $movie->setNegativeFormat($data['negativeFormat']); + $movie->setCineProcess($data['cineProcess']); + $movie->setPrinted($data['printed']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadMedia.php b/src/IMDB/Parser/LoadMedia.php new file mode 100644 index 0000000..969185e --- /dev/null +++ b/src/IMDB/Parser/LoadMedia.php @@ -0,0 +1,152 @@ +urlBuilder = $urlBuilder; + $this->processMedia = $processMedia; + $this->processImage = $processImage; + $this->client = new \GuzzleHttp\Client(); + } + + + public function loadMedia(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_MEDIA_INDEX)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processMedia->process($content->getBody()->getContents()); + $baseUrl = $this->urlBuilder->buildUrl($link); + $imageData = $this->loadImageData($baseUrl . \MovieParser\IMDB\UrlBuilder::URL_MEDIA_VIEWER); + $imageEntities = []; + + foreach ($data['mediaTypes'] as $mediaType) { + $mediaTypeUrl = rtrim(\MovieParser\IMDB\UrlBuilder::URL_IMDB, '/') . $mediaType; + $mediaContent = $this->client->get($mediaTypeUrl); + $mediaData = $this->processMedia->process($mediaContent->getBody()->getContents()); + $imageType = $this->getImageType($mediaTypeUrl); + + foreach ($mediaData['media'] as $image) { + try { + $imageEntities[] = $this->createImage($image, $imageData, $imageType); + } catch (\Throwable $exception) { + + } + } + + if (count($mediaData['pages'])) { + foreach ($mediaData['pages'] as $page) { + $mediaPageContent = $this->client->get($mediaTypeUrl . '&page=' . $page); + $mediaPageData = $this->processMedia->process($mediaPageContent->getBody()->getContents()); + foreach ($mediaPageData['media'] as $image) { + try { + $imageEntities[] = $this->createImage($image, $imageData, $imageType); + } catch (\Throwable $exception) { + + } + } + } + } + } + + $movie->setImages($imageEntities); + } + } + + return $movie; + } + + + public function createImage($image, $imageData, $imageType) + { + $imageEntity = new \MovieParser\IMDB\DTO\Image(); + $imageEntity->setId($this->getImageId($image['link'])); + $imageObject = $imageData[$imageEntity->getId()]; + $imageEntity->setVideo($imageObject->relatedTitles[0]->constId ?? ''); + $imageEntity->setAuthor($imageObject->createdBy ?? ''); + $imageEntity->setCopyright($imageObject->copyright ?? ''); + $imageEntity->setSrc($imageObject->src ?? ''); + $imageEntity->setTitle($imageObject->altText ?? ''); + $imageEntity->setCharacters($imageObject->relatedCharacters ?? ''); + $imageEntity->setPeople($imageObject->relatedNames ?? ''); + $imageEntity->setType($imageType); + + return $imageEntity; + } + + + public function getImageType(string $string) : int + { + $type = 0; + + if (strpos($string, 'event')) { + $type = 1; + } elseif (strpos($string, 'still_frame')) { + $type = 2; + } elseif (strpos($string, 'publicity')) { + $type = 3; + } elseif (strpos($string, 'production_art')) { + $type = 4; + } + + return $type; + } + + + public function getImageId(string $string) : string + { + preg_match('/rm\d+/', $string, $output); + + if ( ! isset($output[0])) { + throw new \MovieParser\IMDB\Exception\IncompleteId; + } + + return $output[0]; + } + + + public function loadImageData(string $link) : array + { + $data = []; + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $imageData = $this->processImage->process($content->getBody()->getContents()); + + $jsonDecode = json_decode($imageData['imageData']); + /** + * @var $allImages array + */ + $allImages = $jsonDecode->mediaViewerModel->allImages; + foreach ($allImages as $item) { + $data[$item->id] = $item; + } + } + + return $data; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadMovie.php b/src/IMDB/Parser/LoadMovie.php new file mode 100644 index 0000000..2655319 --- /dev/null +++ b/src/IMDB/Parser/LoadMovie.php @@ -0,0 +1,30 @@ +processMovie = $processMovie; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link) : \MovieParser\IMDB\DTO\Movie + { + $content = $this->client->get($link); + $data = $this->processMovie->process($content->getBody()->getContents()); + + return new \MovieParser\IMDB\DTO\Movie($data); + } +} diff --git a/src/IMDB/Parser/LoadPlotSummary.php b/src/IMDB/Parser/LoadPlotSummary.php new file mode 100644 index 0000000..97375b2 --- /dev/null +++ b/src/IMDB/Parser/LoadPlotSummary.php @@ -0,0 +1,35 @@ +processPlotSummary = $processPlotSummary; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_PLOT_SUMMARY)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processPlotSummary->process($content->getBody()->getContents()); + $movie->setPlotSummary($data['plotSummary']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadQuotes.php b/src/IMDB/Parser/LoadQuotes.php new file mode 100644 index 0000000..a16e46f --- /dev/null +++ b/src/IMDB/Parser/LoadQuotes.php @@ -0,0 +1,46 @@ +processQuotes = $processQuotes; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_QUOTES)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processQuotes->process($content->getBody()->getContents()); + $quotesData = []; + foreach ($data['quotes'] as $value) { + $quote = new \MovieParser\IMDB\DTO\Quote(); + $quote->setId($value['id']); + $quote->setText(implode(' ', $value['text'])); + $quote->setVideo($movie->getId()); + preg_match('/\d+/', $value['relevancy'], $relevancy); + $quote->setRelevancy(reset($relevancy)); + $quotesData[] = $quote; + } + $movie->setQuotes($quotesData); + } + } + + return $movie; + } +} diff --git a/src/IMDB/Parser/LoadRatings.php b/src/IMDB/Parser/LoadRatings.php new file mode 100644 index 0000000..85a6bb3 --- /dev/null +++ b/src/IMDB/Parser/LoadRatings.php @@ -0,0 +1,14 @@ +processReleaseInfo = $processReleaseInfo; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_RELEASE_INFO)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processReleaseInfo->process($content->getBody()->getContents()); + foreach ($data['release'] as $releaseData) { + $release = new \MovieParser\IMDB\DTO\Release($releaseData); + $movie->addRelease($release); + } + foreach ($data['alias'] as $aliasData) { + $alias = new \MovieParser\IMDB\DTO\Alias($aliasData); + $movie->addAlias($alias); + } + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadReviews.php b/src/IMDB/Parser/LoadReviews.php new file mode 100644 index 0000000..9316f55 --- /dev/null +++ b/src/IMDB/Parser/LoadReviews.php @@ -0,0 +1,13 @@ +processSynopsis = $processSynopsis; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_SYNOPSIS)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processSynopsis->process($content->getBody()->getContents()); + $movie->setPlotSummary($data['plotSummary']); + } + } + + return $movie; + } +} diff --git a/src/IMDB/Parser/LoadTagLines.php b/src/IMDB/Parser/LoadTagLines.php new file mode 100644 index 0000000..4d6324f --- /dev/null +++ b/src/IMDB/Parser/LoadTagLines.php @@ -0,0 +1,36 @@ +processTagLines = $processTagLines; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_TAG_LINE)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processTagLines->process($content->getBody()->getContents()); + $movie->setTagLines($data['tagLines']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadTechnical.php b/src/IMDB/Parser/LoadTechnical.php new file mode 100644 index 0000000..964297b --- /dev/null +++ b/src/IMDB/Parser/LoadTechnical.php @@ -0,0 +1,51 @@ +processTechnical = $processTechnical; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_TECHNICAL)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processTechnical->process($content->getBody()->getContents()); + if (strpos($data['runtime'], 'hr')) { + $exploded = explode('min', $data['runtime']); + unset($exploded[2]); + preg_match('/\d+/', end($exploded), $runtime); + } else { + preg_match('/\d+/', $data['runtime'], $runtime); + } + $movie->setRuntime($runtime[0]); + $movie->setColor($data['color']); + $movie->setRatio($data['ratio']); + $movie->setCamera($data['camera']); + $movie->setLaboratory($data['laboratory']); + $movie->setFilmLength($data['filmLength']); + $movie->setNegativeFormat($data['negativeFormat']); + $movie->setCineProcess($data['cineProcess']); + $movie->setPrinted($data['printed']); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadTrivia.php b/src/IMDB/Parser/LoadTrivia.php new file mode 100644 index 0000000..e4c39b5 --- /dev/null +++ b/src/IMDB/Parser/LoadTrivia.php @@ -0,0 +1,46 @@ +processTrivia = $processTrivia; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_TRIVIA)) { + $content = $this->client->get($link); + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + $data = $this->processTrivia->process($content->getBody()->getContents()); + $triviaData = []; + foreach ($data['trivia'] as $value) { + $trivia = new \MovieParser\IMDB\DTO\Trivia(); + $trivia->setId($value['id']); + $trivia->setText(implode(' ', $value['text'])); + $trivia->setVideo($movie->getId()); + preg_match('/\d+/', $value['relevancy'], $relevancy); + $trivia->setRelevancy(reset($relevancy)); + $triviaData[] = $trivia; + } + $movie->setTrivia($triviaData); + } + } + + return $movie; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadVideo.php b/src/IMDB/Parser/LoadVideo.php new file mode 100644 index 0000000..df28fa7 --- /dev/null +++ b/src/IMDB/Parser/LoadVideo.php @@ -0,0 +1,39 @@ +processVideo = $processVideo; + $this->client = new \GuzzleHttp\Client(); + } + + + public function load(string $link) : array + { + $data = []; + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_VIDEO)) { + $content = $this->client->get($link); + $data = $this->processVideo->process($content->getBody()->getContents()); + + $contentObject = $this->client->get($data['videoObject']); + $dataObject = $this->processVideo->processObject($contentObject->getBody()->getContents()); + + $data['videoObject'] = $dataObject; + } + + return $data; + } +} \ No newline at end of file diff --git a/src/IMDB/Parser/LoadVideoGallery.php b/src/IMDB/Parser/LoadVideoGallery.php new file mode 100644 index 0000000..7b9b345 --- /dev/null +++ b/src/IMDB/Parser/LoadVideoGallery.php @@ -0,0 +1,69 @@ +processVideoGallery = $processVideoGallery; + $this->urlBuilder = $urlBuilder; + $this->client = new \GuzzleHttp\Client(); + $this->loadVideo = $loadVideo; + } + + + public function load(string $link, \MovieParser\IMDB\DTO\Movie $movie) : \MovieParser\IMDB\DTO\Movie + { + if (strpos($link, \MovieParser\IMDB\UrlBuilder::URL_VIDEO_GALLERY)) { + $baseUrl = $this->urlBuilder->buildUrl($link); + $content = $this->client->get($link); + $data = $this->processVideoGallery->process($content->getBody()->getContents()); + + if ($content->getStatusCode() === \MovieParser\IMDB\Parser::STATUS_OK) { + if (count($data['pages'])) { + foreach ($data['pages'] as $page) { + if ($page === 'Next »') { + continue; + } + $mediaPageContent = $this->client->get($baseUrl . \MovieParser\IMDB\UrlBuilder::URL_VIDEO_GALLERY . '?page=' . $page); + $mediaPageData = $this->processVideoGallery->process($mediaPageContent->getBody()->getContents()); + foreach ($mediaPageData['videos'] as $item) { + $data['videos'][] = $item; + } + } + } + $videos = []; + + foreach ($data['videos'] as $videoLink) { + $videos[] = $this->loadVideo->load($videoLink); + } + + $movie->setVideos($videos); + } + } + + return $movie; + } +} diff --git a/src/IMDB/UrlBuilder.php b/src/IMDB/UrlBuilder.php index a7a873d..3c12b7b 100644 --- a/src/IMDB/UrlBuilder.php +++ b/src/IMDB/UrlBuilder.php @@ -10,12 +10,14 @@ class UrlBuilder const URL_IMDB = 'http://www.imdb.com/'; const URL_TYPE_TITLE = 'title'; + const URL_TYPE_VIDEO = 'video/imdb'; const URL_TYPE_PERSON = 'name'; const URL_TYPE_CHARACTER = 'character'; const TYPE_TITLE = 'tt'; const TYPE_PERSON = 'nm'; const TYPE_CHARACTER = 'ch'; + const TYPE_VIDEO = 'vi'; const URL_FULL_CREDITS = 'fullcredits'; @@ -42,7 +44,9 @@ class UrlBuilder const URL_SOUNDTRACK = 'soundtrack'; const URL_MEDIA_INDEX = 'mediaindex'; + const URL_MEDIA_VIEWER = 'mediaviewer'; const URL_VIDEO_GALLERY = 'videogallery'; + const URL_VIDEO = 'video'; const URL_AWARDS = 'awards'; const URL_FAQ = 'faq'; @@ -81,11 +85,14 @@ class UrlBuilder self::URL_RATINGS, self::URL_EXTERNAL_REVIEWS, self::URL_TV_SCHEDULE, + self::URL_VIDEO, ]; + /** * @param string $input * @return string + * @throws \MovieParser\IMDB\Exception\IncompleteId */ public function buildUrl($input) { @@ -99,11 +106,14 @@ public function buildUrl($input) } elseif ($type === self::TYPE_CHARACTER) { $url .= self::URL_TYPE_CHARACTER . '/'; + } elseif ($type === self::TYPE_VIDEO) { + $url .= self::URL_TYPE_VIDEO . '/'; + } else { $url .= self::URL_TYPE_TITLE . '/'; } - $url .= $type . $id; + $url .= $type . $id . '/'; return $url; } @@ -124,6 +134,9 @@ public function getType($input) } elseif (strpos($input, self::TYPE_CHARACTER)) { $type = self::TYPE_CHARACTER; + } elseif (strpos($input, self::TYPE_VIDEO)) { + $type = self::TYPE_VIDEO; + } else { $type = self::TYPE_TITLE; } @@ -139,7 +152,7 @@ public function getType($input) */ public function getId($input) { - preg_match("/[0-9]+/", $input, $output); + preg_match('/\d+/', $input, $output); if ( ! isset($output[0])) { throw new MovieParser\IMDB\Exception\IncompleteId;