Skip to content

Updates templates #3

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

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class _ScrobblerTemplateParser extends ScrobbleParser {
constructor() {
super(ScrobblerTemplateApi, {
videoPlayerSelector: 'video', // This is the default option, so it doesn't need to be specified
watchingUrlRegex: /\/watch\/(.+)/, // https://streamingservice.com/watch/ABC123 => ABC123
watchingUrlRegex: /\/watch\/(?<id>.+)/, // https://streamingservice.com/watch/ABC123 => ABC123
});
}

Expand Down
22 changes: 20 additions & 2 deletions src/templates/sync-template/SyncTemplateApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,44 @@ class _SyncTemplateApi extends ServiceApi {
*
* It should also set `hasReachedHistoryEnd` to true when there are no more history items to load.
*/
async loadNextHistoryPage(): Promise<TemplateHistoryItem[]> {
async loadHistoryItems(): Promise<TemplateHistoryItem[]> {
// Example implementation:

let historyItems: TemplateHistoryItem[] = [];

// Retrieve the history items
const responseText = await Requests.send({
url: '...',
// note, that this.nextHistoryPage starts at 0
url: `...?page=${this.nextHistoryPage}`,
method: 'GET',
});
const responseJson = JSON.parse(responseText);
historyItems = responseJson?.items ?? [];

this.nextHistoryPage += 1;

// Check if it has reached the history end
// @ts-expect-error
this.hasReachedHistoryEnd = historyItems.length === 0;

return historyItems;
}

/**
* This method should return a unique ID for a history item
*/
getHistoryItemId(historyItem: TemplateHistoryItem): string {
throw new Error('not implemented');
}

/**
* This method is should update the `watchedAt` and `progress` data of `item` based in the `historyItem`
*/
updateItemFromHistory(item: ScrobbleItemValues, historyItem: TemplateHistoryItem): Promisable<void> {
// update item.watchedAt and item.progress here
throw new Error('not implemented');
}

/**
* This method should check if a history item is new.
*/
Expand Down