cn-tools / cntools_FreshRssExtensions

This repository contains my unofficial FreshRSS extensions
MIT License
49 stars 11 forks source link

Filtering away Youtube Shorts? #8

Closed krusty4president closed 5 months ago

krusty4president commented 11 months ago

Hi. I am using it with my freshrss installation. Is it possible to filter out Youtube shorts with this extension?

cn-tools commented 11 months ago

this plug in is changing the url of the added feed only yet and doesn't do any interaction with feed entries.

but i'll take a look if i can fulfill your wish.

krusty4president commented 11 months ago

That would be so helpful both to me and the community. Unfortunately som channels just bloat the content with so many YT Shorts.

colinstu12 commented 10 months ago

Agreed, that would be useful

cn-tools commented 6 months ago

Hello @krusty4president and @colinstu12

a few seconds ago i checked in a alpha version to detect youtube shorts.

Please test it and i'm happy to read your feedback.

colinstu12 commented 6 months ago

Thanks @cn-tools Was this addon required previously to import YT channels? I was already able to just put the channel's URL into the add feed screen without the need of addon nor this API docker for [YouTube-operational-API].

cn-tools commented 6 months ago

@colinstu12

There are other addons availabe to change a YT channel url into a feed URL. Whithout any of this addons it's not able to do this, as i know.

If you want to add only YT urls for playlists, channels, user you don't need the third party url 'YouTube-operational-API'. With the third-party url it is possible to process YT handles like 'https://youtube.com/@youtube'

Additional with 'YouTube-operational-API' you can detect YT shorts and therefor you could mark them as read or will block them.

i300220 commented 6 months ago

Shorts are now marked as read, per the extension configuration. Works perfectly well. Thank you so much @cn-tools !

Does not log though. Might be me, not the extension. All that is logged here from FreshRss is the SimplePie messages. Found nothing in the GUI nor in the config files to enable logging with Minz_Log

cn-tools commented 6 months ago

THX @i300220 for the positive answer!

Do you see any LOG message on LOG page inside the settings of FreshRSS?

i300220 commented 6 months ago

Do you see any LOG message on LOG page inside the settings of FreshRSS?

Capture d’écran du 2024-05-12 12-20-41

I do, but none related to this extension.

Thanks!

i300220 commented 6 months ago

Arrgh! They're now making 20 second videos that aren't technically shorts e.g.

https://www.youtube.com/watch?v=lox2ZemF3HI -> 200 https://www.youtube.com/shorts/lox2ZemF3HI -> 303 redirect to https://www.youtube.com/watch?v=lox2ZemF3HI

https://yt.lemnoslife.com/videos?part=short&id=lox2ZemF3HI

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "lox2ZemF3HI",
            "short": {
                "available": false
            }
        }
    ]
}
cn-tools commented 5 months ago

grrrrrr 🫣

i will have a look, but i think this should be checked and fixed (if iths possible) by the development team of the third-party software

i300220 commented 5 months ago

Makes sense. I had a look at the 3rd party code.

This would determine the duration of the same video as above in seconds.

https://yt.lemnoslife.com/videos?part=contentDetails&id=lox2ZemF3HI

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "lox2ZemF3HI",
            "contentDetails": {
                "duration": 20
            }
        }
    ]
}

One could check the duration and if it's less than 60 seconds, decide a short is therefore available whether there is one or not.

Here, you kill 2 birds with 1 stone:

https://yt.lemnoslife.com/videos?part=contentDetails,short&id=lox2ZemF3HI

{
    "kind": "youtube#videoListResponse",
    "etag": "NotImplemented",
    "items": [
        {
            "kind": "youtube#video",
            "etag": "NotImplemented",
            "id": "lox2ZemF3HI",
            "contentDetails": {
                "duration": 20
            },
            "short": {
                "available": false
            }
        }
    ]
}

If you prefer I submit it to the 3rd party, let me know.

Patch attached, currently under evaluation: extension.diff.gz

Best!

cn-tools commented 5 months ago

Your shot on two birds looks like a really good way and base. 👍

I will have a look in the next few days. Thx for the DIFF file!

Best!

cn-tools commented 5 months ago

@i300220 could you test the branch YT-shorts, please?

i added a new setting to define a duration. All shorter videos will be declared as 'short' too yet

i300220 commented 5 months ago

Hi,

Gladly.

Installed. Duration set to 5 minutes to be certain to intercept some files. Will reset to 60 seconds if all goes well. Shorts by duration are very uncommon.

Thanks a lot!

i300220 commented 5 months ago

Tested with shorts, shorts by duration and regular videos and, everything is as expected. Best regards.

luckycold commented 4 months ago

I hope this isn't me just bringing this up for nothing. But it seems to be the case that this is applied to all YouTube videos with RSS. Is there a way to make it where it can be enabled dependent on the channel?

i300220 commented 2 months ago

``I noticed zero youtube videos in my feeds for a few weeks.

Testing https://yt.lemnoslife.com/videos?part=contentDetails,short&id=lox2ZemF3HI showed contentDetails duration = 0 therefore all videos are being rejected.

Just documenting the issue before I go to lemnoslife to determine what has changed.

I think it would be prudent for now to test if the duration == 0 near lines 251-252 and if so abort.

                                        $extraLogTxt = '('.strval($ytDuration).'<'.strval($shortDuration).')';
                                        if ($ytDuration < $shortDuration && $ytDuration > 0) {
                                            Minz_Log::debug('YouTubeChannel2RssFeed-isShort: THIS IS A SHORT (by duration)'.$extraLogTxt);
                                            $result = true;
                                        }

I am currently testing the code. And it does as it should.

Best!

UPDATE: Issue submitted - https://github.com/Benjamin-Loison/YouTube-operational-API/issues/299

UPDATE 2: Reported fixed.