|
29 | 29 | $promise->then(function ($resp) use ($guzzle, &$nodes, $listinfoUrl, &$deadProviders, &$totalAdded){
|
30 | 30 | $html = $resp->getBody();
|
31 | 31 | println('Hit ' . $listinfoUrl);
|
32 |
| - preg_match_all('/href="listinfo\/(.*?)"/', $html, $m); |
33 |
| - if (empty($m[1])) { |
| 32 | + preg_match_all('/href="(\.\.\/)*listinfo\/(.*?)"/', $html, $m); |
| 33 | + if (empty($m[2])) { |
34 | 34 | if (PRESERVE_EMPTY_PROVIDERS) {
|
35 | 35 | println('Provider ' . $listinfoUrl . ' returned an empty list. Preserved according to config.');
|
36 | 36 | } else {
|
|
40 | 40 | }
|
41 | 41 | return;
|
42 | 42 | }
|
43 |
| - $testUrl = substr($listinfoUrl, 0, strlen($listinfoUrl) - 8) . 'subscribe/' . $m[1][0] . '?language=en'; |
| 43 | + $testUrl = substr($listinfoUrl, 0, strlen($listinfoUrl) - 8) . 'subscribe/' . $m[2][0] . '?language=en'; |
44 | 44 | $promise2=$guzzle->getAsync($testUrl);
|
45 | 45 | $promise2->then(function ($resp2) use ($guzzle, &$nodes, $listinfoUrl, &$deadProviders, $m, &$totalAdded, $testUrl) {
|
46 | 46 | $testHtml = $resp2->getBody();
|
|
55 | 55 | file_put_contents(DEAD_PROVIDERS_JSON, pretty_json_encode($deadProviders));
|
56 | 56 | println('Provider ' . $listinfoUrl . ' forces a captcha. Skipped & Added to dead list.');
|
57 | 57 | return;
|
| 58 | + }else if(intval($resp2->getStatusCode()/100)!=2){ |
| 59 | + $deadProviders[] = $listinfoUrl; |
| 60 | + file_put_contents(DEAD_PROVIDERS_JSON, pretty_json_encode($deadProviders)); |
| 61 | + println('Provider ' . $listinfoUrl . ' test failed. Skipped & Added to dead list.'); |
| 62 | + return; |
58 | 63 | }
|
59 | 64 | $singleAdded = 0;
|
60 |
| - foreach ($m[1] as $item) { |
| 65 | + foreach ($m[2] as $item) { |
61 | 66 | $url = substr($listinfoUrl, 0, strlen($listinfoUrl) - 8) . 'subscribe/' . $item;
|
62 | 67 | if (!in_array($url, $nodes)) {
|
63 | 68 | //println('Added node '.$url);
|
|
0 commit comments