jdf76 / plugin.video.youtube

Kodi's Youtube Plugin -- Please Check the forums before submitting an issue
https://ytaddon.page.link/forum
392 stars 117 forks source link

Incorrect sort order of videos in a channel #612

Open Dikowda opened 5 years ago

Dikowda commented 5 years ago

For some Youtube channels the list of videos is not in chronological order. It's been bugging me for a while now and causes me to miss videos because they end up appearing on later pages.

A good example is JustKiddingNews channel. They past multiple videos per day (not sure if that has anything to do with it). With default, date or date added sort order, page 1 of the channel video list has missing videos compared to Youtube in a web browser. These videos appear on later pages.

Further information is here... https://forum.kodi.tv/showthread.php?tid=325740&pid=2857221#pid2857221 ...and has also been confirmed by forum user anxdpanic, quote - 'I can confirm this is happening, it appears to be a disparity between the public and private api.'

Notes: This occurs when signed in (with my private keys) or signed out. Originally found on version 6.4.0 and also 6.4.1.

anxdpanic commented 5 years ago

Thanks for opening the issue, I would like to have this resolved as well.

The api doesn't include a way to filter or request the playlist with sorting, so we can only sort the returned videos.

Atm the only reliable way to resolve this would be to request the whole Uploads playlist, which isn't reasonable, as you can imagine how large they can be.

I will post any progress made on the issue here.

Dikowda commented 5 years ago

I have done a few tests myself using API v3. Not sure whether this is what is used in the Kodi addon, but the request does allow the sort order to be defined.

GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCfPhyExfcaqJBKc3HO3cNBw&maxResults=50&order=date&key=[YOUR_API_KEY]

anxdpanic commented 5 years ago

Will look into using search hopefully this evening/tomorrow.

What we're currently using is https://developers.google.com/youtube/v3/docs/playlistItems/list with the channels Uploads playlist. Which should be the playlist that shows when you choose Videos for a channel on the website.

One down side is going to be the quota cost going from 5~7 points to 100 points. If it resolves the channel order I think it'll be worth the cost. May need to expose the Uploads playlist in some other way as well, since the search is limited to 500 results.

Note: Search results are constrained to a maximum of 500 videos if your request specifies a value for the channelId parameter and sets the type parameter value to video,...
anxdpanic commented 5 years ago

v6.5.0~alpha2 has the changes to use search and adds the Uploads playlist to channel playlists. Installation - In-development It seems to be better but is still not a 1:1

Dikowda commented 5 years ago

That's better. Thanks Still the odd video that is not in order like https://www.youtube.com/watch?v=94Oqqzghsos. It was published 23/05/2019 but does not appear in the api results around that date. But it does appear on the channel page in a web browser in the correct place.

anxdpanic commented 5 years ago

Thanks for confirming it's improved. Since it's still not 1:1, will leave this issue open for any future improvements

Dikowda commented 5 years ago

I notice that the channel list now includes live streams. This means you could remove the Live page on the channel page. Just a thought.

Dikowda commented 5 years ago

I have been plying and noticed that I get 1:1 results when published dates are used. eg GET https://www.googleapis.com/youtube/v3/search?part=snippet&channelId=UCfPhyExfcaqJBKc3HO3cNBw&maxResults=50&order=date&publishedAfter=2019-06-13T00:00:00Z&publishedBefore=2019-06-20T00:00:00Z&safeSearch=none&key=[YOUR_API_KEY]

The problem will be how to deal with the variable number of results in the app and the quota cost. Some channels would have 1 video per month and some 10 videos per day. Maybe a 1 day search can be run multiple times working back from today's date/time until an array of results is filled. Then these are shown on a page.