This commit is contained in:
Markos Gogoulos 2025-09-17 12:16:56 +03:00 committed by Yiannis Christodoulou
parent 32f61cf566
commit e34bd55e7a
6 changed files with 12 additions and 36 deletions

View File

@ -256,7 +256,7 @@ def video_chapters(request, friendly_token):
return HttpResponseRedirect("/")
try:
data = json.loads(request.body)["chapters"]
data = json.loads(request.body)["segments"]
chapters = []
for _, chapter_data in enumerate(data):
start_time = chapter_data.get('startTime')

View File

@ -968,7 +968,7 @@ const TimelineControls = ({
useEffect(() => {
const loadSavedSegments = () => {
// Get savedSegments directly from window.MEDIA_DATA
let savedData = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.savedSegments) || null;
let savedData = (typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) || null;
// If no saved segments, use default segments
if (!savedData) {

View File

@ -94,33 +94,7 @@ const useVideoChapters = () => {
// Check if we have existing chapters from the backend
const existingChapters =
(typeof window !== 'undefined' && (window as any).MEDIA_DATA?.chapters) ||
[
/* {
name: 'Chapter 1',
from: '00:00:00',
to: '00:00:03',
},
{
name: 'Chapter 2',
from: '00:00:03',
to: '00:00:06',
},
{
name: 'Chapter 3',
from: '00:00:09',
to: '00:00:12',
},
{
name: 'Chapter 4',
from: '00:00:15',
to: '00:00:18',
},
{
name: 'Chapter 5',
from: '00:00:21',
to: '00:00:24',
}, */
];
[];
if (existingChapters.length > 0) {
// Create segments from existing chapters
@ -128,8 +102,8 @@ const useVideoChapters = () => {
const chapter = existingChapters[i];
// Parse time strings to seconds
const startTime = parseTimeToSeconds(chapter.from);
const endTime = parseTimeToSeconds(chapter.to);
const startTime = parseTimeToSeconds(chapter.startTime);
const endTime = parseTimeToSeconds(chapter.endTime);
// Generate thumbnail for this segment
const segmentThumbnail = await generateThumbnail(video, (startTime + endTime) / 2);
@ -140,7 +114,7 @@ const useVideoChapters = () => {
startTime: startTime,
endTime: endTime,
thumbnail: segmentThumbnail,
chapterTitle: chapter.name, // Set the chapter title from backend data
chapterTitle: chapter.text,
};
initialSegments.push(segment);
@ -768,7 +742,7 @@ const useVideoChapters = () => {
// Convert chapters to backend expected format
const backendChapters = chapters.map((chapter) => ({
startTime: chapter.from,
startTime: chapter.from,
endTime: chapter.to,
text: chapter.name,
}));

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -16,8 +16,10 @@
mediaId: "{{ media_object.friendly_token }}",
redirectURL: "{{ media_object.get_absolute_url }}",
redirectUserMediaURL: "{{ media_object.user.get_absolute_url }}",
chapters: "{{ chapters }}",
chapters: {{ chapters|safe }},
};
console.log(window.MEDIA_DATA.chapters)
</script>
{%endblock topimports %}