Make the value used for 'f' in KDM names consistent (#1657).
authorCarl Hetherington <cth@carlh.net>
Thu, 10 Mar 2022 22:00:43 +0000 (23:00 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 16 Mar 2022 13:25:54 +0000 (14:25 +0100)
Before it was mostly the film name, but this is confusing when a
single film contains multiple CPLs.

src/lib/dkdm_recipient.cc
src/lib/film.cc
src/lib/film.h
src/lib/kdm_cli.cc
src/lib/screen.cc
src/tools/dcpomatic_kdm.cc
src/wx/kdm_output_panel.h
test/kdm_naming_test.cc

index 30c3075691d4baa1a81130ade548227d63c84e35..b15487c8ab4935864334ec27957ba0b4fc5ba4a2 100644 (file)
@@ -86,7 +86,7 @@ kdm_for_dkdm_recipient (
                        );
 
        dcp::NameFormat::Map name_values;
-       name_values['f'] = film->name();
+       name_values['f'] = kdm.content_title_text();
        name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
        name_values['e'] = end.date() + " " + end.time_of_day(true, false);
        name_values['i'] = kdm.cpl_id();
index 5e99e466c4375a04d90484708f11d294321b8c68..d9ed8c53000b8430c0f02f3838b6f4bdf59b09cb 100644 (file)
@@ -1283,6 +1283,7 @@ Film::set_isdcf_date_today ()
        _isdcf_date = boost::gregorian::day_clock::local_day ();
 }
 
+
 boost::filesystem::path
 Film::j2c_path (int reel, Frame frame, Eyes eyes, bool tmp) const
 {
index a1bec3d53b93763a298c467232e1bad28f3d00ec..55bbb406959a65167626c894515ec99833f0b5d9 100644 (file)
@@ -409,6 +409,10 @@ public:
                return _luminance;
        }
 
+       boost::gregorian::date isdcf_date () const {
+               return _isdcf_date;
+       }
+
 
        /* SET */
 
index 0ec648e0489d1a9eb88db033fbfbe14e9d35731d..e89da6e373913757df420164fd494cd37eaf01be 100644 (file)
@@ -374,7 +374,7 @@ from_dkdm (
                        dcp::NameFormat::Map name_values;
                        name_values['c'] = i->cinema ? i->cinema->name : "";
                        name_values['s'] = i->name;
-                       name_values['f'] = dkdm.annotation_text().get_value_or("");
+                       name_values['f'] = kdm.content_title_text();
                        name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
                        name_values['e'] = end.date() + " " + end.time_of_day(true, false);
                        name_values['i'] = kdm.cpl_id();
index 21d7ebf2566bccad3185601eb5325aed8c439a74..a9291e8f05e4fa84bd84158e92c7c419e42766a6 100644 (file)
@@ -109,7 +109,7 @@ kdm_for_screen (
                name_values['c'] = "";
        }
        name_values['s'] = screen->name;
-       name_values['f'] = film->name();
+       name_values['f'] = kdm.content_title_text();
        name_values['b'] = begin.date() + " " + begin.time_of_day(true, false);
        name_values['e'] = end.date() + " " + end.time_of_day(true, false);
        name_values['i'] = kdm.cpl_id();
index 9a65314e52f0c89b8669db11f12857374e30b742..24bd3b4d7f776ad60f369fb1e16cc80b4e2b52a3 100644 (file)
@@ -338,7 +338,7 @@ private:
                                                begin,
                                                end,
                                                decrypted.annotation_text().get_value_or (""),
-                                               decrypted.content_title_text(),
+                                               title,
                                                dcp::LocalTime().as_string()
                                                );
 
index f831fdce0937a44237d3df6f2ba565b2210da690..0025b0072655292f837ccbd424c15bc84e5beebd 100644 (file)
@@ -20,6 +20,7 @@
 
 
 #include "lib/kdm_with_metadata.h"
+#include "wx_util.h"
 #include <dcp/types.h>
 #include <wx/wx.h>
 #include <boost/filesystem.hpp>
index c41d5c31513b481ecbe1dcaa08e151c77d6621db..f53f4aba2102d1987a324400884c628883ac6aef 100644 (file)
@@ -122,7 +122,8 @@ BOOST_AUTO_TEST_CASE (single_kdm_naming_test)
        auto until_time = until.time_of_day (true, false);
        boost::algorithm::replace_all (until_time, ":", "-");
 
-       auto const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
+       auto const dcp_date = boost::gregorian::to_iso_string(film->isdcf_date());
+       auto const ref = String::compose("KDM_Cinema_A_-_Screen_1_-_MyGreatFilm_TST-1_F_XX-XX_MOS_2K_%1_SMPTE_OV_-_%2_%3_-_%4_%5.xml", dcp_date, from.date(), from_time, until.date(), until_time);
        BOOST_CHECK_MESSAGE (boost::filesystem::exists("build/test/single_kdm_naming_test/" + ref), "File " << ref << " not found");
 }
 
@@ -182,8 +183,8 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on(
                path("build/test/directory_kdm_naming_test"),
                dcp::NameFormat("%c - %s - %f - %b - %e"),
 #ifdef DCPOMATIC_WINDOWS
-               /* With %i in the format the path is too long for Windows */
-               dcp::NameFormat("KDM %c - %s - %f - %b - %e"),
+               /* Use a shorter name on Windows so that the paths aren't too long */
+               dcp::NameFormat("KDM %f"),
 #else
                dcp::NameFormat("KDM %c - %s - %f - %b - %e - %i"),
 #endif
@@ -195,38 +196,42 @@ BOOST_AUTO_TEST_CASE (directory_kdm_naming_test, * boost::unit_test::depends_on(
        auto until_time = until.time_of_day (true, false);
        boost::algorithm::replace_all (until_time, ":", "-");
 
+       auto const dcp_date = boost::gregorian::to_iso_string(film->isdcf_date());
+       auto const dcp_name = String::compose("MyGreatFilm_TST-1_F_XX-XX_MOS_2K_%1_SMPTE_OV", dcp_date);
+       auto const common = String::compose("%1_-_%2_%3_-_%4_%5", dcp_name, from.date(), from_time, until.date(), until_time);
+
        path const base = "build/test/directory_kdm_naming_test";
 
-       path dir_a = String::compose("Cinema_A_-_%s_-_my_great_film_-_%1_%2_-_%3_%4", from.date(), from_time, until.date(), until_time);
+       path dir_a = String::compose("Cinema_A_-_%s_-_%1", common);
        BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a), "Directory " << dir_a << " not found");
-       path dir_b = String::compose("Cinema_B_-_%s_-_my_great_film_-_%1_%2_-_%3_%4", from.date(), from_time, until.date(), until_time);
+       path dir_b = String::compose("Cinema_B_-_%s_-_%1", common);
        BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b), "Directory " << dir_b << " not found");
 
 #ifdef DCPOMATIC_WINDOWS
-       path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
+       path ref = String::compose("KDM_%1.xml", dcp_name);
 #else
-       path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id);
+       path ref = String::compose("KDM_Cinema_A_-_Screen_2_-_%1_-_%2.xml", common, cpl_id);
 #endif
        BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found");
 
 #ifdef DCPOMATIC_WINDOWS
-       ref = String::compose("KDM_Cinema_B_-_Screen_X_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
+       ref = String::compose("KDM_%1.xml", dcp_name);
 #else
-       ref = String::compose("KDM_Cinema_B_-_Screen_X_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id);
+       ref = String::compose("KDM_Cinema_B_-_Screen_X_-_%1_-_%2.xml", common, cpl_id);
 #endif
        BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found");
 
 #ifdef DCPOMATIC_WINDOWS
-       ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
+       ref = String::compose("KDM_%1.xml", dcp_name);
 #else
-       ref = String::compose("KDM_Cinema_A_-_Screen_1_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id);
+       ref = String::compose("KDM_Cinema_A_-_Screen_1_-_%1_-_%2.xml", common, cpl_id);
 #endif
        BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_a / ref), "File " << ref << " not found");
 
 #ifdef DCPOMATIC_WINDOWS
-       ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_my_great_film_-_%1_%2_-_%3_%4.xml", from.date(), from_time, until.date(), until_time);
+       ref = String::compose("KDM_%1.xml", dcp_name);
 #else
-       ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_my_great_film_-_%1_%2_-_%3_%4_-_%5.xml", from.date(), from_time, until.date(), until_time, cpl_id);
+       ref = String::compose("KDM_Cinema_B_-_Screen_Z_-_%1_-_%2.xml", common, cpl_id);
 #endif
        BOOST_CHECK_MESSAGE (boost::filesystem::exists(base / dir_b / ref), "File " << ref << " not found");
 }