MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / chapter_list_import_xml

Function chapter_list_import_xml

gtk/src/chapters.c:355–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355static gboolean
356chapter_list_import_xml (const gchar *file, signal_user_data_t *ud)
357{
358 xmlDocPtr doc;
359 xmlNodePtr node;
360 xmlXPathObjectPtr chapter_list;
361 xmlNodeSetPtr nodeset;
362 char *name;
363 GhbValue *chapter_array, *chapter, *dest;
364
365 doc = xmlParseFile(file);
366 if (!doc)
367 {
368 ghb_log("Could not open file %s", file);
369 return FALSE;
370 }
371 node = xmlDocGetRootElement(doc);
372 if (node == NULL || xmlStrcmp(node->name, (const xmlChar *) "Chapters"))
373 {
374 ghb_log("%s is not a valid Matroska XML file.", file);
375 xmlFreeDoc(doc);
376 return FALSE;
377 }
378 node = node->xmlChildrenNode;
379 while (node != NULL)
380 {
381 // Get the EditionEntry with the default flag
382 if (!xmlStrcmp(node->name, (const xmlChar *) "EditionEntry")
383 && xml_get_bool(doc, node, "EditionFlagDefault", FALSE))
384 break;
385 node = node->next;
386 }
387 if (node == NULL)
388 {
389 // Get the first EditionEntry
390 node = xmlDocGetRootElement(doc);
391 node = xml_get_child_node(node, "EditionEntry");
392 }
393 chapter_list = xml_get_all_paths(doc, node, "./ChapterAtom");
394 if (chapter_list == NULL)
395 {
396 ghb_log("%s has no chapters.", file);
397 xmlFreeDoc(doc);
398 return FALSE;
399 }
400 dest = ghb_get_job_dest_settings(ud->settings);
401 chapter_array = ghb_dict_get(dest, "ChapterList");
402 nodeset = chapter_list->nodesetval;
403 for (int i=0; i < nodeset->nodeNr; i++)
404 {
405 if (!xml_get_bool(doc, nodeset->nodeTab[i], "ChapterFlagEnabled", TRUE))
406 continue; // Skip disabled chapters
407
408 chapter = ghb_array_get(chapter_array, i);
409 if (chapter == NULL)
410 break;
411
412 node = xml_get_child_node(nodeset->nodeTab[i], "ChapterDisplay");

Callers 1

Calls 8

ghb_logFunction · 0.85
xml_get_boolFunction · 0.85
xml_get_child_nodeFunction · 0.85
xml_get_all_pathsFunction · 0.85
xml_get_dataFunction · 0.85
ghb_dict_set_stringFunction · 0.85

Tested by

no test coverage detected