mirror of
https://github.com/starr-dusT/dotfiles.git
synced 2025-02-19 19:27:31 -08:00
Load additional rss-bridge bridges from /var/lib/rss-bridge/bridges
This commit is contained in:
parent
e5e59e21dc
commit
ddcf1e5bd7
@ -95,6 +95,7 @@ in
|
|||||||
};
|
};
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d '${cfg.dataDir}/cache' 0750 ${cfg.user} ${cfg.group} - -"
|
"d '${cfg.dataDir}/cache' 0750 ${cfg.user} ${cfg.group} - -"
|
||||||
|
"d '${cfg.dataDir}/bridges' 0750 ${cfg.user} ${cfg.group} - -"
|
||||||
(mkIf (cfg.whitelist != []) "L+ ${cfg.dataDir}/whitelist.txt - - - - ${whitelist}")
|
(mkIf (cfg.whitelist != []) "L+ ${cfg.dataDir}/whitelist.txt - - - - ${whitelist}")
|
||||||
"z '${cfg.dataDir}/config.ini.php' 0750 ${cfg.user} ${cfg.group} - -"
|
"z '${cfg.dataDir}/config.ini.php' 0750 ${cfg.user} ${cfg.group} - -"
|
||||||
];
|
];
|
||||||
|
@ -5,7 +5,7 @@ stdenv.mkDerivation rec {
|
|||||||
version = "b037d1b4d1f0b0f422e21125ddef00a58e185ed1";
|
version = "b037d1b4d1f0b0f422e21125ddef00a58e185ed1";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "starr-dusT";
|
owner = "RSS-Bridge";
|
||||||
repo = "rss-bridge";
|
repo = "rss-bridge";
|
||||||
rev = version;
|
rev = version;
|
||||||
sha256 = "sha256-zyWnjSYE2NFK/OJLnsFsE5oEyf+yrJe8TT6MH4roBwU=";
|
sha256 = "sha256-zyWnjSYE2NFK/OJLnsFsE5oEyf+yrJe8TT6MH4roBwU=";
|
||||||
@ -13,7 +13,6 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
patches = [
|
patches = [
|
||||||
./paths.patch
|
./paths.patch
|
||||||
./youtube_time_hack.patch
|
|
||||||
];
|
];
|
||||||
|
|
||||||
installPhase = ''
|
installPhase = ''
|
||||||
@ -23,7 +22,7 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
description = "The RSS feed for websites missing it";
|
description = "The RSS feed for websites missing it";
|
||||||
homepage = "https://github.com/starr-dusT/rss-bridge";
|
homepage = "https://github.com/RSS-Bridge/rss-bridge";
|
||||||
license = licenses.unlicense;
|
license = licenses.unlicense;
|
||||||
maintainers = with maintainers; [ starr-dusT ];
|
maintainers = with maintainers; [ starr-dusT ];
|
||||||
platforms = platforms.all;
|
platforms = platforms.all;
|
||||||
|
60
provision/pkgs/rss-bridge/paths.patch
Normal file → Executable file
60
provision/pkgs/rss-bridge/paths.patch
Normal file → Executable file
@ -3,7 +3,7 @@ index 123f6ecd..69071aa2 100644
|
|||||||
--- a/index.php
|
--- a/index.php
|
||||||
+++ b/index.php
|
+++ b/index.php
|
||||||
@@ -8,8 +8,8 @@ require_once __DIR__ . '/lib/bootstrap.php';
|
@@ -8,8 +8,8 @@ require_once __DIR__ . '/lib/bootstrap.php';
|
||||||
|
|
||||||
Configuration::verifyInstallation();
|
Configuration::verifyInstallation();
|
||||||
$customConfig = [];
|
$customConfig = [];
|
||||||
-if (file_exists(__DIR__ . '/config.ini.php')) {
|
-if (file_exists(__DIR__ . '/config.ini.php')) {
|
||||||
@ -12,16 +12,39 @@ index 123f6ecd..69071aa2 100644
|
|||||||
+ $customConfig = parse_ini_file(getenv('RSSBRIDGE_DATA') . '/config.ini.php', true, INI_SCANNER_TYPED);
|
+ $customConfig = parse_ini_file(getenv('RSSBRIDGE_DATA') . '/config.ini.php', true, INI_SCANNER_TYPED);
|
||||||
}
|
}
|
||||||
Configuration::loadConfiguration($customConfig, getenv());
|
Configuration::loadConfiguration($customConfig, getenv());
|
||||||
|
|
||||||
diff --git a/lib/Configuration.php b/lib/Configuration.php
|
diff --git a/lib/BridgeFactory.php b/lib/BridgeFactory.php
|
||||||
index d699178f..5431f345 100644
|
index ad433287..195c7af1 100644
|
||||||
--- a/lib/Configuration.php
|
--- a/lib/BridgeFactory.php
|
||||||
+++ b/lib/Configuration.php
|
+++ b/lib/BridgeFactory.php
|
||||||
@@ -91,9 +91,8 @@ final class Configuration
|
@@ -13,12 +13,18 @@ final class BridgeFactory
|
||||||
self::setConfig('system', 'debug_mode_whitelist', explode("\n", str_replace("\r", '', $debug)));
|
$this->cache = RssBridge::getCache();
|
||||||
|
$this->logger = RssBridge::getLogger();
|
||||||
|
|
||||||
|
- // Create all possible bridge class names from fs
|
||||||
|
+ // Create all possible bridge class names from original fs
|
||||||
|
foreach (scandir(__DIR__ . '/../bridges/') as $file) {
|
||||||
|
if (preg_match('/^([^.]+Bridge)\.php$/U', $file, $m)) {
|
||||||
|
$this->bridgeClassNames[] = $m[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
-
|
+ // Create all possible bridge class names from additional fs
|
||||||
|
+ foreach (scandir(PATH_BRIDGES) as $file) {
|
||||||
|
+ if (preg_match('/^([^.]+Bridge)\.php$/U', $file, $m)) {
|
||||||
|
+ $this->bridgeClassNames[] = $m[1];
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
|
||||||
|
$enabledBridges = Configuration::getConfig('system', 'enabled_bridges');
|
||||||
|
if ($enabledBridges === null) {
|
||||||
|
diff --git a/lib/Configuration.php b/lib/Configuration.php
|
||||||
|
index c6fed0fd..672a5699 100644
|
||||||
|
--- a/lib/Configuration.php
|
||||||
|
+++ b/lib/Configuration.php
|
||||||
|
@@ -92,8 +92,8 @@ final class Configuration
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- if (file_exists(__DIR__ . '/../whitelist.txt')) {
|
- if (file_exists(__DIR__ . '/../whitelist.txt')) {
|
||||||
- $enabledBridges = trim(file_get_contents(__DIR__ . '/../whitelist.txt'));
|
- $enabledBridges = trim(file_get_contents(__DIR__ . '/../whitelist.txt'));
|
||||||
+ if (file_exists(getenv('RSSBRIDGE_DATA') . '/whitelist.txt')) {
|
+ if (file_exists(getenv('RSSBRIDGE_DATA') . '/whitelist.txt')) {
|
||||||
@ -30,15 +53,26 @@ index d699178f..5431f345 100644
|
|||||||
self::setConfig('system', 'enabled_bridges', ['*']);
|
self::setConfig('system', 'enabled_bridges', ['*']);
|
||||||
} else {
|
} else {
|
||||||
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
|
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
|
||||||
index a95de9dd..78153a65 100644
|
index a95de9dd..e8ed317f 100644
|
||||||
--- a/lib/bootstrap.php
|
--- a/lib/bootstrap.php
|
||||||
+++ b/lib/bootstrap.php
|
+++ b/lib/bootstrap.php
|
||||||
@@ -7,7 +7,7 @@ const PATH_LIB_FORMATS = __DIR__ . '/../formats/';
|
@@ -7,7 +7,10 @@ const PATH_LIB_FORMATS = __DIR__ . '/../formats/';
|
||||||
const PATH_LIB_CACHES = __DIR__ . '/../caches/';
|
const PATH_LIB_CACHES = __DIR__ . '/../caches/';
|
||||||
|
|
||||||
/** Path to the cache folder */
|
/** Path to the cache folder */
|
||||||
-const PATH_CACHE = __DIR__ . '/../cache/';
|
-const PATH_CACHE = __DIR__ . '/../cache/';
|
||||||
+define('PATH_CACHE', getenv('RSSBRIDGE_DATA') . '/cache/');
|
+define('PATH_CACHE', getenv('RSSBRIDGE_DATA') . '/cache/');
|
||||||
|
+
|
||||||
|
+/** Path to extra bridge files */
|
||||||
|
+define('PATH_BRIDGES', getenv('RSSBRIDGE_DATA') . '/bridges/');
|
||||||
|
|
||||||
/** URL to the RSS-Bridge repository */
|
/** URL to the RSS-Bridge repository */
|
||||||
const REPOSITORY = 'https://github.com/RSS-Bridge/rss-bridge/';
|
const REPOSITORY = 'https://github.com/RSS-Bridge/rss-bridge/';
|
||||||
|
@@ -41,6 +44,7 @@ spl_autoload_register(function ($className) {
|
||||||
|
__DIR__ . '/../caches/',
|
||||||
|
__DIR__ . '/../formats/',
|
||||||
|
__DIR__ . '/../lib/',
|
||||||
|
+ PATH_BRIDGES,
|
||||||
|
];
|
||||||
|
foreach ($folders as $folder) {
|
||||||
|
$file = $folder . $className . '.php';
|
||||||
|
@ -1,74 +0,0 @@
|
|||||||
diff --git a/bridges/YoutubeBridge.php b/bridges/YoutubeBridge.php
|
|
||||||
index 993f8c90..b000a9ff 100644
|
|
||||||
--- a/bridges/YoutubeBridge.php
|
|
||||||
+++ b/bridges/YoutubeBridge.php
|
|
||||||
@@ -134,26 +134,20 @@ class YoutubeBridge extends BridgeAbstract
|
|
||||||
$url_feed = $jsonData->metadata->channelMetadataRenderer->rssUrl;
|
|
||||||
$this->feedIconUrl = $jsonData->metadata->channelMetadataRenderer->avatar->thumbnails[0]->url;
|
|
||||||
}
|
|
||||||
- if ($filterByDuration) {
|
|
||||||
- if (!$custom) {
|
|
||||||
- // Fetch the html page
|
|
||||||
- $html = $this->fetch($url_listing);
|
|
||||||
- $jsonData = $this->extractJsonFromHtml($html);
|
|
||||||
- }
|
|
||||||
- $channel_id = '';
|
|
||||||
- if (isset($jsonData->contents)) {
|
|
||||||
- $channel_id = $jsonData->metadata->channelMetadataRenderer->externalId;
|
|
||||||
- $jsonData = $jsonData->contents->twoColumnBrowseResultsRenderer->tabs[1];
|
|
||||||
- $jsonData = $jsonData->tabRenderer->content->richGridRenderer->contents;
|
|
||||||
- // $jsonData = $jsonData->itemSectionRenderer->contents[0]->gridRenderer->items;
|
|
||||||
- $this->fetchItemsFromFromJsonData($jsonData);
|
|
||||||
- } else {
|
|
||||||
- returnServerError('Unable to get data from YouTube');
|
|
||||||
- }
|
|
||||||
+ if (!$custom) {
|
|
||||||
+ // Fetch the html page
|
|
||||||
+ $html = $this->fetch($url_listing);
|
|
||||||
+ $jsonData = $this->extractJsonFromHtml($html);
|
|
||||||
+ }
|
|
||||||
+ $channel_id = '';
|
|
||||||
+ if (isset($jsonData->contents)) {
|
|
||||||
+ $channel_id = $jsonData->metadata->channelMetadataRenderer->externalId;
|
|
||||||
+ $jsonData = $jsonData->contents->twoColumnBrowseResultsRenderer->tabs[1];
|
|
||||||
+ $jsonData = $jsonData->tabRenderer->content->richGridRenderer->contents;
|
|
||||||
+ // $jsonData = $jsonData->itemSectionRenderer->contents[0]->gridRenderer->items;
|
|
||||||
+ $this->fetchItemsFromFromJsonData($jsonData);
|
|
||||||
} else {
|
|
||||||
- // Fetch the xml feed
|
|
||||||
- $html = $this->fetch($url_feed);
|
|
||||||
- $this->extractItemsFromXmlFeed($html);
|
|
||||||
+ returnServerError('Unable to get data from YouTube');
|
|
||||||
}
|
|
||||||
$this->feedName = str_replace(' - YouTube', '', $html->find('title', 0)->plaintext);
|
|
||||||
} elseif ($playlist) {
|
|
||||||
@@ -496,24 +490,23 @@ class YoutubeBridge extends BridgeAbstract
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
- if (!$description || !$timestamp) {
|
|
||||||
- $this->fetchVideoDetails($videoId, $author, $description, $timestamp);
|
|
||||||
- }
|
|
||||||
- $this->addItem($videoId, $title, $author, $description, $timestamp);
|
|
||||||
+ # Re-fetch better details from xml
|
|
||||||
+ $this->fetchVideoDetails($videoId, $author, $description, $timestamp);
|
|
||||||
+ $this->addItem($videoId, $title, $author, $description, $timestamp, $durationText);
|
|
||||||
if (count($this->items) >= 99) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
- private function addItem($videoId, $title, $author, $description, $timestamp, $thumbnail = '')
|
|
||||||
+ private function addItem($videoId, $title, $author, $description, $timestamp, $durationText, $thumbnail = '')
|
|
||||||
{
|
|
||||||
$description = nl2br($description);
|
|
||||||
|
|
||||||
$item = [];
|
|
||||||
// This should probably be uid?
|
|
||||||
$item['id'] = $videoId;
|
|
||||||
- $item['title'] = $title;
|
|
||||||
+ $item['title'] = $title . " [" . $durationText . "]";
|
|
||||||
$item['author'] = $author ?? '';
|
|
||||||
$item['timestamp'] = $timestamp;
|
|
||||||
$item['uri'] = self::URI . '/watch?v=' . $videoId;
|
|
Loading…
x
Reference in New Issue
Block a user