forked from serima/sylvan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch.php
More file actions
30 lines (28 loc) · 1014 Bytes
/
batch.php
File metadata and controls
30 lines (28 loc) · 1014 Bytes
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
<?php
date_default_timezone_set('Asia/Tokyo');
$countries = array('jp', 'us', 'cn', 'kr');
$source_filename_prefix = array('topfree', 'toppaid', 'topgrossing');
$source_dir = "./src";
$output_dir = "./data";
// データ格納用ディレクトリが存在しなければ作る
if (!is_dir($output_dir)) mkdir($output_dir, 0777);
foreach ($countries as $country) {
$chk_dir = $output_dir . '/' . $country;
if (!is_dir($chk_dir)) {
mkdir($chk_dir, 0777);
}
}
foreach ($countries as $country) {
foreach ($source_filename_prefix as $filename_prefix) {
$filename = $source_dir . '/' . $country . '_' . $filename_prefix . '.list';
$contents = @file($filename);
foreach ($contents as $line) {
$rss_data = explode("," ,$line);
$category = trim($rss_data[0]);
$xml_url = trim($rss_data[1]);
$output_filename = $output_dir . '/' . $country . '/' . $filename_prefix . '_' . $category . '_' . date('Ymd') . '.xml';
$cmd = "wget " . $xml_url . " -O " . $output_filename;
system($cmd);
}
}
}