2020-02-26 23:50:25 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
class TinyLetterBridge extends BridgeAbstract
|
|
|
|
{
|
|
|
|
const NAME = 'Tiny Letter';
|
|
|
|
const URI = 'https://tinyletter.com/';
|
|
|
|
const DESCRIPTION = 'Tiny Letter is a mailing list service';
|
|
|
|
const MAINTAINER = 'somini';
|
|
|
|
const PARAMETERS = [
|
2022-07-01 16:10:30 +03:00
|
|
|
[
|
2020-02-26 23:50:25 +03:00
|
|
|
'username' => [
|
|
|
|
'name' => 'User Name',
|
2022-03-24 13:59:34 +03:00
|
|
|
'required' => true,
|
2020-02-26 23:50:25 +03:00
|
|
|
'exampleValue' => 'forwards',
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
|
|
|
]
|
2020-02-26 23:50:25 +03:00
|
|
|
];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
$username = $this->getInput('username');
|
|
|
|
if (!is_null($username)) {
|
|
|
|
return static::NAME . ' | ' . $username;
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
return parent::getName();
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
$username = $this->getInput('username');
|
|
|
|
if (!is_null($username)) {
|
|
|
|
return static::URI . urlencode($username);
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
return parent::getURI();
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-07-09 09:13:07 +03:00
|
|
|
$archives = $this->getURI() . '/archive';
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOMCached($archives);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
foreach ($html->find('.message-list li') as $element) {
|
|
|
|
$item = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
$snippet = $element->find('p.message-snippet', 0);
|
|
|
|
$link = $element->find('.message-link', 0);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
$item['title'] = $link->plaintext;
|
|
|
|
$item['content'] = $snippet->innertext;
|
|
|
|
$item['uri'] = $link->href;
|
|
|
|
$item['timestamp'] = strtotime($element->find('.message-date', 0)->plaintext);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2020-02-26 23:50:25 +03:00
|
|
|
$this->items[] = $item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|