From fef75a274bf7e8ac6fce40df9247d82e0c85d0c5 Mon Sep 17 00:00:00 2001 From: chaptergy Date: Mon, 16 Jan 2023 00:28:51 +0100 Subject: [PATCH 1/2] Fixes scrobble template to include named matching group --- src/templates/scrobbler-template/ScrobblerTemplateParser.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/templates/scrobbler-template/ScrobblerTemplateParser.ts b/src/templates/scrobbler-template/ScrobblerTemplateParser.ts index 809367b..6b3bacc 100644 --- a/src/templates/scrobbler-template/ScrobblerTemplateParser.ts +++ b/src/templates/scrobbler-template/ScrobblerTemplateParser.ts @@ -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\/(?.+)/, // https://streamingservice.com/watch/ABC123 => ABC123 }); } From b3a7d4892297a6c04fdcab920dbde20756b46bf2 Mon Sep 17 00:00:00 2001 From: chaptergy Date: Mon, 16 Jan 2023 00:38:31 +0100 Subject: [PATCH 2/2] Updates sync template to reflect current required functions --- .../sync-template/SyncTemplateApi.ts | 22 +++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/templates/sync-template/SyncTemplateApi.ts b/src/templates/sync-template/SyncTemplateApi.ts index 2ec9c42..a14299e 100644 --- a/src/templates/sync-template/SyncTemplateApi.ts +++ b/src/templates/sync-template/SyncTemplateApi.ts @@ -36,19 +36,22 @@ class _SyncTemplateApi extends ServiceApi { * * It should also set `hasReachedHistoryEnd` to true when there are no more history items to load. */ - async loadNextHistoryPage(): Promise { + async loadHistoryItems(): Promise { // 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; @@ -56,6 +59,21 @@ class _SyncTemplateApi extends ServiceApi { 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 { + // update item.watchedAt and item.progress here + throw new Error('not implemented'); + } + /** * This method should check if a history item is new. */