Browse Source

content directory: playlist videos in metadata

Mokhtar Naamani 4 years ago
parent
commit
41af8a4ff0

+ 6 - 0
content-metadata-protobuf/compiled/proto/Playlist_pb.d.ts

@@ -9,6 +9,11 @@ export class PlaylistMetadata extends jspb.Message {
   getTitle(): string | undefined;
   setTitle(value: string): void;
 
+  clearVideosList(): void;
+  getVideosList(): Array<number>;
+  setVideosList(value: Array<number>): void;
+  addVideos(value: number, index?: number): number;
+
   serializeBinary(): Uint8Array;
   toObject(includeInstance?: boolean): PlaylistMetadata.AsObject;
   static toObject(includeInstance: boolean, msg: PlaylistMetadata): PlaylistMetadata.AsObject;
@@ -22,6 +27,7 @@ export class PlaylistMetadata extends jspb.Message {
 export namespace PlaylistMetadata {
   export type AsObject = {
     title?: string,
+    videosList: Array<number>,
   }
 }
 

+ 60 - 2
content-metadata-protobuf/compiled/proto/Playlist_pb.js

@@ -26,7 +26,7 @@ goog.exportSymbol('proto.PlaylistMetadata', null, global);
  * @constructor
  */
 proto.PlaylistMetadata = function(opt_data) {
-  jspb.Message.initialize(this, opt_data, 0, -1, null, null);
+  jspb.Message.initialize(this, opt_data, 0, -1, proto.PlaylistMetadata.repeatedFields_, null);
 };
 goog.inherits(proto.PlaylistMetadata, jspb.Message);
 if (goog.DEBUG && !COMPILED) {
@@ -37,6 +37,13 @@ if (goog.DEBUG && !COMPILED) {
   proto.PlaylistMetadata.displayName = 'proto.PlaylistMetadata';
 }
 
+/**
+ * List of repeated fields within this message type.
+ * @private {!Array<number>}
+ * @const
+ */
+proto.PlaylistMetadata.repeatedFields_ = [2];
+
 
 
 if (jspb.Message.GENERATE_TO_OBJECT) {
@@ -68,7 +75,8 @@ proto.PlaylistMetadata.prototype.toObject = function(opt_includeInstance) {
  */
 proto.PlaylistMetadata.toObject = function(includeInstance, msg) {
   var f, obj = {
-    title: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f
+    title: (f = jspb.Message.getField(msg, 1)) == null ? undefined : f,
+    videosList: (f = jspb.Message.getRepeatedField(msg, 2)) == null ? undefined : f
   };
 
   if (includeInstance) {
@@ -109,6 +117,12 @@ proto.PlaylistMetadata.deserializeBinaryFromReader = function(msg, reader) {
       var value = /** @type {string} */ (reader.readString());
       msg.setTitle(value);
       break;
+    case 2:
+      var values = /** @type {!Array<number>} */ (reader.isDelimited() ? reader.readPackedUint64() : [reader.readUint64()]);
+      for (var i = 0; i < values.length; i++) {
+        msg.addVideos(values[i]);
+      }
+      break;
     default:
       reader.skipField();
       break;
@@ -145,6 +159,13 @@ proto.PlaylistMetadata.serializeBinaryToWriter = function(message, writer) {
       f
     );
   }
+  f = message.getVideosList();
+  if (f.length > 0) {
+    writer.writeRepeatedUint64(
+      2,
+      f
+    );
+  }
 };
 
 
@@ -184,4 +205,41 @@ proto.PlaylistMetadata.prototype.hasTitle = function() {
 };
 
 
+/**
+ * repeated uint64 videos = 2;
+ * @return {!Array<number>}
+ */
+proto.PlaylistMetadata.prototype.getVideosList = function() {
+  return /** @type {!Array<number>} */ (jspb.Message.getRepeatedField(this, 2));
+};
+
+
+/**
+ * @param {!Array<number>} value
+ * @return {!proto.PlaylistMetadata} returns this
+ */
+proto.PlaylistMetadata.prototype.setVideosList = function(value) {
+  return jspb.Message.setField(this, 2, value || []);
+};
+
+
+/**
+ * @param {number} value
+ * @param {number=} opt_index
+ * @return {!proto.PlaylistMetadata} returns this
+ */
+proto.PlaylistMetadata.prototype.addVideos = function(value, opt_index) {
+  return jspb.Message.addToRepeatedField(this, 2, value, opt_index);
+};
+
+
+/**
+ * Clears the list making it empty but non-null.
+ * @return {!proto.PlaylistMetadata} returns this
+ */
+proto.PlaylistMetadata.prototype.clearVideosList = function() {
+  return this.setVideosList([]);
+};
+
+
 goog.object.extend(exports, proto);

+ 1 - 0
content-metadata-protobuf/doc/index.md

@@ -132,6 +132,7 @@
 | Field | Type | Label | Description |
 | ----- | ---- | ----- | ----------- |
 | title | [string](#string) | optional |  |
+| videos | [uint64](#uint64) | repeated | Videos in the playlist |
 
 
 

+ 2 - 0
content-metadata-protobuf/proto/Playlist.proto

@@ -2,4 +2,6 @@ syntax = "proto2";
 
 message PlaylistMetadata {
     optional string title = 1;
+    // Videos in the playlist
+    repeated uint64 videos = 2;
 }

+ 4 - 7
runtime-modules/content/src/lib.rs

@@ -275,14 +275,11 @@ pub struct VideoUpdateParameters {
 /// A video which belongs to a channel. A video may be part of a series or playlist.
 #[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
 #[derive(Encode, Decode, Default, Clone, PartialEq, Eq, Debug)]
-pub struct Video<ChannelId, SeriesId, PlaylistId> {
+pub struct Video<ChannelId, SeriesId> {
     in_channel: ChannelId,
-    // keep track of which seasons and playlists which reference the video
+    // keep track of which season the video is in if it is an 'episode'
     // - prevent removing a video if it is in a season (because order is important)
-    // - remove from playlist on deletion
-    in_series: Vec<SeriesId>,
-    in_playlists: Vec<PlaylistId>,
-
+    in_series: Option<SeriesId>,
     /// Whether the curators have censored the video or not.
     is_censored: bool,
     /// Whether the curators have chosen to feature the video or not.
@@ -426,7 +423,7 @@ decl_storage! {
 
         pub ChannelCategoryById get(fn channel_category_by_id): map hasher(blake2_128_concat) T::ChannelCategoryId => ChannelCategory;
 
-        pub VideoById get(fn video_by_id): map hasher(blake2_128_concat) T::VideoId => Video<T::ChannelId, T::SeriesId, T::PlaylistId>;
+        pub VideoById get(fn video_by_id): map hasher(blake2_128_concat) T::VideoId => Video<T::ChannelId, T::SeriesId>;
 
         pub VideoCategoryById get(fn video_category_by_id): map hasher(blake2_128_concat) T::VideoCategoryId => VideoCategory;
 

+ 1 - 2
types/src/content/index.ts

@@ -83,8 +83,7 @@ export class VideoCategoryUpdateParameters extends JoyStructDecorated({
 
 export class Video extends JoyStructDecorated({
   in_channel: ChannelId,
-  in_series: Vec.with(SeriesId),
-  in_playlists: Vec.with(PlaylistId),
+  in_series: Option.with(SeriesId),
   is_censored: bool,
   is_featured: bool,
 }) {}