GetVideoInfosResult.cc 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/vod/model/GetVideoInfosResult.h>
  17. #include <json/json.h>
  18. using namespace AlibabaCloud::Vod;
  19. using namespace AlibabaCloud::Vod::Model;
  20. GetVideoInfosResult::GetVideoInfosResult() :
  21. ServiceResult()
  22. {}
  23. GetVideoInfosResult::GetVideoInfosResult(const std::string &payload) :
  24. ServiceResult()
  25. {
  26. parse(payload);
  27. }
  28. GetVideoInfosResult::~GetVideoInfosResult()
  29. {}
  30. void GetVideoInfosResult::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 allVideoList = value["VideoList"]["Video"];
  37. for (auto value : allVideoList)
  38. {
  39. Video videoListObject;
  40. if(!value["VideoId"].isNull())
  41. videoListObject.videoId = value["VideoId"].asString();
  42. if(!value["Title"].isNull())
  43. videoListObject.title = value["Title"].asString();
  44. if(!value["Tags"].isNull())
  45. videoListObject.tags = value["Tags"].asString();
  46. if(!value["Status"].isNull())
  47. videoListObject.status = value["Status"].asString();
  48. if(!value["Size"].isNull())
  49. videoListObject.size = std::stol(value["Size"].asString());
  50. if(!value["Duration"].isNull())
  51. videoListObject.duration = std::stof(value["Duration"].asString());
  52. if(!value["Description"].isNull())
  53. videoListObject.description = value["Description"].asString();
  54. if(!value["ModificationTime"].isNull())
  55. videoListObject.modificationTime = value["ModificationTime"].asString();
  56. if(!value["CreationTime"].isNull())
  57. videoListObject.creationTime = value["CreationTime"].asString();
  58. if(!value["CoverURL"].isNull())
  59. videoListObject.coverURL = value["CoverURL"].asString();
  60. if(!value["CateId"].isNull())
  61. videoListObject.cateId = std::stol(value["CateId"].asString());
  62. if(!value["CateName"].isNull())
  63. videoListObject.cateName = value["CateName"].asString();
  64. if(!value["DownloadSwitch"].isNull())
  65. videoListObject.downloadSwitch = value["DownloadSwitch"].asString();
  66. if(!value["TemplateGroupId"].isNull())
  67. videoListObject.templateGroupId = value["TemplateGroupId"].asString();
  68. if(!value["PreprocessStatus"].isNull())
  69. videoListObject.preprocessStatus = value["PreprocessStatus"].asString();
  70. if(!value["StorageLocation"].isNull())
  71. videoListObject.storageLocation = value["StorageLocation"].asString();
  72. if(!value["RegionId"].isNull())
  73. videoListObject.regionId = value["RegionId"].asString();
  74. if(!value["CustomMediaInfo"].isNull())
  75. videoListObject.customMediaInfo = value["CustomMediaInfo"].asString();
  76. if(!value["AppId"].isNull())
  77. videoListObject.appId = value["AppId"].asString();
  78. auto allThumbnailList = value["ThumbnailList"]["Thumbnail"];
  79. for (auto value : allThumbnailList)
  80. {
  81. Video::Thumbnail thumbnailListObject;
  82. if(!value["URL"].isNull())
  83. thumbnailListObject.uRL = value["URL"].asString();
  84. videoListObject.thumbnailList.push_back(thumbnailListObject);
  85. }
  86. auto allSnapshots = value["Snapshots"]["Snapshot"];
  87. for (auto value : allSnapshots)
  88. videoListObject.snapshots.push_back(value.asString());
  89. videoList_.push_back(videoListObject);
  90. }
  91. auto allNonExistVideoIds = value["NonExistVideoIds"]["VideoId"];
  92. for (const auto &item : allNonExistVideoIds)
  93. nonExistVideoIds_.push_back(item.asString());
  94. }
  95. std::vector<GetVideoInfosResult::Video> GetVideoInfosResult::getVideoList()const
  96. {
  97. return videoList_;
  98. }
  99. std::vector<std::string> GetVideoInfosResult::getNonExistVideoIds()const
  100. {
  101. return nonExistVideoIds_;
  102. }