-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
100 lines (90 loc) · 3.92 KB
/
index.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?php
$shows = [
'greys-anatomy',
'silicon-valley',
'South-Park'
];
$countdown_wrapper = array();
$i = 0;
foreach($shows as $show) {
$info = json_decode(file_get_contents('https://api.tvmaze.com/search/shows?q='.$show), true);
$title = $info[0]['show']['name'];
$poster_url = $info[0]['show']['image']['original'];
$poster_url = substr_replace($poster_url, 's', 4, 0);
$last_episode_link = json_decode(file_get_contents($info[0]['show']['_links']['previousepisode']['href']), true);
$last_episode_airstamp = $last_episode_link['airstamp'];
$next_episode_link = $info[0]['show']['_links']['nextepisode']['href'];
$episode_info = json_decode(file_get_contents($next_episode_link), true);
$next_episode_name = $episode_info['name'];
$next_episode_summary = $episode_info['summary'];
$next_episode_air_date = strtotime($episode_info['airstamp']);
$season = $episode_info['season'];
$episode = $episode_info['number'];
if(!$next_episode_air_date) {
$next_episode_air_date = "9999999999";
}
$countdown_wrapper[$i] = [
'next_episode_airtime' => $next_episode_air_date ,
'title' => $title ,
'poster_url' => $poster_url ,
'next_episode_name' => $next_episode_name ,
'next_episode_summary' => $next_episode_summary,
'season' => $season,
'episode' => $episode,
'last_episode_airtime' => $last_episode_airstamp,
];
$i++;
}
sort($countdown_wrapper);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>TvCountdown</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet">
<link href="style_dark.css" rel="stylesheet">
<link href="https://use.fontawesome.com/releases/v5.0.9/css/all.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.1/Chart.bundle.js"></script>
</head>
<body>
<div class="container-fluid" style="padding-top: 10px;">
<div class="row">
<?php foreach($countdown_wrapper as $countdown): ?>
<?php $img = $countdown['poster_url']; ?>
<div class="col-md-2 col-sm-12" style="height: 450px !important; min-height: 450px; margin-bottom: 8px;">
<div class="card bg-dark text-white" style="height: 450px !important; min-height: 450px;">
<div class="card-img-overlay" style="background-image: url('<?php echo $img; ?>'); background-size: cover;">
<div class="poster_overlay">
</div>
<div style="z-index: 10;">
<h3><b><?php echo $countdown['title']; ?></b></h3>
<h5 class="card-title"><b><?php echo $countdown['next_episode_name'] . ' (S'.$countdown['season'].'E'.$countdown['episode'].')'; ?></b></h5>
<p class="card-text"><?php if($countdown['next_episode_summary']!=''){ echo $countdown['next_episode_summary']; } else { echo 'No episode summary avaliable.'; } ?></p>
<p class="card-text" style="font-size: large !important; bottom: 15px; position: absolute;">
<?php if($countdown['next_episode_airtime'] < time() + 86400 ){
$secs_to_air = $countdown['next_episode_airtime'] - time();
echo 'Airs in: ' . ceil($secs_to_air / 60 / 60) . ' Hours';
}else{
if($countdown['next_episode_airtime']=='9999999999'):
echo 'No episodes avaliable';
else:
echo 'Airs: '. date('d-m-Y H:i' , $countdown['next_episode_airtime']);
endif;
} ?>
</p>
<p class="card-text" style="bottom: 15px; position: absolute;">
<small>Last episode: <?php echo date('d-m-Y' , strtotime($countdown['last_episode_airtime'])); ?></small>
</p>
</div>
</div>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
</body>
</html>