-
-
Notifications
You must be signed in to change notification settings - Fork 835
Pr/epg fixes #1104
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
Alanon202
wants to merge
12
commits into
4gray:master
Choose a base branch
from
Alanon202:pr/epg-fixes
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Pr/epg fixes #1104
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
856d9c8
fix(catchup): resolve EPG data-loading issues and enable archive play…
Alanon202 0aeaa06
add catchup/archive playback to favorites tab:
Alanon202 747edf1
update handler to properly use external players with catch-up
Alanon202 63fe465
use epg_channel_id for XMLTV lookup in favorites EPG
Alanon202 feccbc8
feat(epg): manual EPG-to-channel mapping with mapping fallback in all…
Alanon202 f68fcc1
fix(epg): correct i18n interpolation syntax in mapping dialog subtitle
Alanon202 b82ce7f
fix(xtream): persist favorites reorder via saveOrder + position fallback
Alanon202 005d2fa
fix: add providedIn:root to catchup service, fix blank favorites
Alanon202 495c344
fix: address remaining Greptile issues 2-5
Alanon202 7a23ba7
fix: use raw SQL with ESCAPE clause for LIKE wildcards in EPG search
Alanon202 1eeea1d
fix: add missing epgService.clearCache() in removeMapping()
Alanon202 6c00711
fix: make favourites catch-up GUI consistent to channel list
Alanon202 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
apps/electron-backend/src/app/database/operations/epg-mapping.operations.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| import { and, eq, inArray, or, sql } from 'drizzle-orm'; | ||
| import * as schema from '@iptvnator/shared/database/schema'; | ||
| import type { AppDatabase } from '../database.types'; | ||
|
|
||
| /** | ||
| * Get a single EPG channel mapping by lookup key. | ||
| */ | ||
| export async function getEpgMapping( | ||
| db: AppDatabase, | ||
| channelKey: string | ||
| ): Promise<{ id: number; channelKey: string; epgChannelId: string; playlistId: string | null } | null> { | ||
| const rows = await db | ||
| .select({ | ||
| id: schema.epgChannelMappings.id, | ||
| channelKey: schema.epgChannelMappings.channelKey, | ||
| epgChannelId: schema.epgChannelMappings.epgChannelId, | ||
| playlistId: schema.epgChannelMappings.playlistId, | ||
| }) | ||
| .from(schema.epgChannelMappings) | ||
| .where(eq(schema.epgChannelMappings.channelKey, channelKey)) | ||
| .limit(1); | ||
|
|
||
| return rows[0] ?? null; | ||
| } | ||
|
|
||
| /** | ||
| * Batch lookup of EPG channel mappings for multiple keys. | ||
| * Returns a Map of channelKey → epgChannelId (only for keys that have mappings). | ||
| */ | ||
| export async function getEpgMappingsBatch( | ||
| db: AppDatabase, | ||
| channelKeys: string[] | ||
| ): Promise<Map<string, string>> { | ||
| if (channelKeys.length === 0) { | ||
| return new Map(); | ||
| } | ||
|
|
||
| const rows = await db | ||
| .select({ | ||
| channelKey: schema.epgChannelMappings.channelKey, | ||
| epgChannelId: schema.epgChannelMappings.epgChannelId, | ||
| }) | ||
| .from(schema.epgChannelMappings) | ||
| .where(inArray(schema.epgChannelMappings.channelKey, channelKeys)); | ||
|
|
||
| const mapping = new Map<string, string>(); | ||
| for (const row of rows) { | ||
| mapping.set(row.channelKey, row.epgChannelId); | ||
| } | ||
| return mapping; | ||
| } | ||
|
|
||
| /** | ||
| * Create or update an EPG channel mapping (upsert). | ||
| */ | ||
| export async function setEpgMapping( | ||
| db: AppDatabase, | ||
| channelKey: string, | ||
| epgChannelId: string, | ||
| playlistId?: string | ||
| ): Promise<{ success: boolean }> { | ||
| await db | ||
| .insert(schema.epgChannelMappings) | ||
| .values({ | ||
| channelKey, | ||
| epgChannelId, | ||
| playlistId: playlistId ?? null, | ||
| }) | ||
| .onConflictDoUpdate({ | ||
| target: schema.epgChannelMappings.channelKey, | ||
| set: { | ||
| epgChannelId, | ||
| playlistId: playlistId ?? null, | ||
| updatedAt: sql`(datetime('now'))`, | ||
| }, | ||
| }); | ||
|
|
||
| return { success: true }; | ||
| } | ||
|
|
||
| /** | ||
| * Remove an EPG channel mapping. | ||
| */ | ||
| export async function deleteEpgMapping( | ||
| db: AppDatabase, | ||
| channelKey: string | ||
| ): Promise<{ success: boolean }> { | ||
| await db | ||
| .delete(schema.epgChannelMappings) | ||
| .where(eq(schema.epgChannelMappings.channelKey, channelKey)); | ||
|
|
||
| return { success: true }; | ||
| } | ||
|
|
||
| /** | ||
| * Search EPG channels by display name for the mapping dialog. | ||
| */ | ||
| export async function searchEpgChannels( | ||
| db: AppDatabase, | ||
| searchTerm: string, | ||
| limit = 50 | ||
| ): Promise<Array<{ id: string; displayName: string; iconUrl: string | null }>> { | ||
| // Escape LIKE wildcards so user input like "HBO%" or "_BC" is literal. | ||
| // Drizzle's like() doesn't support ESCAPE, so we use raw SQL. | ||
| const escaped = searchTerm.trim().replace(/[%_\\]/g, '\\$&'); | ||
| const pattern = `%${escaped}%`; | ||
|
|
||
| return db | ||
| .select({ | ||
| id: schema.epgChannels.id, | ||
| displayName: schema.epgChannels.displayName, | ||
| iconUrl: schema.epgChannels.iconUrl, | ||
| }) | ||
| .from(schema.epgChannels) | ||
| .where( | ||
| or( | ||
| sql`${schema.epgChannels.displayName} LIKE ${pattern} ESCAPE '\\'`, | ||
| sql`${schema.epgChannels.id} LIKE ${pattern} ESCAPE '\\'` | ||
| ) | ||
| ) | ||
| .orderBy(schema.epgChannels.displayName) | ||
| .limit(limit); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.