-
Notifications
You must be signed in to change notification settings - Fork 0
/
dailyshowtimes.php
80 lines (73 loc) · 2.76 KB
/
dailyshowtimes.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/**
* Google Showtime grabber
*
* This file will grab the last showtimes of theatres nearby your zipcode.
* Please make the URL your own! You can also add parameters to this URL:
* &date=0|1|2|3 => today|1 day|2 days|etc..
* &start=10 gets the second page etc...
*
* Please download the latest version of simple_html_dom.php on sourceForge:
* http://sourceforge.net/projects/simplehtmldom/files/
*
* @author Bas van Dorst <info@basvandorst.nl>
* @version 0.1
* @package GoogleShowtime
*
* @modifyed by stephen byrne <gold.mine.labs@gmail.com>
* @GoldMinelabs.com
*/
require_once('simple_html_dom.php');
if(isset($argv[1]))
{
$near = $argv[1];
}
else
{
die("Location not given...");
}
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, 'http://www.google.com/movies?near='.$near);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10);
$str = curl_exec($curl);
curl_close($curl);
$html = str_get_html($str);
foreach($html->find('#movie_results .theater') as $div) {
// print theater and address info
$theatername = $div->find('h2 a',0)->innertext;
$theateraddress = $div->find('.info',0)->innertext;
$theateraddress = strstr($theateraddress, ' - ', true);
$theaterphone = $div->find('.info',0)->innertext;
$theaterphone = substr($theaterphone, strrpos($theaterphone,' - ') + 3);
$theaterphone = strstr($theaterphone, '<', true);
include('GetTheaterInfo.php'); //writes theater to database
// print all the movies with showtimes
foreach($div->find('.movie') as $movie) {
$movieName = urldecode($movie->find('.name a',0)->innertext);
$imdbid = $movie->find('.info',0)->innertext;
$imdbid = substr($imdbid, strrpos($imdbid,' - ') + 3);
$imdbid = substr($imdbid, strpos($imdbid,'/title/')+7);
$imdbid = strstr($imdbid, '/', true); //IMDBid is solo'd out here
$trailer = $movie->find('.info',0)->innertext;
$trailer = substr($trailer, strrpos($trailer, ' - ',(strrpos($trailer, ' - ')-strlen($trailer)-1))+3);
$trailer = substr($trailer, strpos($trailer, 'http://www.youtube.com/watch'));
$trailer = strstr($trailer, '&', true);
$trailer = str_replace('%3F','?',$trailer);
$trailer = str_replace('%3D','=',$trailer);
//Checking to make sure that we have a youtube link as the trailer. If not, we have a NULL trailer
if (strpos($trailer, 'http://www.youtube.com/watch') === false) {
$trailer = NULL;
}
$showtimes = $movie->find('.times',0)->innertext;
//regex to get showtimes
preg_match_all("/\d?\d:\d\d((pm)|(am)|(&#))/", $showtimes, $times);
//Saving the showtime as 3D if needed
if (strpos($movieName, 'in 3D') === false) { $ddd = 0; } else { $ddd = 1; }
//Save information to database
include('GetMovieInfo.php');
}
}
// clean up memory
$html->clear();
?>