diff --git a/src/ytdl_sub/entries/script/variable_definitions.py b/src/ytdl_sub/entries/script/variable_definitions.py index fcd67168..aa8f08f1 100644 --- a/src/ytdl_sub/entries/script/variable_definitions.py +++ b/src/ytdl_sub/entries/script/variable_definitions.py @@ -68,6 +68,10 @@ class VariableDefinitions: """ return MetadataVariable(metadata_key="id", variable_name="uid") + @property + def duration(self) -> MetadataVariable: + return MetadataVariable("duration", metadata_key="duration") + @property def uid_sanitized_plex(self) -> Variable: """ diff --git a/src/ytdl_sub/entries/script/variable_scripts.py b/src/ytdl_sub/entries/script/variable_scripts.py index a35ac83a..d63cb7eb 100644 --- a/src/ytdl_sub/entries/script/variable_scripts.py +++ b/src/ytdl_sub/entries/script/variable_scripts.py @@ -138,6 +138,7 @@ ENTRY_DEFAULT_VARIABLES: Dict[MetadataVariable, str] = { v.channel: entry_get_str(v.channel, v.uploader), v.creator: entry_get_str(v.creator, v.channel), v.channel_id: entry_get_str(v.channel_id, v.uploader_id), + v.duration: entry_get_int(v.duration, 0), v.playlist_index: entry_get_int(v.playlist_index, 1), v.playlist_count: entry_get_int(v.playlist_count, 1), v.playlist_uid: entry_get_str(v.playlist_uid, v.uid), diff --git a/src/ytdl_sub/plugins/chapters.py b/src/ytdl_sub/plugins/chapters.py index 71f0d5db..9fde8799 100644 --- a/src/ytdl_sub/plugins/chapters.py +++ b/src/ytdl_sub/plugins/chapters.py @@ -333,7 +333,7 @@ class ChaptersPlugin(Plugin[ChaptersOptions]): set_ffmpeg_metadata_chapters( file_path=entry.get_download_file_path(), chapters=chapters, - file_duration_sec=entry.kwargs("duration"), + file_duration_sec=entry.get_int(v.duration), ) if not has_chapters_from_comments: diff --git a/src/ytdl_sub/plugins/split_by_chapters.py b/src/ytdl_sub/plugins/split_by_chapters.py index 3194e8e5..6d9bf8f0 100644 --- a/src/ytdl_sub/plugins/split_by_chapters.py +++ b/src/ytdl_sub/plugins/split_by_chapters.py @@ -146,7 +146,7 @@ class SplitByChaptersPlugin(SplitPlugin[SplitByChaptersOptions]): ) timestamp_begin = chapters.timestamps[idx].readable_str - timestamp_end = Timestamp(new_entry.kwargs("duration")).readable_str + timestamp_end = Timestamp(new_entry.get_int(v.duration)).readable_str if idx + 1 < len(chapters.timestamps): timestamp_end = chapters.timestamps[idx + 1].readable_str