Tidy up a few details with custom filenames.
authorCarl Hetherington <cth@carlh.net>
Tue, 16 Aug 2016 15:24:33 +0000 (16:24 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 Aug 2016 15:24:33 +0000 (16:24 +0100)
cscript
src/lib/cinema_kdms.cc
src/lib/config.cc
src/lib/screen_kdm.cc
src/lib/util.cc
src/wx/config_dialog.cc
src/wx/kdm_output_panel.cc
src/wx/name_format_editor.cc
src/wx/name_format_editor.h

diff --git a/cscript b/cscript
index cc07de56c486337f208593721e3a3381d618529f..9dda13d3a7958dff48993bbfa764ab2548793a71 100644 (file)
--- a/cscript
+++ b/cscript
@@ -237,7 +237,7 @@ def dependencies(target):
         ffmpeg_options = {}
 
     return (('ffmpeg-cdist', '1d4a1a4', ffmpeg_options),
-            ('libdcp', '06f0ba1'),
+            ('libdcp', '81ed0eb'),
             ('libsub', '067c21c'))
 
 def configure_options(target):
index c05dd613857db93776e1d6a288e9d7d2fd343e8c..6a0349b3125cb97052bc6d8fc0607052a3218c5d 100644 (file)
@@ -64,7 +64,7 @@ CinemaKDMs::make_zip_file (boost::filesystem::path zip_file, dcp::NameFormat nam
                }
 
                name_values['s'] = i.screen->name;
-               string const name = name_format.get(name_values) + ".xml";
+               string const name = name_format.get(name_values, ".xml");
                if (zip_add (zip, name.c_str(), source) == -1) {
                        throw runtime_error ("failed to add KDM to ZIP archive");
                }
@@ -128,7 +128,7 @@ CinemaKDMs::write_zip_files (
        BOOST_FOREACH (CinemaKDMs const & i, cinema_kdms) {
                boost::filesystem::path path = directory;
                name_values['c'] = i.cinema->name;
-               path /= name_format.get(name_values) + ".zip";
+               path /= name_format.get(name_values, ".zip");
                i.make_zip_file (path, name_format, name_values);
        }
 }
@@ -189,7 +189,7 @@ CinemaKDMs::email (
                        email.add_bcc (config->kdm_bcc ());
                }
 
-               email.add_attachment (zip_file, name_format.get(name_values) + ".zip", "application/zip");
+               email.add_attachment (zip_file, name_format.get(name_values, ".zip"), "application/zip");
 
                Config* c = Config::instance ();
 
index b5e4b4d008e317bb4e282e3f9f6e5e0363209cd3..5df45ea082854d36ccf04cf0f2e91d53d4279d5b 100644 (file)
@@ -111,8 +111,8 @@ Config::set_defaults ()
        _cinemas_file = path ("cinemas.xml");
        _show_hints_before_make_dcp = true;
        _kdm_filename_format = dcp::NameFormat ("KDM %f %c %s");
-       _dcp_metadata_filename_format = dcp::NameFormat ("%t_%i");
-       _dcp_asset_filename_format = dcp::NameFormat ("%t_%i");
+       _dcp_metadata_filename_format = dcp::NameFormat ("%t");
+       _dcp_asset_filename_format = dcp::NameFormat ("%t");
 
        _allowed_dcp_frame_rates.clear ();
        _allowed_dcp_frame_rates.push_back (24);
index 129e64aeee5b7e88de8bcccd512cdfa8b98c796d..182d03bb071c7d8cd632303ab76357e15272ed5d 100644 (file)
@@ -41,7 +41,7 @@ ScreenKDM::write_files (list<ScreenKDM> screen_kdms, boost::filesystem::path dir
        BOOST_FOREACH (ScreenKDM const & i, screen_kdms) {
                name_values['c'] = i.screen->cinema->name;
                name_values['s'] = i.screen->name;
-               boost::filesystem::path out = directory / (name_format.get(name_values) + ".xml");
+               boost::filesystem::path out = directory / (name_format.get(name_values, ".xml"));
                i.kdm.as_xml (out);
        }
 }
index d20fd7dc7b0f4d94cb830dfaf6db4d07683d446d..704d4aa9dbb5744e0d1d16af8cb8594fa656ac9c 100644 (file)
@@ -619,13 +619,12 @@ video_asset_filename (shared_ptr<dcp::PictureAsset> asset, int reel_index, int r
 {
        dcp::NameFormat::Map values;
        values['t'] = "j2c";
-       values['i'] = asset->id();
        values['r'] = raw_convert<string> (reel_index + 1);
        values['n'] = raw_convert<string> (reel_count);
        if (summary) {
                values['c'] = summary.get();
        }
-       return Config::instance()->dcp_asset_filename_format().get(values) + ".mxf";
+       return Config::instance()->dcp_asset_filename_format().get(values, "_" + asset->id() + ".mxf");
 }
 
 string
@@ -633,13 +632,12 @@ audio_asset_filename (shared_ptr<dcp::SoundAsset> asset, int reel_index, int ree
 {
        dcp::NameFormat::Map values;
        values['t'] = "pcm";
-       values['i'] = asset->id();
        values['r'] = raw_convert<string> (reel_index + 1);
        values['n'] = raw_convert<string> (reel_count);
        if (summary) {
                values['c'] = summary.get();
        }
-       return Config::instance()->dcp_asset_filename_format().get(values) + ".mxf";
+       return Config::instance()->dcp_asset_filename_format().get(values, "_" + asset->id() + ".mxf");
 }
 
 float
index cb9f4669b8c7a0cfa7057b2606e7a73c9f10d969..c18cf3c92eae46e788f573182d3772bbb4d42578 100644 (file)
@@ -1440,13 +1440,11 @@ private:
                        add_top_aligned_label_to_sizer (table, _panel, _("DCP metadata filename format"));
                        dcp::NameFormat::Map titles;
                        titles['t'] = "type (cpl/pkl)";
-                       titles['i'] = "unique ID";
-                       titles['c'] = "content filename";
                        dcp::NameFormat::Map examples;
                        examples['t'] = "cpl";
-                       examples['i'] = "eb1c112c-ca3c-4ae6-9263-c6714ff05d64";
-                       examples['c'] = "myfile.mp4";
-                       _dcp_metadata_filename_format = new NameFormatEditor (_panel, Config::instance()->dcp_metadata_filename_format(), titles, examples);
+                       _dcp_metadata_filename_format = new NameFormatEditor (
+                               _panel, Config::instance()->dcp_metadata_filename_format(), titles, examples, "_eb1c112c-ca3c-4ae6-9263-c6714ff05d64.xml"
+                               );
                        table->Add (_dcp_metadata_filename_format->panel(), 1, wxEXPAND | wxALL);
                }
 
@@ -1454,17 +1452,17 @@ private:
                        add_top_aligned_label_to_sizer (table, _panel, _("DCP asset filename format"));
                        dcp::NameFormat::Map titles;
                        titles['t'] = "type (j2c/pcm/sub)";
-                       titles['i'] = "unique ID";
                        titles['r'] = "reel number";
                        titles['n'] = "number of reels";
                        titles['c'] = "content filename";
                        dcp::NameFormat::Map examples;
                        examples['t'] = "j2c";
-                       examples['i'] = "eb1c112c-ca3c-4ae6-9263-c6714ff05d64";
                        examples['r'] = "1";
                        examples['n'] = "4";
                        examples['c'] = "myfile.mp4";
-                       _dcp_asset_filename_format = new NameFormatEditor (_panel, Config::instance()->dcp_asset_filename_format(), titles, examples);
+                       _dcp_asset_filename_format = new NameFormatEditor (
+                               _panel, Config::instance()->dcp_asset_filename_format(), titles, examples, "_eb1c112c-ca3c-4ae6-9263-c6714ff05d64.mxf"
+                               );
                        table->Add (_dcp_asset_filename_format->panel(), 1, wxEXPAND | wxALL);
                }
 
index 537cf66523fd1c5d0704bcbef286e5f99d1624af..4130e4938b1c4e486657f4441b4811e278fcd2ed 100644 (file)
@@ -68,7 +68,7 @@ KDMOutputPanel::KDMOutputPanel (wxWindow* parent, bool interop)
        ex['s'] = "Screen 1";
        ex['b'] = "2012/03/15 12:30";
        ex['e'] = "2012/03/22 02:30";
-       _filename_format = new NameFormatEditor (this, Config::instance()->kdm_filename_format(), titles, ex);
+       _filename_format = new NameFormatEditor (this, Config::instance()->kdm_filename_format(), titles, ex, ".xml");
        table->Add (_filename_format->panel(), 1, wxEXPAND);
 
        _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
index 7d09158962d3bde47554c98f18fa0ccc42d6d123..160a554c01d3289216f057a27b0dfd7e51c9f1c0 100644 (file)
 #include "name_format_editor.h"
 #include "wx_util.h"
 
-NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples)
+using std::string;
+
+NameFormatEditor::NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples, string suffix)
        : _panel (new wxPanel (parent))
        , _example (new wxStaticText (_panel, wxID_ANY, ""))
        , _sizer (new wxBoxSizer (wxVERTICAL))
        , _specification (new wxTextCtrl (_panel, wxID_ANY, ""))
        , _name (name)
        , _examples (examples)
+       , _suffix (suffix)
 {
        _sizer->Add (_specification, 0, wxEXPAND, DCPOMATIC_SIZER_Y_GAP);
        _sizer->Add (_example, 0, wxBOTTOM, DCPOMATIC_SIZER_Y_GAP);
@@ -61,7 +64,7 @@ NameFormatEditor::update_example ()
 {
        _name.set_specification (wx_to_std (_specification->GetValue ()));
 
-       wxString example = wxString::Format (_("e.g. %s"), _name.get (_examples));
+       wxString example = wxString::Format (_("e.g. %s"), _name.get (_examples, _suffix));
        wxString wrapped;
        for (size_t i = 0; i < example.Length(); ++i) {
                if (i > 0 && (i % 40) == 0) {
index 204de76d3a943d6f438d8b9b2ad6026002284d0a..2ae3f5e930911e887990088b3a848a717c29f2a8 100644 (file)
@@ -30,7 +30,7 @@
 class NameFormatEditor
 {
 public:
-       NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples);
+       NameFormatEditor (wxWindow* parent, dcp::NameFormat name, dcp::NameFormat::Map titles, dcp::NameFormat::Map examples, std::string suffix);
 
        wxPanel* panel () const {
                return _panel;
@@ -54,6 +54,7 @@ private:
 
        dcp::NameFormat _name;
        dcp::NameFormat::Map _examples;
+       std::string _suffix;
 };
 
 #endif