Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video no refresh #300

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ namespace Invidious
cacheSeconds = 18000 ' 5 hours
cancellation = invalid
tryCount = 2
refresh = true

if options <> invalid
if options.DoesExist("cacheSeconds")
Expand All @@ -124,13 +125,20 @@ namespace Invidious
if options.DoesExist("tryCount")
tryCount = options.tryCount
end if
if options.DoesExist("refresh")
refresh = options.refresh
end if
end if

instance = m.GetInstance()
url = `${instance}${Invidious.VIDEOS_ENDPOINT}/${videoId}`

request = HttpClient.Get(url)

if not refresh
request.QueryParam("refresh", "false")
end if

request.CacheSeconds(cacheSeconds)
request.Cancellation(cancellation)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function VideoQueueViewContentTask(input as object) as object
index = MathUtils.Clamp(input.index - 2, 0, videoNodes.Count() - 1)

requestOptions = {
refresh: false
cacheSeconds: 8640000 ' 100 days
cancellation: cancellation
tryCount: 1
Expand Down
4 changes: 4 additions & 0 deletions playlet-lib/src/config/invidious_video_api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ video_info:
url: /api/v1/videos/{id}
responseHandler: VideoInfoHandler
cacheSeconds: 259200 # 3 days
queryParams:
refresh:
type: boolean
default: false

playlist_info:
title: Playlist
Expand Down
4 changes: 2 additions & 2 deletions playlet-web/src/lib/Api/InvidiousApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ export class InvidiousApi {
return await response.json();
}

public async getVideoMetadata(videoId: string) {
const response = await fetch(`${this.instance}/api/v1/videos/${videoId}`);
public async getVideoMetadata(videoId: string, refresh: boolean = true) {
const response = await fetch(`${this.instance}/api/v1/videos/${videoId}?refresh=${refresh}`);
return await response.json();
}

Expand Down
2 changes: 1 addition & 1 deletion playlet-web/src/lib/LinkDragDrop.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
async function searchForVideoById(videoId, timestamp) {
try {
isLoading = true;
videoMetadata = await invidiousApi.getVideoMetadata(videoId);
videoMetadata = await invidiousApi.getVideoMetadata(videoId, false);
videoStartAtChecked = timestamp !== undefined;
if (videoStartAtChecked) {
videoStartAtTimestamp = timestamp;
Expand Down