Git Product home page Git Product logo

xextension-redditimage's People

Contributors

aledeg avatar itskaa avatar rom-1 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

timendum itskaa

xextension-redditimage's Issues

Cyrillic text appears scrambled

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.

Screenshot_2024-02-29-12-51-22

InvalidContentException

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

Some entries doesn't load `metadata` properly

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

PHP Warning: Trying to access array offset on value of type null InsertTransformer.php on line 76

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.

Problems with Video/Audio if media source is v.redd.it

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:

  • I can play the video within FreshRSS, and audio plays without any problems
  • I can visit both source urls manually, and the video plays in my browser
  • my smartphone RSS Reader App (FeedMe) plays the video without any problem

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:

  • I can play the video within FreshRSS, but only without audio. It seems the audio portion of the video is missing (speaker button is greyed out), but when visiting the original reddit post on reddit.com, it turns out there is an audio part!
  • The first source url (webm type) does not work at all if visiting manually -> "Access denied"
  • The second source url (mp4 type) shows the video, but again the audio part is missing
  • my smartphone RSS Reader App (FeedMe) tells me the link to the video is broken and cannot be loaded. I guess the App only tries accessing the first webm url which results in an "access denied" http response.

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 ;)

PHP Warning: Undefined variable $links and PHP Fatal error: Uncaught TypeError: ($media) must be of type array

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

[Feature Request] Reddit Image: Option to keep Metadata

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.

I attached a screenshot to show what I mean:
2021-04-06_09h17_06

Add teddit support

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

Add an option to save images

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.

[Bug] v.redd.it video files: No webm source file found

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.