Afrostream / afrostream-back-end

Simple backo for afrostream
1 stars 0 forks source link

import 3 contenus #346

Closed syndr0m closed 7 years ago

syndr0m commented 7 years ago

il faudrait import 3 titres

[4:56]
contentId: 12417, uuid: d8cb27ad-76f0-4095-afad-7ef8f190f23e

[4:56]
contentId: 12418, uuid: b518ca49-47ec-4d58-87ef-a886b02e6c11

[4:57]
contentId: 12419, uuid: a24e43e1-06d8-4755-90b9-3d196e84d3b3

[4:58]
subtitles url pour 12417: http://sources-1.adm.afrostream.net/subtitles/101_CNTM_EPISODE_1_h264_en.vtt, http://sources-1.adm.afrostream.net/subtitles/101_CNTM_EPISODE_1_h264_fr.vtt

[4:58]
subtitles url pour 12418: http://sources-1.adm.afrostream.net/subtitles/102_CNTM_EPISODE_2_h264_en.vtt, http://sources-1.adm.afrostream.net/subtitles/102_CNTM_EPISODE_2_h264_fr.vtt

[4:59]
subtitles pour 12419: http://sources-1.adm.afrostream.net/subtitles/103_CNTM_EPISODE_3_h264_en.vtt, http://sources-1.adm.afrostream.net/subtitles/103_CNTM_EPISODE_3_h264_fr.vtt

syndr0m commented 7 years ago
// to import new contents from PF, duplicate this script & increment manualImportId
var manualImportId = "04";

// import script
var liste = JSON.parse(document.querySelector('pre').innerHTML).filter(function (o) {
  return o.contentId === 12417 ||
             o.contentId === 12418 ||
             o.contentId === 12419;
});
liste.sort(function(a, b) {
   if (a.filename === b.filename) return 0;
   return (a.filename < b.filename) ? -1 : 1;
});
function pad(n, width, z) {
  z = z || '0';
  n = n + '';
  return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
liste.map(function (o,i) { 
  var d = o.duration.split(':'); 
  var duration = parseInt(d[2], 10) + parseInt(d[1], 10)*60 + parseInt(d[0], 0) * 3600; 
  var name = o.filename.split('/').pop().replace('.mp4', '').replace('.mov', '').replace('.mxf', '');
  var encodingId = o.uuid;
  var pfMd5Hash = o.md5Hash;
  var id = "01234567-89ab-cdef-"+manualImportId+"00-000000000"+pad(i, 3);
  var assetId1 = "01234567-89ab-cdef-"+manualImportId+"01-000000000"+pad(i, 3);
  var assetId2 = "01234567-89ab-cdef-"+manualImportId+"02-000000000"+pad(i, 3);
  var assetId3 = "01234567-89ab-cdef-"+manualImportId+"03-000000000"+pad(i, 3);

  return 'INSERT INTO "Videos" ' +
         '("_id", "name", "active", "importId", "encodingId", "drm", "duration", "pfMd5Hash")' +
         'VALUES ' +
         "('"+id+"','"+name+"', true, null, '"+encodingId+"', false, '"+duration+"', '"+pfMd5Hash+"');"+
         'INSERT INTO "Assets" (_id, src, type, "videoId") ' + "VALUES ('"+assetId1+"', '"+ 'https://hw.cdn.afrostream.net/vod/'+name+'/'+encodingId+'.ism/master.m3u8' + "', 'application/vnd.apple.mpegurl', '"+id+"');"+
         'INSERT INTO "Assets" (_id, src, type, "videoId") ' + "VALUES ('"+assetId2+"', '"+ 'https://hw.cdn.afrostream.net/vod/'+name+'/'+encodingId+'.ism/'+encodingId+'.mpd' + "', 'application/dash+xml', '"+id+"');"+
         'INSERT INTO "Assets" (_id, src, type, "videoId") ' + "VALUES ('"+assetId3+"', '"+ 'http://hw.cdn.afrostream.net/vod/'+name+'/'+encodingId+'.ism/MANIFEST' + "', 'application/vnd.ms-sstr+xml', '"+id+"');";
}).join("\n") 
syndr0m commented 7 years ago

pb sur le 1er (duration = 0) => on importe que les 2 derniers

syndr0m commented 7 years ago
// to import new contents from PF, duplicate this script & increment manualImportId
var manualImportId = "04";

// import script
var liste = JSON.parse(document.querySelector('pre').innerHTML).filter(function (o) {
  return  /*o.contentId === 12417 ||*/ o.contentId === 12418 || o.contentId === 12419;
});
liste.sort(function(a, b) {
   if (a.filename === b.filename) return 0;
   return (a.filename < b.filename) ? -1 : 1;
});
function pad(n, width, z) {
  z = z || '0';
  n = n + '';
  return n.length >= width ? n : new Array(width - n.length + 1).join(z) + n;
}
liste.map(function (o,i) { 
  var d = o.duration.split(':'); 
  var duration = parseInt(d[2], 10) + parseInt(d[1], 10)*60 + parseInt(d[0], 0) * 3600; 
  var name = o.filename.split('/').pop().replace('.mp4', '').replace('.mov', '').replace('.mxf', '');
  var encodingId = o.uuid;
  var pfMd5Hash = o.md5Hash;
  var id = "01234567-89ab-cdef-"+manualImportId+"00-000000000"+pad(i, 3);
  var assetId1 = "01234567-89ab-cdef-"+manualImportId+"01-000000000"+pad(i, 3);
  var assetId2 = "01234567-89ab-cdef-"+manualImportId+"02-000000000"+pad(i, 3);
  var assetId3 = "01234567-89ab-cdef-"+manualImportId+"03-000000000"+pad(i, 3);

  return 'INSERT INTO "Videos" ' +
         '("_id", "name", "active", "importId", "encodingId", "drm", "duration", "pfMd5Hash")' +
         'VALUES ' +
         "('"+id+"','"+name+"', true, null, '"+encodingId+"', false, '"+duration+"', '"+pfMd5Hash+"');"+
         'INSERT INTO "Assets" (_id, src, type, "videoId") ' + "VALUES ('"+assetId1+"', '"+ 'https://hw.cdn.afrostream.net/vod/'+name+'/'+encodingId+'.ism/master.m3u8' + "', 'application/vnd.apple.mpegurl', '"+id+"');"+
         'INSERT INTO "Assets" (_id, src, type, "videoId") ' + "VALUES ('"+assetId2+"', '"+ 'https://hw.cdn.afrostream.net/vod/'+name+'/'+encodingId+'.ism/'+encodingId+'.mpd' + "', 'application/dash+xml', '"+id+"');"+
         'INSERT INTO "Assets" (_id, src, type, "videoId") ' + "VALUES ('"+assetId3+"', '"+ 'http://hw.cdn.afrostream.net/vod/'+name+'/'+encodingId+'.ism/MANIFEST' + "', 'application/vnd.ms-sstr+xml', '"+id+"');";
}).join("\n")
syndr0m commented 7 years ago

pb .mov vs .mp4

delete from "Videos" where _id = '01234567-89ab-cdef-0400-000000000000' OR _id = '01234567-89ab-cdef-0400-000000000001';
delete from "Assets" where _id::char varying like '01234567-89ab-cdef-04%'
syndr0m commented 7 years ago

CNTP épisodes 2 & 3

INSERT INTO "Videos" ("_id", "name", "active", "importId", "encodingId", "drm", "duration", "pfMd5Hash")VALUES ('01234567-89ab-cdef-0400-000000000000','102_CNTM_EPISODE_2_h264', true, null, 'b518ca49-47ec-4d58-87ef-a886b02e6c11', false, '2782', '3142befa5482930f0f4f8e7dae0e10be');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0401-000000000000', 'https://hw.cdn.afrostream.net/vod/102_CNTM_EPISODE_2_h264/b518ca49-47ec-4d58-87ef-a886b02e6c11.ism/master.m3u8', 'application/vnd.apple.mpegurl', '01234567-89ab-cdef-0400-000000000000');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0402-000000000000', 'https://hw.cdn.afrostream.net/vod/102_CNTM_EPISODE_2_h264/b518ca49-47ec-4d58-87ef-a886b02e6c11.ism/b518ca49-47ec-4d58-87ef-a886b02e6c11.mpd', 'application/dash+xml', '01234567-89ab-cdef-0400-000000000000');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0403-000000000000', 'http://hw.cdn.afrostream.net/vod/102_CNTM_EPISODE_2_h264/b518ca49-47ec-4d58-87ef-a886b02e6c11.ism/MANIFEST', 'application/vnd.ms-sstr+xml', '01234567-89ab-cdef-0400-000000000000');
INSERT INTO "Videos" ("_id", "name", "active", "importId", "encodingId", "drm", "duration", "pfMd5Hash")VALUES ('01234567-89ab-cdef-0400-000000000001','103_CNTM_EPISODE_3_h264', true, null, 'a24e43e1-06d8-4755-90b9-3d196e84d3b3', false, '2795', 'd1f6bcde77c686ed569ab07f9f88aaa5');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0401-000000000001', 'https://hw.cdn.afrostream.net/vod/103_CNTM_EPISODE_3_h264/a24e43e1-06d8-4755-90b9-3d196e84d3b3.ism/master.m3u8', 'application/vnd.apple.mpegurl', '01234567-89ab-cdef-0400-000000000001');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0402-000000000001', 'https://hw.cdn.afrostream.net/vod/103_CNTM_EPISODE_3_h264/a24e43e1-06d8-4755-90b9-3d196e84d3b3.ism/a24e43e1-06d8-4755-90b9-3d196e84d3b3.mpd', 'application/dash+xml', '01234567-89ab-cdef-0400-000000000001');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0403-000000000001', 'http://hw.cdn.afrostream.net/vod/103_CNTM_EPISODE_3_h264/a24e43e1-06d8-4755-90b9-3d196e84d3b3.ism/MANIFEST', 'application/vnd.ms-sstr+xml', '01234567-89ab-cdef-0400-000000000001');"
syndr0m commented 7 years ago

CNTP épisode 1

INSERT INTO "Videos" ("_id", "name", "active", "importId", "encodingId", "drm", "duration", "pfMd5Hash")VALUES ('01234567-89ab-cdef-0500-000000000000','101_CNTM_EPISODE_1_h264', true, null, 'd8cb27ad-76f0-4095-afad-7ef8f190f23e', false, '0', '0a9ada1fd83e31eb39690f4f82d57175');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0501-000000000000', 'https://hw.cdn.afrostream.net/vod/101_CNTM_EPISODE_1_h264/d8cb27ad-76f0-4095-afad-7ef8f190f23e.ism/master.m3u8', 'application/vnd.apple.mpegurl', '01234567-89ab-cdef-0500-000000000000');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0502-000000000000', 'https://hw.cdn.afrostream.net/vod/101_CNTM_EPISODE_1_h264/d8cb27ad-76f0-4095-afad-7ef8f190f23e.ism/d8cb27ad-76f0-4095-afad-7ef8f190f23e.mpd', 'application/dash+xml', '01234567-89ab-cdef-0500-000000000000');INSERT INTO "Assets" (_id, src, type, "videoId") VALUES ('01234567-89ab-cdef-0503-000000000000', 'http://hw.cdn.afrostream.net/vod/101_CNTM_EPISODE_1_h264/d8cb27ad-76f0-4095-afad-7ef8f190f23e.ism/MANIFEST', 'application/vnd.ms-sstr+xml', '01234567-89ab-cdef-0500-000000000000');
syndr0m commented 7 years ago

done