12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- import { ApiPromise, WsProvider } from '@polkadot/api'
- import { types as joyTypes } from '@joystream/types'
- import { Keyring } from '@polkadot/keyring'
- import { InputParser } from '@joystream/cd-schemas'
- import { VideoEntity } from '@joystream/cd-schemas/types/entities/VideoEntity'
- async function main() {
-
- const provider = new WsProvider('ws://127.0.0.1:9944')
- const api = await ApiPromise.create({ provider, types: joyTypes })
-
- const keyring = new Keyring()
- keyring.addFromUri('//Alice', undefined, 'sr25519')
- const [ALICE] = keyring.getPairs()
- const video: VideoEntity = {
- title: 'Example video',
- description: 'This is an example video',
-
-
- language: { existing: { code: 'EN' } },
- category: { existing: { name: 'Education' } },
-
-
- channel: { existing: { handle: 'Example channel' } },
- media: {
-
- new: {
-
- encoding: { existing: { name: 'H.263_MP4' } },
- pixelHeight: 600,
- pixelWidth: 800,
-
- location: { new: { httpMediaLocation: { new: { url: 'https://testnet.joystream.org/' } } } },
- },
- },
-
- license: {
- new: {
- knownLicense: {
-
- existing: { code: 'CC_BY' },
- },
- },
- },
- duration: 3600,
- thumbnailUrl: '',
- isExplicit: false,
- isPublic: true,
- }
-
- const parser = InputParser.createWithKnownSchemas(
- api,
-
- [
- {
- className: 'Video',
- entries: [video],
- },
- ]
- )
-
- const operations = await parser.getEntityBatchOperations()
- await api.tx.contentDirectory
- .transaction(
- { Member: 0 },
- operations
- )
- .signAndSend(ALICE)
- }
- main()
- .then(() => process.exit())
- .catch(console.error)
|