[ThePirateBayBridge] Remove nested function
This commit is contained in:
parent
684c69b0cd
commit
548e28249b
1 changed files with 55 additions and 55 deletions
|
@ -40,60 +40,6 @@ class ThePirateBayBridge extends BridgeAbstract {
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
function parseDateTimestamp($element){
|
|
||||||
$guessedDate = $element->find('font', 0)->plaintext;
|
|
||||||
$guessedDate = explode('Uploaded ', $guessedDate)[1];
|
|
||||||
$guessedDate = explode(',', $guessedDate)[0];
|
|
||||||
|
|
||||||
if(count(explode(':', $guessedDate)) == 1) {
|
|
||||||
$guessedDate = strptime($guessedDate, '%m-%d %Y');
|
|
||||||
$timestamp = mktime(
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
$guessedDate['tm_mon'] + 1,
|
|
||||||
$guessedDate['tm_mday'],
|
|
||||||
1900 + $guessedDate['tm_year']
|
|
||||||
);
|
|
||||||
} elseif(explode(' ', $guessedDate)[0] == 'Today') {
|
|
||||||
$guessedDate = strptime(
|
|
||||||
explode(' ', $guessedDate)[1], '%H:%M'
|
|
||||||
);
|
|
||||||
|
|
||||||
$timestamp = mktime(
|
|
||||||
$guessedDate['tm_hour'],
|
|
||||||
$guessedDate['tm_min'],
|
|
||||||
0,
|
|
||||||
date('m'),
|
|
||||||
date('d'),
|
|
||||||
date('Y')
|
|
||||||
);
|
|
||||||
} elseif(explode(' ', $guessedDate)[0] == 'Y-day') {
|
|
||||||
$guessedDate = strptime(
|
|
||||||
explode(' ', $guessedDate)[1], '%H:%M'
|
|
||||||
);
|
|
||||||
|
|
||||||
$timestamp = mktime(
|
|
||||||
$guessedDate['tm_hour'],
|
|
||||||
$guessedDate['tm_min'],
|
|
||||||
0,
|
|
||||||
date('m', time() - 24 * 60 * 60),
|
|
||||||
date('d', time() - 24 * 60 * 60),
|
|
||||||
date('Y', time() - 24 * 60 * 60)
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$guessedDate = strptime($guessedDate, '%m-%d %H:%M');
|
|
||||||
$timestamp = mktime(
|
|
||||||
$guessedDate['tm_hour'],
|
|
||||||
$guessedDate['tm_min'],
|
|
||||||
0,
|
|
||||||
$guessedDate['tm_mon'] + 1,
|
|
||||||
$guessedDate['tm_mday'],
|
|
||||||
date('Y'));
|
|
||||||
}
|
|
||||||
return $timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
$catBool = $this->getInput('catCheck');
|
$catBool = $this->getInput('catCheck');
|
||||||
if($catBool) {
|
if($catBool) {
|
||||||
$catNum = $this->getInput('cat');
|
$catNum = $this->getInput('cat');
|
||||||
|
@ -151,7 +97,7 @@ class ThePirateBayBridge extends BridgeAbstract {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = self::URI . $element->find('a.detLink', 0)->href;
|
$item['uri'] = self::URI . $element->find('a.detLink', 0)->href;
|
||||||
$item['id'] = self::URI . $element->find('a.detLink', 0)->href;
|
$item['id'] = self::URI . $element->find('a.detLink', 0)->href;
|
||||||
$item['timestamp'] = parseDateTimestamp($element);
|
$item['timestamp'] = $this->parseDateTimestamp($element);
|
||||||
$item['author'] = $element->find('a.detDesc', 0)->plaintext;
|
$item['author'] = $element->find('a.detDesc', 0)->plaintext;
|
||||||
$item['title'] = $element->find('a.detLink', 0)->plaintext;
|
$item['title'] = $element->find('a.detLink', 0)->plaintext;
|
||||||
$item['magnet'] = $element->find('a', 3)->href;
|
$item['magnet'] = $element->find('a', 3)->href;
|
||||||
|
@ -174,4 +120,58 @@ class ThePirateBayBridge extends BridgeAbstract {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function parseDateTimestamp($element){
|
||||||
|
$guessedDate = $element->find('font', 0)->plaintext;
|
||||||
|
$guessedDate = explode('Uploaded ', $guessedDate)[1];
|
||||||
|
$guessedDate = explode(',', $guessedDate)[0];
|
||||||
|
|
||||||
|
if(count(explode(':', $guessedDate)) == 1) {
|
||||||
|
$guessedDate = strptime($guessedDate, '%m-%d %Y');
|
||||||
|
$timestamp = mktime(
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
$guessedDate['tm_mon'] + 1,
|
||||||
|
$guessedDate['tm_mday'],
|
||||||
|
1900 + $guessedDate['tm_year']
|
||||||
|
);
|
||||||
|
} elseif(explode(' ', $guessedDate)[0] == 'Today') {
|
||||||
|
$guessedDate = strptime(
|
||||||
|
explode(' ', $guessedDate)[1], '%H:%M'
|
||||||
|
);
|
||||||
|
|
||||||
|
$timestamp = mktime(
|
||||||
|
$guessedDate['tm_hour'],
|
||||||
|
$guessedDate['tm_min'],
|
||||||
|
0,
|
||||||
|
date('m'),
|
||||||
|
date('d'),
|
||||||
|
date('Y')
|
||||||
|
);
|
||||||
|
} elseif(explode(' ', $guessedDate)[0] == 'Y-day') {
|
||||||
|
$guessedDate = strptime(
|
||||||
|
explode(' ', $guessedDate)[1], '%H:%M'
|
||||||
|
);
|
||||||
|
|
||||||
|
$timestamp = mktime(
|
||||||
|
$guessedDate['tm_hour'],
|
||||||
|
$guessedDate['tm_min'],
|
||||||
|
0,
|
||||||
|
date('m', time() - 24 * 60 * 60),
|
||||||
|
date('d', time() - 24 * 60 * 60),
|
||||||
|
date('Y', time() - 24 * 60 * 60)
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
$guessedDate = strptime($guessedDate, '%m-%d %H:%M');
|
||||||
|
$timestamp = mktime(
|
||||||
|
$guessedDate['tm_hour'],
|
||||||
|
$guessedDate['tm_min'],
|
||||||
|
0,
|
||||||
|
$guessedDate['tm_mon'] + 1,
|
||||||
|
$guessedDate['tm_mday'],
|
||||||
|
date('Y'));
|
||||||
|
}
|
||||||
|
return $timestamp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue