mirror of
https://github.com/starr-dusT/dotfiles.git
synced 2025-02-19 19:27:31 -08:00
package rss-bridge with patches to hack Youtube feeds
This commit is contained in:
parent
516abb7a33
commit
aa368ea88b
@ -5,4 +5,5 @@ final: prev: {
|
||||
sway-scratchpad = final.callPackage ../pkgs/sway-scratchpad.nix {};
|
||||
advcpmv = final.callPackage ../pkgs/advcpmv.nix {};
|
||||
taskopen = final.callPackage ../pkgs/taskopen.nix {};
|
||||
rss-bridge = final.callPackage ../pkgs/rss-bridge {};
|
||||
}
|
||||
|
31
provision/pkgs/rss-bridge/default.nix
Normal file
31
provision/pkgs/rss-bridge/default.nix
Normal file
@ -0,0 +1,31 @@
|
||||
{ stdenv, lib, fetchFromGitHub }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "rss-bridge";
|
||||
version = "b037d1b4d1f0b0f422e21125ddef00a58e185ed1";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "starr-dusT";
|
||||
repo = "rss-bridge";
|
||||
rev = version;
|
||||
sha256 = "sha256-zyWnjSYE2NFK/OJLnsFsE5oEyf+yrJe8TT6MH4roBwU=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./paths.patch
|
||||
./youtube_time_hack.patch
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
mkdir $out/
|
||||
cp -R ./* $out
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "The RSS feed for websites missing it";
|
||||
homepage = "https://github.com/starr-dusT/rss-bridge";
|
||||
license = licenses.unlicense;
|
||||
maintainers = with maintainers; [ starr-dusT ];
|
||||
platforms = platforms.all;
|
||||
};
|
||||
}
|
44
provision/pkgs/rss-bridge/paths.patch
Normal file
44
provision/pkgs/rss-bridge/paths.patch
Normal file
@ -0,0 +1,44 @@
|
||||
diff --git a/index.php b/index.php
|
||||
index 123f6ecd..69071aa2 100644
|
||||
--- a/index.php
|
||||
+++ b/index.php
|
||||
@@ -8,8 +8,8 @@ require_once __DIR__ . '/lib/bootstrap.php';
|
||||
|
||||
Configuration::verifyInstallation();
|
||||
$customConfig = [];
|
||||
-if (file_exists(__DIR__ . '/config.ini.php')) {
|
||||
- $customConfig = parse_ini_file(__DIR__ . '/config.ini.php', true, INI_SCANNER_TYPED);
|
||||
+if (file_exists(getenv('RSSBRIDGE_DATA') . '/config.ini.php')) {
|
||||
+ $customConfig = parse_ini_file(getenv('RSSBRIDGE_DATA') . '/config.ini.php', true, INI_SCANNER_TYPED);
|
||||
}
|
||||
Configuration::loadConfiguration($customConfig, getenv());
|
||||
|
||||
diff --git a/lib/Configuration.php b/lib/Configuration.php
|
||||
index d699178f..5431f345 100644
|
||||
--- a/lib/Configuration.php
|
||||
+++ b/lib/Configuration.php
|
||||
@@ -91,9 +91,8 @@ final class Configuration
|
||||
self::setConfig('system', 'debug_mode_whitelist', explode("\n", str_replace("\r", '', $debug)));
|
||||
}
|
||||
}
|
||||
-
|
||||
- if (file_exists(__DIR__ . '/../whitelist.txt')) {
|
||||
- $enabledBridges = trim(file_get_contents(__DIR__ . '/../whitelist.txt'));
|
||||
+ if (file_exists(getenv('RSSBRIDGE_DATA') . '/whitelist.txt')) {
|
||||
+ $enabledBridges = trim(file_get_contents(getenv('RSSBRIDGE_DATA') . '/whitelist.txt'));
|
||||
if ($enabledBridges === '*') {
|
||||
self::setConfig('system', 'enabled_bridges', ['*']);
|
||||
} else {
|
||||
diff --git a/lib/bootstrap.php b/lib/bootstrap.php
|
||||
index a95de9dd..78153a65 100644
|
||||
--- a/lib/bootstrap.php
|
||||
+++ b/lib/bootstrap.php
|
||||
@@ -7,7 +7,7 @@ const PATH_LIB_FORMATS = __DIR__ . '/../formats/';
|
||||
const PATH_LIB_CACHES = __DIR__ . '/../caches/';
|
||||
|
||||
/** Path to the cache folder */
|
||||
-const PATH_CACHE = __DIR__ . '/../cache/';
|
||||
+define('PATH_CACHE', getenv('RSSBRIDGE_DATA') . '/cache/');
|
||||
|
||||
/** URL to the RSS-Bridge repository */
|
||||
const REPOSITORY = 'https://github.com/RSS-Bridge/rss-bridge/';
|
74
provision/pkgs/rss-bridge/youtube_time_hack.patch
Normal file
74
provision/pkgs/rss-bridge/youtube_time_hack.patch
Normal file
@ -0,0 +1,74 @@
|
||||
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