invidious
invidious copied to clipboard
Get all videos when sorted by oldest
I had originally implemented a partially working solution where the continuation was passed in the request headers, similiar to how this issue was fixed here. However after doing that I found this comment which stated that using the page number rather than passing around the continuation was a design decision.
This pull request adds a new database table which keeps track of the continuation for each page on a channel. The new db store/lookup logic is only used where the current implementation doesn't work, so getting videos sorted by newest and popular still uses the existing continuation generation logic. This reduces the amount of entries that will be written to the database, and the amount of time looking up continuations in the database, as we only really need to store the continuations when sorting by oldest.
In normal operation (using the next page button) the continuation for the following page will be stored after the data for the current page is returned from the API call. However if a user manually goes to a page where we don't have the continuation (e.g. by modifying the page request header) we find the 'latest' continuation we have then iterate from there to get the continuation for the wanted page. During this iteration we store the returned continuation so that it can be easily looked up next time that page is requested.
Fixes: #2436 I want to be awarded the bounty associated to the issue this PR is fixing.
Thanks for your contribution!
~~While your idea is good, the problem lies in how the continuation token is crafted. Youtube changed that some time ago and produce_channel_videos_continuation
now produces bad tokens.~~
Edit: After some investigation, it seems that ctokens have only changed for the oldest
sorting. And it requires arbitrary integers to get the other pages.
Also, we won't be able to merge your PR soon because we don't have any migration tools, sorry for the inconvenience.
According to this IRC message, this PR should be closed