-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
18754dd
commit 2b40c81
Showing
4 changed files
with
75 additions
and
11 deletions.
There are no files selected for viewing
This file contains 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 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 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 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,39 @@ | ||
import type { PlaylistItem } from '../../types/playlist'; | ||
|
||
type DeprecatedPlaylistItem = { | ||
seriesPlayListId?: string; | ||
seriesPlaylistId?: string; | ||
}; | ||
|
||
export const getSeriesId = (item: PlaylistItem & DeprecatedPlaylistItem) => { | ||
if (!item) { | ||
return undefined; | ||
} | ||
|
||
return item['seriesPlayListId'] || item.seriesPlaylistId || item.seriesId; | ||
}; | ||
|
||
export const isSeriesPlaceholder = (item: PlaylistItem) => { | ||
return typeof getSeriesId(item) !== 'undefined'; | ||
}; | ||
|
||
export const isEpisode = (item: PlaylistItem) => { | ||
return item && typeof item.episodeNumber !== 'undefined'; | ||
}; | ||
|
||
export const getSeriesIdFromEpisode = (item: PlaylistItem) => { | ||
if (!item || !isEpisode(item)) { | ||
return null; | ||
} | ||
|
||
const tags = item.tags ? item.tags.split(',') : []; | ||
const seriesIdTag = tags.find(function (tag) { | ||
return /seriesid_([\w\d]+)/i.test(tag); | ||
}); | ||
|
||
if (seriesIdTag) { | ||
return seriesIdTag.split('_')[1]; | ||
} | ||
|
||
return null; | ||
}; |