|
|
@@ -51,6 +51,14 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
initNew(iapPlatformList);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void test() throws Exception {
|
|
|
+ String token = "009970b1323314355756a4158f363be29676d5f0";
|
|
|
+ long videoId = 61073;
|
|
|
+ String albumId = uploadAlbum(videoId, token);
|
|
|
+ System.out.println(albumId);
|
|
|
+ }
|
|
|
+
|
|
|
public void initNew(List<JSONObject> platformList) {
|
|
|
//为广告主账户创建新的字节小程序
|
|
|
//step1 查询表里广告主是否都有自己的字节小程序、
|
|
|
@@ -404,4 +412,66 @@ public class BytedanceProductUpdateServiceImpl implements IBytedanceProductUpdat
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 上传短剧
|
|
|
+ * @param videoId from ly_videos
|
|
|
+ * @return albumId
|
|
|
+ */
|
|
|
+ private String uploadAlbum(long videoId, String appAccessToken){
|
|
|
+ JSONObject video = bytedanceProductUpdateMapper.getVideoInfo(videoId);
|
|
|
+ if (video == null){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ String videoName = video.getString("name");
|
|
|
+ Integer sylloge = video.getInteger("sylloge");//总集数
|
|
|
+ List<JSONObject> videoDetail = bytedanceProductUpdateMapper.getVideoDetail(videoId);
|
|
|
+ if (videoDetail == null || videoDetail.isEmpty()){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject requestBody = new JSONObject();
|
|
|
+ requestBody.put("album_title", videoName);
|
|
|
+ requestBody.put("seq_num", sylloge);
|
|
|
+ requestBody.put("app_id", 1742489802322972L);
|
|
|
+
|
|
|
+ List<JSONObject> videoDetailList = new ArrayList<>();
|
|
|
+ for (JSONObject obj : videoDetail){
|
|
|
+ String videoUrl = obj.getString("url");
|
|
|
+ String title = obj.getString("name");
|
|
|
+ Integer seq = obj.getInteger("sort");
|
|
|
+
|
|
|
+ JSONObject meta = new JSONObject();
|
|
|
+ meta.put("url", videoUrl);
|
|
|
+ meta.put("title", title);
|
|
|
+ meta.put("seq", seq);
|
|
|
+ videoDetailList.add(meta);
|
|
|
+ }
|
|
|
+ requestBody.put("video_meta_mico", videoDetailList);
|
|
|
+
|
|
|
+ String url = "https://api.oceanengine.com/open_api/v3.0/dpa/album/create/";
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("App-Access-Token", appAccessToken);
|
|
|
+ headers.put("Content-Type", "application/json");
|
|
|
+
|
|
|
+ System.out.println(requestBody.toJSONString());
|
|
|
+// return null;
|
|
|
+ String res = HttpUtils.httpPostRequest(url, requestBody, headers);
|
|
|
+ if (res == null || res.isEmpty()){
|
|
|
+ System.out.println("上传短剧失败, 返回null");
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ JSONObject resObj = JSONObject.parseObject(res);
|
|
|
+ int code = resObj.getIntValue("code");
|
|
|
+ if (code != 0){
|
|
|
+ System.out.println("上传短剧失败,code: " + code + ", msg: " + resObj.getString("message"));
|
|
|
+ return null;
|
|
|
+ }else {
|
|
|
+ String albumId = resObj.getJSONObject("data").getString("album_id");
|
|
|
+ return albumId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|