Timeline
TimelineItem
dataclass
¶
An instance of TimelineItem describes an objects being displayed either a Top or Bottom timeline within a PGS file.
A TimelineItem is effectively the text block being displayed on screen for a set duration.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
start
|
SubRipTime
|
When the item starts being displayed. |
required |
ds
|
DisplaySet | None
|
DisplaySet associated with this item. |
None
|
end
|
SubRipTime
|
When the item stops being displayed. |
SubRipTime()
|
window_id
|
The Window the item is being displayed in within a PGS file. |
required |
duration
property
¶
Provides duration with which a given TimelineItem is being displayed.
Returns:
| Type | Description |
|---|---|
SubRipTime
|
Duration with which a given TimelineItem is being displayed. |
lang_estimate
property
¶
Contains a list of languages and their probabilities matching the text within a PgsSubtitleItem.
Returns:
| Type | Description |
|---|---|
list
|
Language estimation of the text. |
text
property
¶
Returns text displayed within this timeline slot in a PGS file.
Returns:
| Type | Description |
|---|---|
str
|
Text displayed within this timeline slot in a PGS file. |
gen_pgs_subtitle_item()
¶
Generates a PgsSubtitleItem described by the TimelineItems entry. Contains the image and later text / language estimation of the text.
Returns:
| Type | Description |
|---|---|
PgsSubtitleItem
|
The PgsSubtitleItem which is displayed within this timeline slot. |
set_text(text)
¶
Sets the text displayed within this timeline slot in a PGS file.
__process_timeline_item(new_timeline, timelines, ds, global_palettes)
¶
TimelineItems extracted from PGS subtitles have no correlation to their respective counterparts coming before or after.
Process each item and extract the WindowID they are displayed in. If a prior item already exists within the Timelines dict, check if they are the same item referenced by their ID.
If its a new item, simply add it to the Timelines dict, else update prior items data with current items data where required.
Returns:
| Type | Description |
|---|---|
dict
|
Timelines dict once a new item has been processed. |
fix_endpoints(fixables, reset_statements, end)
¶
Reprocess dictionary containing TimelineItems displayed in either Top or Bottom window. Since END & RESET segments do not define images within them, they will not be correlated to a specific TimelineItem.
However they define the true end timestamp for the TimelineItem prior, so the items end needs to be extended to match the END / RESET segments display timestamp.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing TimelineItems displayed in either Top or Bottom window. |
gen_timelines(members, global_palettes)
¶
Generate timelines. Timelines consist of TimelineItems and describe the changes in either the Top or Bottom window of a PGS file. Items will be grouped as one if they display the same image within the same position and will be treated as new items if a new image is being defined.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary containing TimelineItems displayed in either Top or Bottom window. |