aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar July <phantop@tuta.io> 2023-09-09 03:19:09 -0400
committerGravatar GitHub <noreply@github.com> 2023-09-09 09:19:09 +0200
commit586d707ae48b74b150eb101f2e9986d0bd18d89f (patch)
tree9ccd13b65eeac42b2e7e6a317ff777287994ff5f
parentb3a784244808041a264c3bd548d2bdca9a143275 (diff)
downloadrss-bridge-586d707ae48b74b150eb101f2e9986d0bd18d89f.tar.gz
rss-bridge-586d707ae48b74b150eb101f2e9986d0bd18d89f.tar.zst
rss-bridge-586d707ae48b74b150eb101f2e9986d0bd18d89f.zip
[ArsTechnicaBridge] Add new bridge (#3657)
-rw-r--r--bridges/ArsTechnicaBridge.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/bridges/ArsTechnicaBridge.php b/bridges/ArsTechnicaBridge.php
new file mode 100644
index 00000000..1e3e6379
--- /dev/null
+++ b/bridges/ArsTechnicaBridge.php
@@ -0,0 +1,71 @@
+<?php
+
+class ArsTechnicaBridge extends FeedExpander
+{
+ const MAINTAINER = 'phantop';
+ const NAME = 'Ars Technica';
+ const URI = 'https://arstechnica.com/';
+ const DESCRIPTION = 'Returns the latest articles from Ars Technica';
+ const PARAMETERS = [[
+ 'section' => [
+ 'name' => 'Site section',
+ 'type' => 'list',
+ 'defaultValue' => 'index',
+ 'values' => [
+ 'All' => 'index',
+ 'Apple' => 'apple',
+ 'Board Games' => 'cardboard',
+ 'Cars' => 'cars',
+ 'Features' => 'features',
+ 'Gaming' => 'gaming',
+ 'Information Technology' => 'technology-lab',
+ 'Science' => 'science',
+ 'Staff Blogs' => 'staff-blogs',
+ 'Tech Policy' => 'tech-policy',
+ 'Tech' => 'gadgets',
+ ]
+ ]
+ ]];
+
+ public function collectData()
+ {
+ $url = 'https://feeds.arstechnica.com/arstechnica/' . $this->getInput('section');
+ $this->collectExpandableDatas($url);
+ }
+
+ protected function parseItem($newItem)
+ {
+ $item = parent::parseItem($newItem);
+
+ $item_html = getSimpleHTMLDOMCached($item['uri'] . '&amp');
+ $item_html = defaultLinkTo($item_html, self::URI);
+ $item['content'] = $item_html->find('.amp-wp-article-content', 0);
+
+ // remove various ars advertising
+ $item['content']->find('#social-left', 0)->remove();
+ foreach ($item['content']->find('.ars-component-buy-box') as $ad) {
+ $ad->remove();
+ }
+ foreach ($item['content']->find('i-amphtml-sizer') as $ad) {
+ $ad->remove();
+ }
+ foreach ($item['content']->find('.sidebar') as $ad) {
+ $ad->remove();
+ }
+
+ foreach ($item['content']->find('a') as $link) { //remove amp redirect links
+ $url = $link->getAttribute('href');
+ if (str_contains($url, 'go.redirectingat.com')) {
+ $url = extractFromDelimiters($url, 'url=', '&amp');
+ $url = urldecode($url);
+ $link->setAttribute('href', $url);
+ }
+ }
+
+ $item['content'] = backgroundToImg(str_replace('data-amp-original-style="background-image', 'style="background-image', $item['content']));
+
+ $item['uid'] = explode('=', $item['uri'])[1];
+
+ return $item;
+ }
+}