mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-20 15:22:17 +02:00
refactor (#4244)
This commit is contained in:
@@ -68,12 +68,13 @@ class AO3Bridge extends BridgeAbstract
|
||||
*/
|
||||
private function collectList($url)
|
||||
{
|
||||
$httpClient = RssBridge::getHttpClient();
|
||||
$version = 'v0.0.1';
|
||||
$agent = ['useragent' => "rss-bridge $version (https://github.com/RSS-Bridge/rss-bridge)"];
|
||||
$headers = [
|
||||
"useragent: rss-bridge $version (https://github.com/RSS-Bridge/rss-bridge)"
|
||||
];
|
||||
$response = getContents($url, $headers);
|
||||
|
||||
$response = $httpClient->request($url, $agent);
|
||||
$html = \str_get_html($response->getBody());
|
||||
$html = \str_get_html($response);
|
||||
$html = defaultLinkTo($html, self::URI);
|
||||
|
||||
// Get list title. Will include page range + count in some cases
|
||||
@@ -128,14 +129,15 @@ class AO3Bridge extends BridgeAbstract
|
||||
case ('last'):
|
||||
// only way to get this is using the navigate page unfortunately
|
||||
$url .= '/navigate';
|
||||
$response = $httpClient->request($url, $agent);
|
||||
$html = \str_get_html($response->getBody());
|
||||
$response = getContents($url, $headers);
|
||||
$html = \str_get_html($response);
|
||||
$html = defaultLinkTo($html, self::URI);
|
||||
$url = $html->find('ol.index.group > li > a', -1)->href;
|
||||
break;
|
||||
}
|
||||
$response = $httpClient->request($url, $agent);
|
||||
$html = \str_get_html($response->getBody());
|
||||
$response = getContents($url, $headers);
|
||||
|
||||
$html = \str_get_html($response);
|
||||
$html = defaultLinkTo($html, self::URI);
|
||||
// remove duplicate fic summary
|
||||
if ($ficsum = $html->find('#workskin > .preface > .summary', 0)) {
|
||||
@@ -159,16 +161,18 @@ class AO3Bridge extends BridgeAbstract
|
||||
*/
|
||||
private function collectWork($url)
|
||||
{
|
||||
$httpClient = RssBridge::getHttpClient();
|
||||
$version = 'v0.0.1';
|
||||
$agent = ['useragent' => "rss-bridge $version (https://github.com/RSS-Bridge/rss-bridge)"];
|
||||
$headers = [
|
||||
"useragent: rss-bridge $version (https://github.com/RSS-Bridge/rss-bridge)"
|
||||
];
|
||||
$response = getContents($url . '/navigate', $headers);
|
||||
|
||||
$response = $httpClient->request($url . '/navigate', $agent);
|
||||
$html = \str_get_html($response->getBody());
|
||||
$html = \str_get_html($response);
|
||||
$html = defaultLinkTo($html, self::URI);
|
||||
|
||||
$response = $httpClient->request($url . '?view_full_work=true', $agent);
|
||||
$workhtml = \str_get_html($response->getBody());
|
||||
$response = getContents($url . '?view_full_work=true', $headers);
|
||||
|
||||
$workhtml = \str_get_html($response);
|
||||
$workhtml = defaultLinkTo($workhtml, self::URI);
|
||||
|
||||
$this->title = $html->find('h2 a', 0)->plaintext;
|
||||
|
@@ -54,7 +54,7 @@ class BMDSystemhausBlogBridge extends BridgeAbstract
|
||||
public function collectData()
|
||||
{
|
||||
// get website content
|
||||
$html = getSimpleHTMLDOM($this->getURI()) or returnServerError('No contents received!');
|
||||
$html = getSimpleHTMLDOM($this->getURI());
|
||||
|
||||
// Convert relative links in HTML into absolute links
|
||||
$html = defaultLinkTo($html, self::URI);
|
||||
@@ -207,7 +207,8 @@ class BMDSystemhausBlogBridge extends BridgeAbstract
|
||||
//-----------------------------------------------------
|
||||
public function getURI()
|
||||
{
|
||||
$lURI = $this->getURIbyCountry($this->getInput('country'));
|
||||
$country = $this->getInput('country') ?? '';
|
||||
$lURI = $this->getURIbyCountry($country);
|
||||
return $lURI != '' ? $lURI : parent::getURI();
|
||||
}
|
||||
|
||||
|
@@ -196,23 +196,21 @@ EOD;
|
||||
// e.g. 01:53:27
|
||||
private function formatTimestampTime($seconds)
|
||||
{
|
||||
return sprintf(
|
||||
'%02d:%02d:%02d',
|
||||
floor($seconds / 3600),
|
||||
($seconds / 60) % 60,
|
||||
$seconds % 60
|
||||
);
|
||||
$floor = floor($seconds / 3600);
|
||||
$i = intval($seconds / 60) % 60;
|
||||
$i1 = $seconds % 60;
|
||||
|
||||
return sprintf('%02d:%02d:%02d', $floor, $i, $i1);
|
||||
}
|
||||
|
||||
// e.g. 01h53m27s
|
||||
private function formatQueryTime($seconds)
|
||||
{
|
||||
return sprintf(
|
||||
'%02dh%02dm%02ds',
|
||||
floor($seconds / 3600),
|
||||
($seconds / 60) % 60,
|
||||
$seconds % 60
|
||||
);
|
||||
$floor = floor($seconds / 3600);
|
||||
$i = intval($seconds / 60) % 60;
|
||||
$i1 = $seconds % 60;
|
||||
|
||||
return sprintf('%02dh%02dm%02ds', $floor, $i, $i1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user