blob: 98497527df0a3db34975b6917708dfd1e5a94aa5 (
plain) (
blame)
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
|
<?php
/**
* Server-side script of the Netflix Stats Generator to get the personal Netflix JSON
* @author Marvin Borner
* @copyright Marvin Borner 2018
*/
$debug = true;
$cookie = $_POST['cookie'];
if ($debug) {
print_r(file_get_contents("debug.json"));
} else if (isset($cookie)) {
$isLastPage = false;
$currentPage = 0;
$result = '[';
while ($isLastPage === false) {
$ch = curl_init('https://www.netflix.com/api/shakti/v52f427f5/viewingactivity?pg=' . $currentPage . '&pgSize=100');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_COOKIE, $cookie);
$answer = curl_exec($ch);
if ($isLastPage = (count(json_decode($answer, true)['viewedItems']) > 0)) {
$isLastPage = false;
$result .= json_encode(json_decode($answer, true)['viewedItems']) . ',';
} else {
$isLastPage = true;
$result = substr($result, 0, -1);
}
curl_close($ch);
$currentPage++;
}
if ($result !== '') {
print_r($result . ']');
} else {
http_response_code(404);
die();
}
} else {
http_response_code(404);
die();
}
|