X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Ftools%2Fdcpomatic_kdm_cli.cc;h=f0097d7de38cd14b06256009d174ca60100f8a96;hb=1a693725f9a8cc6ba58f65b2f1ef03255d295f23;hp=df828416f3fe5ad3e8d6ef3148a768ba7cf9ac6e;hpb=b93599eb990cdad18c3de47d62575031ed688cea;p=dcpomatic.git diff --git a/src/tools/dcpomatic_kdm_cli.cc b/src/tools/dcpomatic_kdm_cli.cc index df828416f..f0097d7de 100644 --- a/src/tools/dcpomatic_kdm_cli.cc +++ b/src/tools/dcpomatic_kdm_cli.cc @@ -29,7 +29,6 @@ #include "lib/config.h" #include "lib/exceptions.h" #include "lib/emailer.h" -#include "lib/safe_stringstream.h" #include #include #include @@ -40,6 +39,7 @@ using std::cerr; using std::list; using std::vector; using boost::shared_ptr; +using boost::optional; static void help () @@ -82,10 +82,10 @@ time_from_string (string t) static boost::posix_time::time_duration duration_from_string (string d) { - SafeStringStream s (d); int N; - string unit; - s >> N >> unit; + char unit_buf[64] = "\0"; + sscanf (d.c_str(), "%d %63s", &N, unit_buf); + string const unit (unit_buf); if (N == 0) { cerr << "Could not understand duration \"" << d << "\"\n"; @@ -218,7 +218,7 @@ int main (int argc, char* argv[]) valid_to = valid_from.get() + duration_from_string (duration_string); } - string const film_dir = argv[optind]; + boost::filesystem::path const film_dir = argv[optind]; dcpomatic_setup_path_encoding (); dcpomatic_setup (); @@ -231,7 +231,7 @@ int main (int argc, char* argv[]) cout << "Read film " << film->name () << "\n"; } } catch (std::exception& e) { - cerr << program_name << ": error reading film `" << film_dir << "' (" << e.what() << ")\n"; + cerr << program_name << ": error reading film `" << film_dir.string() << "' (" << e.what() << ")\n"; exit (EXIT_FAILURE); } @@ -284,19 +284,29 @@ int main (int argc, char* argv[]) output = "."; } + dcp::NameFormat::Map values; + values['f'] = film->name(); + values['b'] = dcp::LocalTime(valid_from.get()).date() + " " + dcp::LocalTime(valid_from.get()).time_of_day(); + values['e'] = dcp::LocalTime(valid_to.get()).date() + " " + dcp::LocalTime(valid_to.get()).time_of_day(); + try { list screen_kdms = film->make_kdms ( (*i)->screens(), cpl, valid_from.get(), valid_to.get(), formulation ); if (zip) { - CinemaKDMs::write_zip_files (film->name(), CinemaKDMs::collect (screen_kdms), output); + CinemaKDMs::write_zip_files ( + CinemaKDMs::collect (screen_kdms), + output, + Config::instance()->kdm_filename_format(), + values + ); if (verbose) { cout << "Wrote ZIP files to " << output << "\n"; } } else { - ScreenKDM::write_files (film->name(), screen_kdms, output); + ScreenKDM::write_files (screen_kdms, output, Config::instance()->kdm_filename_format(), values); if (verbose) { cout << "Wrote KDM files to " << output << "\n";