blob: a236d49d25417eaea04f616599d8390312181ab8 (
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
|
<?php
/**
* Server-side script of the Netflix Stats Generator to get the personal Netflix JSON
* @author Marvin Borner
* @copyright Marvin Borner 2018
*/
$cookie = $_POST['cookie'];
if (!isset($cookie)) {
http_response_code(404);
die();
}
$isLastPage = false;
$currentPage = 0;
$result = '[';
while ($isLastPage === false) {
// Anywhere on netflix.com in console: netflix.appContext.state.model.models.serverDefs.data.BUILD_IDENTIFIER
$ch = curl_init('https://www.netflix.com/shakti/vbe1263cd/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);
curl_close($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);
}
$currentPage++;
}
if ($result !== '') {
print_r($result . ']');
} else {
http_response_code(404);
die();
}
|