Automattic / jetpack

Security, performance, marketing, and design tools — Jetpack is made by WordPress experts to make WP sites safer and faster, and help you grow your traffic.
https://jetpack.com/
Other
1.58k stars 799 forks source link

Podcast Player: Increase the number of episodes shown #21291

Open rickmgithub opened 2 years ago

rickmgithub commented 2 years ago

What

Increase the "number of items" in the podcast player block

Why

Many podcasts have more than 10 episodes.

If the podcaster is hosting their podcast files on another service then they can only show 10 of their episodes on the podcast player block in their website here.

Is it possible to increase the number. It doesn't seem to be effected by the "writing" or feed number settings on the site.

How

No response

formosattic commented 2 years ago

Link to test: https://distributed.blog/category/podcast/feed/

The max setting is 10. image

Moving to Jetpack repo.

jeherve commented 2 years ago

Related: #18836 where we added a filter one could use to lift the limit like so:

add_filter(
    'jetpack_podcast_helper_list_quantity',
    function () {
        return 15;
    }
);

However, and as you pointed, the filter does not impact the range control in the UI. If one were to use the filter, you would also have to edit the block attributes with the code editor, like so:

https://user-images.githubusercontent.com/426388/136001311-f7aa798b-1dd8-4195-a251-4767e755d956.mov

As a first step I think it would be interesting to have the range control respect the number set with the filter.

formosattic commented 2 years ago

@jeherve : Thanks for the workaround! Just noting that this was initially filed in the context/repo of WordPress.com, so the filter solution is not an option on Simple sites.

amustaque97 commented 2 years ago

@jeherve, I can take it up. Worked on a similar kind of issue PR #21273

amustaque97 commented 2 years ago

@jeherve, need some directions to get started on this issue. As per my investigation, I found that function fetchPodcastFeed is responsible for calling API https://distributed.blog/category/podcast/feed/ is returning response only 10 tracks as shown in the image.

image

I guess, these changes are required from the wpcom side and these changes can only be done by Automattician.

I tested with some other 3rd party websites, with the same RSS feed link I'm able to get more than 10 records. So I believe it has not only to do with range control max limit but also API /wpcom/v2/podcast-player.

jeherve commented 2 years ago

I found that function fetchPodcastFeed is responsible for calling API

Yup, that's correct. The API endpoint is defined in this file: https://github.com/Automattic/jetpack/blob/ba2dd6c30be137baad96aafb2466d0aed7e182e5/projects/plugins/jetpack/_inc/lib/core-api/wpcom-endpoints/class-wpcom-rest-api-v2-endpoint-podcast-player.php

That file, in turn, uses the utilites in this file to handle fetching RSS feeds: https://github.com/Automattic/jetpack/blob/504aad5997b7c8f5ddc39ca36cb98c8afe9347cd/projects/plugins/jetpack/_inc/lib/class-jetpack-podcast-helper.php

And in this file, we have a filter you can use to increase the number of records you are fetching, as I mentioned in https://github.com/Automattic/jetpack/issues/21291#issuecomment-934258129

Once you've used that filter to allow fetching more items with the endpoint, you're left with the limit set in the UI with the range control UI: https://github.com/Automattic/jetpack/blob/b957e5413117d471421bfbf434fa7c3c7cf9d668/projects/plugins/jetpack/extensions/blocks/podcast-player/edit.js#L313

Ideally, we'd have the range control UI update when one sets up the PHP filter.

inaikem commented 2 years ago

Hi folks, can someone tell me if this change was reverted or if a reduced maximum item count was added?

My own tests following this interaction -- 5469709-zd-woothe -- show a maximum episode count of 10 (regardless of if you manage to add a higher number in the box).

Edit: I originally posted the above in the related PR, before finding this issue 🙏

github-actions[bot] commented 2 years ago

Support References

This comment is automatically generated. Please do not edit it.

jeherve commented 2 years ago

@inaikem It seems to work well on my end. Upon adding the code snippet to bump the number of max items like so:

add_filter(
    'jetpack_podcast_helper_tracks_quantity',
    function () {
        return 42;
    }
);

I see the following in the editor:

Screen Shot 2022-08-11 at 09 24 12

and on the frontend:

moar-podcasts

inaikem commented 2 years ago

I should have been clearer in my comment above and clarified that this specific user is on a WPcom Simple site, so we're not able to add code snippets to bump the limit.

Is there the possibility of bumping the default block limit for all instances? I'm happy to open a feature request to support that if needed.

jeherve commented 2 years ago

In this case we can indeed reopen this issue, and consider bumping the limit for all podcast blocks. What would be a new limit that would work for the site owner in this last request we got?

inaikem commented 2 years ago

The user above has ~30 episodes but I'd like to see an upper limit of 100 to keep things aligned with limits present in other blocks such as Blog Posts, Latest Posts, Query etc.

While we're on this, would it be possible to add some form of pagination/load more option?

Cc @that-mike-bal + @rickmgithub in relation to the upcoming podcast project.

jeherve commented 2 years ago

I'd like to see an upper limit of 100 to keep things aligned with limits present in other blocks such as Blog Posts, Latest Posts, Query etc.

With such a large number, we may start running into performance issues, as well as strain on the site you pull the feed from. This is why WordPress has a default of 10 to start.

would it be possible to add some form of pagination/load more option?

Adding such a feature would be a bigger project, but may be one way to tackle any kind of performance issues.

that-mike-bal commented 2 years ago

Maybe we can identify when it's hosted with us vs third party and open up additional options. I imagine it would be easier to manage playing local files vs via a feed?

that-mike-bal commented 2 years ago

Another thought would be to index the feed and allow searching episodes on the front end that would allow the player to switch tracks and "hold" all of them without having to load all of them.

I actually think it's hard to find an episode on any platform if you have a lot to scroll through.