Browse Source

Fix channel command

iorveth 4 years ago
parent
commit
94df1b71f1
1 changed files with 23 additions and 20 deletions
  1. 23 20
      cli/src/commands/content/channel.ts

+ 23 - 20
cli/src/commands/content/channel.ts

@@ -13,29 +13,32 @@ export default class ChannelCommand extends ContentDirectoryCommandBase {
 
   async run() {
     const { channelId } = this.parse(ChannelCommand).args
-    const [id, aChannel] = await this.channelEntryById(channelId)
+    const channel = await this.getApi().channelById(channelId)
+    if (channel) {
+      displayCollapsedRow({
+        'ID': channelId.toString(),
+        'Owner': JSON.stringify(channel.owner.toJSON()),
+        'IsCensored': channel.is_censored.toString(),
+        'RewardAccount': channel.reward_account ? channel.reward_account.toString() : 'NONE',
+      })
 
-    displayCollapsedRow({
-      'ID': id.toString(),
-      'Owner': JSON.stringify(aChannel.owner.toJSON()),
-      'IsCensored': aChannel.is_censored.toString(),
-      'RewardAccount': aChannel.reward_account? aChannel.reward_account.toString() : 'NONE'
-    })
+      displayHeader(`Media`)
 
-    displayHeader(`Media`)
+      displayCollapsedRow({
+        'NumberOfVideos': channel.videos.length,
+        'NumberOfPlaylists': channel.playlists.length,
+        'NumberOfSeries': channel.series.length,
+      })
 
-    displayCollapsedRow({
-      'NumberOfVideos': aChannel.videos.length,
-      'NumberOfPlaylists': aChannel.playlists.length,
-      'NumberOfSeries': aChannel.series.length,
-    })
+      displayHeader(`MediaData`)
 
-    displayHeader(`MediaData`)
-
-    displayCollapsedRow({
-      'Videos': JSON.stringify(aChannel.videos.toJSON()),
-      'Playlists': JSON.stringify(aChannel.playlists.toJSON()),
-      'Series': JSON.stringify(aChannel.series.toJSON()),
-    })
+      displayCollapsedRow({
+        'Videos': JSON.stringify(channel.videos.toJSON()),
+        'Playlists': JSON.stringify(channel.playlists.toJSON()),
+        'Series': JSON.stringify(channel.series.toJSON()),
+      })
+    } else {
+      this.error(`Channel not found by channel id: "${channelId}"!`)
+    }
   }
 }