You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.1 KiB

  1. From 1ee40116ece90a5504cd33a23d6bc7002d00b68a Mon Sep 17 00:00:00 2001
  2. From: Ian Whyman <ian.whyman@spin.pm>
  3. Date: Tue, 8 Mar 2022 17:36:37 +0000
  4. Subject: [PATCH] Fix default tag matches with ffmpeg_handler
  5. Some of the keys were uppercase e.g. ARTIST when returned from the FLAC
  6. parser, so lowercase the keys first.
  7. Fixes: https://github.com/gerbera/gerbera/issues/2176
  8. ---
  9. src/metadata/ffmpeg_handler.cc | 9 ++++++---
  10. 1 file changed, 6 insertions(+), 3 deletions(-)
  11. --- a/src/metadata/ffmpeg_handler.cc
  12. +++ b/src/metadata/ffmpeg_handler.cc
  13. @@ -93,8 +93,9 @@ void FfmpegHandler::addFfmpegMetadataFie
  14. auto sc = StringConverter::m2i(CFG_IMPORT_LIBOPTS_FFMPEG_CHARSET, item->getLocation(), config);
  15. while ((e = av_dict_get(pFormatCtx->metadata, "", e, AV_DICT_IGNORE_SUFFIX))) {
  16. - std::string key = e->key;
  17. + std::string key = toLower(e->key);
  18. std::string value = e->value;
  19. + log_debug("FFMpeg tag: {}: {}", key, value);
  20. auto it = specialPropertyMap.find(e->key);
  21. if (it != specialPropertyMap.end()) {
  22. // only use ffmpeg meta data if not found by other handler
  23. @@ -105,7 +106,9 @@ void FfmpegHandler::addFfmpegMetadataFie
  24. }
  25. }
  26. auto pIt = std::find_if(propertyMap.begin(), propertyMap.end(),
  27. - [&](auto&& p) { return p.second == key && item->getMetaData(p.first).empty(); });
  28. + [&](auto&& p) {
  29. + return p.second == key && item->getMetaData(p.first).empty();
  30. + });
  31. if (pIt != propertyMap.end()) {
  32. log_debug("Identified default metadata '{}': {}", pIt->second, value);
  33. const auto field = pIt->first;
  34. @@ -128,7 +131,7 @@ void FfmpegHandler::addFfmpegMetadataFie
  35. constexpr auto field = M_CREATION_DATE;
  36. if (item->getMetaData(field).empty()) {
  37. log_debug("Identified metadata 'creation_time': {}", e->value);
  38. - std::tm tmWork;
  39. + std::tm tmWork {};
  40. if (strptime(e->value, "%Y-%m-%dT%T.000000%Z", &tmWork)) {
  41. // convert creation_time to local time
  42. auto utcTime = timegm(&tmWork);