Skip to content

Commit

Permalink
use updated ao3 (limit scraping) and priviblur (favicon) bridges
Browse files Browse the repository at this point in the history
  • Loading branch information
Phantop committed Nov 15, 2024
1 parent efb4220 commit c12a148
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 3 deletions.
30 changes: 30 additions & 0 deletions patches/ao3.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
diff --git a/bridges/AO3Bridge.php b/bridges/AO3Bridge.php
index 970ed414c50..7e18b657f58 100644
--- a/bridges/AO3Bridge.php
+++ b/bridges/AO3Bridge.php
@@ -27,6 +27,7 @@ class AO3Bridge extends BridgeAbstract
'Entire work' => 'all',
],
],
+ 'limit' => self::LIMIT,
],
'Bookmarks' => [
'user' => [
@@ -84,6 +85,8 @@ private function collectList($url)
}
$this->title = $heading->plaintext;

+ $limit = $this->getInput('limit') ?? 3;
+ $count = 0;
foreach ($html->find('.index.group > li') as $element) {
$item = [];

@@ -118,7 +121,7 @@ private function collectList($url)
$item['uid'] = $item['uri'] . "/$strdate/$chapters";

// Fetch workskin of desired chapter(s) in list
- if ($this->getInput('range')) {
+ if ($this->getInput('range') && ($limit == 0 || $count++ < $limit)) {
$url = $item['uri'];
switch ($this->getInput('range')) {
case ('all'):
37 changes: 37 additions & 0 deletions patches/priviblur.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
diff --git a/bridges/PriviblurBridge.php b/bridges/PriviblurBridge.php
index 198c38bc6c3..6b442e75034 100644
--- a/bridges/PriviblurBridge.php
+++ b/bridges/PriviblurBridge.php
@@ -17,6 +17,7 @@ class PriviblurBridge extends BridgeAbstract
];

private $title;
+ private $favicon = 'https://www.tumblr.com/favicon.ico';

public function collectData()
{
@@ -25,6 +26,11 @@ public function collectData()
$html = defaultLinkTo($html, $url);
$this->title = $html->find('head title', 0)->innertext;

+ if ($html->find('#blog-header img.avatar', 0)) {
+ $icon = $html->find('#blog-header img.avatar', 0)->src;
+ $this->favicon = str_replace('pnj', 'png', $icon);
+ }
+
$elements = $html->find('.post');
foreach ($elements as $element) {
$item = [];
@@ -64,6 +70,11 @@ public function getName()

public function getURI()
{
- return $this->getInput('url') ? $this->getInput('url') : parent::getURI();
+ return $this->getInput('url') ?? parent::getURI();
+ }
+
+ public function getIcon()
+ {
+ return $this->favicon;
}
}
5 changes: 3 additions & 2 deletions patches/rewrite.diff
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ index c65f8e00..6e9013e2 100644
+ }
}
diff --git a/lib/RssBridge.php b/lib/RssBridge.php
index c7b132d6..563ede7c 100644
index c7b132d6..99ea4e3e 100644
--- a/lib/RssBridge.php
+++ b/lib/RssBridge.php
@@ -10,8 +10,56 @@ final class RssBridge
@@ -10,8 +10,57 @@ final class RssBridge
$this->container = $container;
}

Expand All @@ -28,6 +28,7 @@ index c7b132d6..563ede7c 100644
+ if (str_starts_with($path, '/ao3')) {
+ $args = [
+ 'context' => 'List',
+ 'range' => 'all',
+ 'url' => 'https://archiveofourown.org' . substr($path, 4),
+ ];
+ $request = Request::fromCli($args);
Expand Down
2 changes: 1 addition & 1 deletion rss-bridge

0 comments on commit c12a148

Please sign in to comment.