aledeg / xextension-redditimage Goto Github PK
View Code? Open in Web Editor NEWA FreshRSS extension to process Reddit feeds
License: GNU Affero General Public License v3.0
A FreshRSS extension to process Reddit feeds
License: GNU Affero General Public License v3.0
See the screenshot below.
Did a little digging and fixed it by adding meta tag to specify encoding where the new document is created in extractReal() from Content.php.
private function extractReal(): void
{
$dom = new \DomDocument('1.0', 'UTF-8');
$content = htmlspecialchars_decode(htmlentities(html_entity_decode(
$this->raw)));
$dom->loadHTML(
"<meta http-equiv='Content-Type' content='charset=utf-8' /><div
>$content</div>",
LIBXML_NOERROR
);
...
Not sure how good of a solution this is. So if you wanna look into it I'd be grateful.
PHP Deprecated:
mb_convert_encoding(): Handling HTML entities via mbstring is deprecated;
use htmlspecialchars, htmlentities, or mb_encode_numericentity/mb_decode_numericentity instead
in Content.php
on line 20
PHP Deprecated:
Using ${var} in strings is deprecated,
use {$var} instead
in Transformer/DisplayTransformer.php
on line 96
I'm seeing the following error in the logs on a new installation. I think the extension is working for most other posts. Thanks!
RedditImage\Exception\InvalidContentException: submitted by <a href="https://www.reddit.com/user/Improv92"> /u/Improv92 </a> to <a href="https://www.reddit.com/r/AskReddit/"> r/AskReddit </a> <br> <span><a href="https://www.reddit.com/r/AskReddit/comments/18m8m16/what_do_poor_countries_do_better_than_rich/">[link]</a></span> <span><a href="https://www.reddit.com/r/AskReddit/comments/18m8m16/what_do_poor_countries_do_better_than_rich/">[comments]</a></span> in /var/www/FreshRSS/extensions/xExtension-RedditImage-1.1.1/Content.php:28
At the moment I'm testing your latest changes to the main branch and get the following error message:
Mär 03 11:28:04 m625q php[2918]: PHP Fatal error: Uncaught TypeError: DOMElement::setAttribute(): Argument #2 ($value) must be of type string, bool given in /usr/share/webapps/freshrss/extensions/_xExtensions_git/xExtension-RedditImage/Media/Video.php:42
Sometimes, some feed entries doen't display properly and are skipped by the plugin.
Example : https://www.reddit.com/user/neo3dofficial/submitted/.rss?sort=new
At some point this error happens (NO METADATA
is a log I added in the isValid
method) :
[Wed, 13 Sep 2023 18:55:16 +0200] [error] --- NO METADATA
[Wed, 13 Sep 2023 18:55:16 +0200] [error] --- RedditImage\Exception\InvalidContentException: submitted by <a href="https://www.reddit.com/user/neo3dofficial"> /u/neo3dofficial </a> to <a href="https://www.reddit.com/r/DigitalArt/"> r/DigitalArt </a> <br> <span><a href="https://i.redd.it/d88vk9o3ehgb1.jpg">[link]</a></span> <span><a href="https://www.reddit.com/r/DigitalArt/comments/15jo38m/chroma_abstract_wallpaper_pack/">[comments]</a></span> in /app/www/extensions/xExtension-RedditImage/Content.php:29
Stack trace:
#0 /app/www/extensions/xExtension-RedditImage/Processor/BeforeInsertProcessor.php(51): RedditImage\Content->__construct()
#1 /app/www/lib/Minz/ExtensionManager.php(338): RedditImage\Processor\BeforeInsertProcessor->process()
#2 /app/www/lib/Minz/ExtensionManager.php(309): Minz_ExtensionManager::callOneToOne()
#3 /app/www/app/Controllers/feedController.php(483): Minz_ExtensionManager::callHook()
#4 /app/www/app/Controllers/feedController.php(653): FreshRSS_feed_Controller::actualizeFeed()
#5 /app/www/lib/Minz/Dispatcher.php(119): FreshRSS_feed_Controller->actualizeAction()
#6 /app/www/lib/Minz/Dispatcher.php(46): Minz_Dispatcher->launchAction()
#7 /app/www/lib/Minz/FrontController.php(58): Minz_Dispatcher->run()
#8 /app/www/p/i/index.php(57): Minz_FrontController->run()
#9 {main}
If I make the metadata regex a bit more tolerent with #(?P<metadata>\s+submitted.*</span>)#
, the error is gone.
This allows the entry to actually be processed by the transformers and the image inlined. Before, as the error happened, the entry was skipped from going through the processors.
However this doesn't seem to handle all cases.
Example (NSFW) : https://www.reddit.com/user/throwmeaway896/submitted/.rss?sort=new
With this feed, even if I have the regex modified, some entries failed to match (though image was already added by the BeforeInsertProcessor) :
[Wed, 13 Sep 2023 19:01:09 +0200] [error] --- NO METADATA
[Wed, 13 Sep 2023 19:01:09 +0200] [error] --- RedditImage\Exception\InvalidContentException: <div class="reddit-image figure"><!--xExtension-RedditImage/1.1.1 | RedditImage\Processor\BeforeInsertProcessor | RedditImage\Transformer\Agnostic\ImageTransformer--><img src="https://i.redd.it/rtuzzy7h9nnb1.jpg" class="reddit-image"></div>
submitted by <a href="https://www.reddit.com/user/throwmeaway896"> /u/throwmeaway896 </a> to <a href="https://www.reddit.com/r/phgonewild/"> r/phgonewild </a> <br> <span><a href="https://i.redd.it/rtuzzy7h9nnb1.jpg">[link]</a></span> <span><a href="https://www.reddit.com/r/phgonewild/comments/16fy4tb/what_if_nasa_kama_mo_ako_now/">[comments]</a></span> in /app/www/extensions/xExtension-RedditImage/Content.php:29
Stack trace:
#0 /app/www/extensions/xExtension-RedditImage/Processor/BeforeDisplayProcessor.php(43): RedditImage\Content->__construct()
#1 /app/www/lib/Minz/ExtensionManager.php(338): RedditImage\Processor\BeforeDisplayProcessor->process()
#2 /app/www/lib/Minz/ExtensionManager.php(309): Minz_ExtensionManager::callOneToOne()
#3 /app/www/app/views/index/normal.phtml(34): Minz_ExtensionManager::callHook()
#4 /app/www/lib/Minz/View.php(88): include('...')
#5 /app/www/lib/Minz/View.php(110): Minz_View->includeFile()
#6 /app/www/app/layout/layout.phtml(69): Minz_View->render()
#7 /app/www/lib/Minz/View.php(88): include('...')
#8 /app/www/lib/Minz/View.php(101): Minz_View->includeFile()
#9 /app/www/lib/Minz/View.php(68): Minz_View->buildLayout()
#10 /app/www/lib/Minz/Dispatcher.php(56): Minz_View->build()
#11 /app/www/lib/Minz/FrontController.php(58): Minz_Dispatcher->run()
#12 /app/www/p/i/index.php(57): Minz_FrontController->run()
#13 {main}
I have to say I don't really understand that one, using an online checker the regex seems to match https://www.phpliveregex.com/p/JSm
My log is cluttered with the following entries:
Dez 18 10:04:10 pi php[1487]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 10:04:10 pi php[1487]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 10:34:29 pi php[2077]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 10:34:29 pi php[2077]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 11:19:30 pi php[2738]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 11:19:30 pi php[2738]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 12:04:32 pi php[3919]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 12:04:32 pi php[3919]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 12:49:34 pi php[4597]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 12:49:34 pi php[4597]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 13:34:36 pi php[5787]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 13:34:36 pi php[5787]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 14:19:36 pi php[6445]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 14:19:36 pi php[6445]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 15:04:48 pi php[7633]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 15:04:48 pi php[7633]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 15:49:35 pi php[8315]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 15:49:35 pi php[8315]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 16:34:35 pi php[9501]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Dez 18 16:34:35 pi php[9501]: PHP Warning: Trying to access array offset on value of type null in /usr/share/webapps/freshrss/extensions/xExtension-RedditImage-main/Transformer/InsertTransformer.php on line 76
Functional limitations don't seem to exist, but I think it would be good if the warning was handled better.
So, maybe there is no solution to this, but I just want to give it a try and ask you this.
(Side Note: In the RedditImage-Extension I did not enable the option to mute videos, so every video should play with audio.)
This is example Reddit Post A: https://www.reddit.com/r/interestingasfuck/comments/mnjke0/the_bionic_woman/
It embeds a video from gfycat.com. The source code in FreshRSS of the post is:
<div class="reddit-image figure">
<video controls="" preload="metadata" class="reddit-image">
<source src="https://giant.gfycat.com/HeartySillyCockatiel.webm" type="video/webm">
<source src="https://giant.gfycat.com/HeartySillyCockatiel.mp4" type="video/mp4">
</video>
</div>
This post works flawless in any scenario:
This is example Reddit Post B: https://www.reddit.com/r/nextfuckinglevel/comments/mnouq4/learning_to_sing/
It embeds a video from v.redd.it. The source code in FreshRSS of the post is:
<div class="reddit-image figure">
<video controls="" preload="metadata" class="reddit-image">
<source src="https://v.redd.it/g5xu53hv97s61/DASH_720.webm" type="video/webm">
<source src="https://v.redd.it/g5xu53hv97s61/DASH_720.mp4" type="video/mp4">
</video>
</div>
Posts who embed media from v.redd.it are almost never working. I experience the following problems:
So somehow, on reddit.com, the video does contain audio. I have no idea why it is missing audio in FreshRSS or using the direct mp4 link. Also, if the webm url never works with v.redd.it, it should not be listed as an available source in html, as this is confusing for 3rd party software.
Hope this makes sense ;)
Hi,
I have some new warnings/errors spamming my log ;)
Apr 06 03:28:08 m625q php[23764]: PHP Warning: Undefined variable $links in /usr/share/webapps/freshrss/extensions/_xExtensions_git/xExtension-RedditImage/Transformer/InsertTransformer.php on line 145
Apr 06 03:28:08 m625q php[23764]: PHP Fatal error: Uncaught TypeError: RedditImage\Transformer\AbstractTransformer::generateDom(): Argument #2 ($media) must be of type array, null given, called in /usr/share/webapps/freshrss/extensions/_xExtensions_git/xExtension-RedditImage/Transformer/InsertTransformer.php on line 145 and defined in /usr/share/webapps/freshrss/extensions/_xExtensions_git/xExtension-RedditImage/Transformer/AbstractTransformer.php:32
Since v0.11.0 some subreddits show their content twice when enabling "show metadata".
Example subredddit feed: https://www.reddit.com/r/sysadmin/top/.rss
Hey,
I like to see the metadata of the reddit posts (user, subreddit, direct link, comments) below a post. This is why I need to check "show original content" in the plugin options. Unfortunately, this also loads the original picture/content, which is not required most of the time. Please add an option to show only the metadata, but without repeating the full content.
The plugin should have an optional "use teddit" checkbox. When checked, all reddit feeds will automatically display content from teddit.net instead of reddit.com. Regardless of the checkbox setting, any feed displaying content from teddit.net should include all the correct image embeds as it would for reddit
The option will allow to save the image encoded in base64 in the database.
A caution warning message must be added to warn about database growth.
When embedding video content from v.redd.it, there are currently 2 source urls used: one for .webm and one for a .mp4 file.
Example code:
<div class="reddit-image figure">
<video controls="" preload="metadata" class="reddit-image">
<source src="https://v.redd.it/g5xu53hv97s61/DASH_720.webm" type="video/webm">
<source src="https://v.redd.it/g5xu53hv97s61/DASH_720.mp4" type="video/mp4">
</video>
</div>
While this works for some media platforms, e.g. gfycat.com, it does not work with v.redd.it, as this platform is simply not offering a .webm file. This means currently there is a broken link as a source file referenced, and some 3rd party clients throw an error in this case. A clean solution would be to only reference the mp4 file.
See #4 for additional information
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.