-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpooqjson.php
More file actions
64 lines (60 loc) · 2.84 KB
/
Copy pathpooqjson.php
File metadata and controls
64 lines (60 loc) · 2.84 KB
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
#!/usr/bin/php -q
<?php
/* Set internal character encoding to UTF-8 */
mb_internal_encoding("UTF-8");
//Default Time Zone Setting
@date_default_timezone_set('Asia/Seoul');
$ProgramId = $argv[1] ?? exit();
$start_num = $argv[2] ?? 1;
$POOQ_TV_DETAIL = 'https://apis.pooq.co.kr/vod/contents/%s?apikey=E5F3E0D30947AA5440556471321BB6D9&device=pc&partner=pooq®ion=kor&targetage=auto&credential=none&pooqzone=none&drm=wm';
$POOQ_TV_EPISODE = 'https://apis.pooq.co.kr/vod/programs-contents/%s?apikey=E5F3E0D30947AA5440556471321BB6D9&device=pc&partner=pooq®ion=kor&targetage=auto&credential=none&pooqzone=none&drm=wm&offset=0&limit=1000&orderby=old';
$options = array('http' => array('user_agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.87 Safari/537.36'));
$context = stream_context_create($options);
try {
$directors = $producers = $writers = $roles = $episodes = $collections = $genres = $countries = array();
$episode_json = json_decode(file_get_contents(sprintf($POOQ_TV_EPISODE, $ProgramId), false, $context), true)['list'];
$tvshow_json = json_decode(file_get_contents(sprintf($POOQ_TV_DETAIL, $episode_json[0]['contentid']), false, $context), true);
$tvshow = $tvshow_json;
$title = trim($tvshow['programtitle']);
$original_title = "";
$genres[] = $tvshow['genretext'];
$countries[] = "";
$year = date_format(date_create($tvshow['releasedate']), "Y");
$studio = $tvshow['channelname'];
$originally_available_at = $tvshow['releasedate'];
$summary = trim($tvshow['programsynopsis']);
$poster_url = 'http://'.trim($tvshow['programposterimage']);
foreach($episode_json as $episodeinfo):
$episodes[] = array(
'name' => $start_num,
'title' => trim($episodeinfo['episodetitle']),
'introduceDescription' => trim(strip_tags($episodeinfo['synopsis'])),
'broadcastDate' => str_replace('-', '', $episodeinfo['releasedate'])
);
$start_num++;
endforeach;
$json_array = array(
'title' => $title,
'original_title' => $original_title,
'summary' => $summary,
'year' => $year,
'originally_available_at' => $originally_available_at,
'countries' => $countries,
'studio' => $studio,
'poster' => $poster_url,
'directors' => $directors,
'producers' => $producers,
'writers' => $writers,
'episodes' => $episodes,
'roles' => $roles,
'genres' => $genres,
'collections' => $collections
);
$json_file = $title.'.json';
$fp = fopen($json_file, 'w+');
fwrite($fp, json_encode($json_array, JSON_PRETTY_PRINT+JSON_UNESCAPED_UNICODE));
fclose($fp);
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "\n";
}
?>