mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 20:56:19 -08:00
- Move PlaybackPositionData interface to shared-interfaces lib - Replace all `any` types with proper PlaybackPositionData typing - Add comment clarifying position=duration semantics for watched episodes Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
91 lines
2.6 KiB
TypeScript
91 lines
2.6 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import { PlaybackPositionData } from 'shared-interfaces';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class PlaybackPositionService {
|
|
async savePlaybackPosition(
|
|
playlistId: string,
|
|
data: PlaybackPositionData
|
|
): Promise<void> {
|
|
try {
|
|
await window.electron.dbSavePlaybackPosition(playlistId, data);
|
|
} catch (error) {
|
|
console.error('Error saving playback position:', error);
|
|
}
|
|
}
|
|
|
|
async getPlaybackPosition(
|
|
playlistId: string,
|
|
contentXtreamId: number,
|
|
contentType: 'vod' | 'episode'
|
|
): Promise<PlaybackPositionData | null> {
|
|
try {
|
|
return await window.electron.dbGetPlaybackPosition(
|
|
playlistId,
|
|
contentXtreamId,
|
|
contentType
|
|
);
|
|
} catch (error) {
|
|
console.error('Error getting playback position:', error);
|
|
return null;
|
|
}
|
|
}
|
|
|
|
async getSeriesPlaybackPositions(
|
|
playlistId: string,
|
|
seriesXtreamId: number
|
|
): Promise<PlaybackPositionData[]> {
|
|
try {
|
|
return await window.electron.dbGetSeriesPlaybackPositions(
|
|
playlistId,
|
|
seriesXtreamId
|
|
);
|
|
} catch (error) {
|
|
console.error('Error getting series playback positions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async getRecentPlaybackPositions(
|
|
playlistId: string,
|
|
limit?: number
|
|
): Promise<PlaybackPositionData[]> {
|
|
try {
|
|
return await window.electron.dbGetRecentPlaybackPositions(
|
|
playlistId,
|
|
limit
|
|
);
|
|
} catch (error) {
|
|
console.error('Error getting recent playback positions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async getAllPlaybackPositions(playlistId: string): Promise<PlaybackPositionData[]> {
|
|
try {
|
|
return await window.electron.dbGetAllPlaybackPositions(playlistId);
|
|
} catch (error) {
|
|
console.error('Error getting all playback positions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
async clearPlaybackPosition(
|
|
playlistId: string,
|
|
contentXtreamId: number,
|
|
contentType: 'vod' | 'episode'
|
|
): Promise<void> {
|
|
try {
|
|
await window.electron.dbClearPlaybackPosition(
|
|
playlistId,
|
|
contentXtreamId,
|
|
contentType
|
|
);
|
|
} catch (error) {
|
|
console.error('Error clearing playback position:', error);
|
|
}
|
|
}
|
|
}
|