mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-29 14:48:52 +03:00
fix(imgsed): parsing of datetime string (#3738)
* refactor * fix(imgsed): parsing of date date_interval_create_from_date_string(): Unknown or bad format (an hour) at position 0 (a)
This commit is contained in:
parent
7e183915a9
commit
d21f8cebf6
1 changed files with 13 additions and 13 deletions
|
@ -43,15 +43,6 @@ class ImgsedBridge extends BridgeAbstract
|
||||||
'https://www.imgsed.com/instagram/' => ['context' => 'Username', 'u' => 'instagram', 'post' => 'on', 'story' => 'on', 'tagged' => 'on'],
|
'https://www.imgsed.com/instagram/' => ['context' => 'Username', 'u' => 'instagram', 'post' => 'on', 'story' => 'on', 'tagged' => 'on'],
|
||||||
];
|
];
|
||||||
|
|
||||||
public function getURI()
|
|
||||||
{
|
|
||||||
if (!is_null($this->getInput('u'))) {
|
|
||||||
return urljoin(self::URI, '/' . $this->getInput('u') . '/');
|
|
||||||
}
|
|
||||||
|
|
||||||
return parent::getURI();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData()
|
public function collectData()
|
||||||
{
|
{
|
||||||
$username = $this->getInput('u');
|
$username = $this->getInput('u');
|
||||||
|
@ -100,9 +91,6 @@ class ImgsedBridge extends BridgeAbstract
|
||||||
$isMoreContent = (bool) $post->find('svg', 0);
|
$isMoreContent = (bool) $post->find('svg', 0);
|
||||||
$moreContentNote = $isMoreContent ? '<p><i>(multiple images and/or videos)</i></p>' : '';
|
$moreContentNote = $isMoreContent ? '<p><i>(multiple images and/or videos)</i></p>' : '';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$this->items[] = [
|
$this->items[] = [
|
||||||
'uri' => $url,
|
'uri' => $url,
|
||||||
'author' => $author,
|
'author' => $author,
|
||||||
|
@ -214,15 +202,18 @@ HTML,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse date, and transform the date into a timetamp, even in a case of a relative date
|
|
||||||
private function parseDate($content)
|
private function parseDate($content)
|
||||||
{
|
{
|
||||||
|
// Parse date, and transform the date into a timetamp, even in a case of a relative date
|
||||||
$date = date_create();
|
$date = date_create();
|
||||||
$dateString = str_replace(' ago', '', $content);
|
$dateString = str_replace(' ago', '', $content);
|
||||||
// Special case : 'a day' is not a valid interval in PHP, so replace it with it's PHP equivalenbt : '1 day'
|
// Special case : 'a day' is not a valid interval in PHP, so replace it with it's PHP equivalenbt : '1 day'
|
||||||
if ($dateString == 'a day') {
|
if ($dateString == 'a day') {
|
||||||
$dateString = '1 day';
|
$dateString = '1 day';
|
||||||
}
|
}
|
||||||
|
if ($dateString === 'an hour') {
|
||||||
|
$dateString = '1 hour';
|
||||||
|
}
|
||||||
|
|
||||||
$relativeDate = date_interval_create_from_date_string($dateString);
|
$relativeDate = date_interval_create_from_date_string($dateString);
|
||||||
if ($relativeDate) {
|
if ($relativeDate) {
|
||||||
|
@ -235,6 +226,15 @@ HTML,
|
||||||
return date_format($date, 'r');
|
return date_format($date, 'r');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getURI()
|
||||||
|
{
|
||||||
|
if (!is_null($this->getInput('u'))) {
|
||||||
|
return urljoin(self::URI, '/' . $this->getInput('u') . '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
private function convertURLToInstagram($url)
|
private function convertURLToInstagram($url)
|
||||||
{
|
{
|
||||||
return str_replace(self::URI, self::INSTAGRAMURI, $url);
|
return str_replace(self::URI, self::INSTAGRAMURI, $url);
|
||||||
|
|
Loading…
Reference in a new issue