AddMediaResult.cc 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2009-2017 Alibaba Cloud All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include <alibabacloud/mts/model/AddMediaResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Mts;
  19. using namespace AlibabaCloud::Mts::Model;
  20. AddMediaResult::AddMediaResult() :
  21. ServiceResult()
  22. {}
  23. AddMediaResult::AddMediaResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. AddMediaResult::~AddMediaResult()
  29. {}
  30. void AddMediaResult::parse(const std::string &payload)
  31. {
  32. Json::Reader reader;
  33. Json::Value value;
  34. reader.parse(payload, value);
  35. setRequestId(value["RequestId"].asString());
  36. auto mediaNode = value["Media"];
  37. if(!mediaNode["MediaId"].isNull())
  38. media_.mediaId = mediaNode["MediaId"].asString();
  39. if(!mediaNode["Title"].isNull())
  40. media_.title = mediaNode["Title"].asString();
  41. if(!mediaNode["Description"].isNull())
  42. media_.description = mediaNode["Description"].asString();
  43. if(!mediaNode["CoverURL"].isNull())
  44. media_.coverURL = mediaNode["CoverURL"].asString();
  45. if(!mediaNode["CateId"].isNull())
  46. media_.cateId = std::stol(mediaNode["CateId"].asString());
  47. if(!mediaNode["Duration"].isNull())
  48. media_.duration = mediaNode["Duration"].asString();
  49. if(!mediaNode["Format"].isNull())
  50. media_.format = mediaNode["Format"].asString();
  51. if(!mediaNode["Size"].isNull())
  52. media_.size = mediaNode["Size"].asString();
  53. if(!mediaNode["Bitrate"].isNull())
  54. media_.bitrate = mediaNode["Bitrate"].asString();
  55. if(!mediaNode["Width"].isNull())
  56. media_.width = mediaNode["Width"].asString();
  57. if(!mediaNode["Height"].isNull())
  58. media_.height = mediaNode["Height"].asString();
  59. if(!mediaNode["Fps"].isNull())
  60. media_.fps = mediaNode["Fps"].asString();
  61. if(!mediaNode["PublishState"].isNull())
  62. media_.publishState = mediaNode["PublishState"].asString();
  63. if(!mediaNode["CensorState"].isNull())
  64. media_.censorState = mediaNode["CensorState"].asString();
  65. if(!mediaNode["CreationTime"].isNull())
  66. media_.creationTime = mediaNode["CreationTime"].asString();
  67. auto fileNode = mediaNode["File"];
  68. if(!fileNode["URL"].isNull())
  69. media_.file.uRL = fileNode["URL"].asString();
  70. if(!fileNode["State"].isNull())
  71. media_.file.state = fileNode["State"].asString();
  72. auto allTags = mediaNode["Tags"]["Tag"];
  73. for (auto value : allTags)
  74. media_.tags.push_back(value.asString());
  75. auto allRunIdList = mediaNode["RunIdList"]["RunId"];
  76. for (auto value : allRunIdList)
  77. media_.runIdList.push_back(value.asString());
  78. }
  79. AddMediaResult::Media AddMediaResult::getMedia()const
  80. {
  81. return media_;
  82. }