import { remove } from 'fs-extra'
import { truncate } from 'lodash'
import { join } from 'path'
-import * as prompt from 'prompt'
import { promisify } from 'util'
import { YoutubeDL } from '@server/helpers/youtube-dl'
import { sha256 } from '../helpers/core-utils'
getLogger,
getServerCredentials
} from './cli'
-import { ServerInfo } from '@shared/extra-utils'
+import { PeerTubeServer } from '@shared/extra-utils'
+
+import prompt = require('prompt')
const processOptions = {
maxBuffer: Infinity
}
const server = buildServer(url)
- const { data } = await server.searchCommand.advancedVideoSearch({
+ const { data } = await server.search.advancedVideoSearch({
search: {
search: videoInfo.title,
sort: '-match',
log.info('\nUploading on PeerTube video "%s".', attributes.name)
try {
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
} catch (err) {
if (err.message.indexOf('401') !== -1) {
log.info('Got 401 Unauthorized, token may have expired, renewing token and retry.')
- server.accessToken = await server.loginCommand.getAccessToken(username, password)
+ server.accessToken = await server.login.getAccessToken(username, password)
- await server.videosCommand.upload({ attributes })
+ await server.videos.upload({ attributes })
} else {
exitError(err.message)
}
/* ---------------------------------------------------------- */
-async function getCategory (server: ServerInfo, categories: string[]) {
+async function getCategory (server: PeerTubeServer, categories: string[]) {
if (!categories) return undefined
const categoryString = categories[0]
if (categoryString === 'News & Politics') return 11
- const categoriesServer = await server.videosCommand.getCategories()
+ const categoriesServer = await server.videos.getCategories()
for (const key of Object.keys(categoriesServer)) {
const categoryServer = categoriesServer[key]
return new Promise<any>((res, rej) => {
const options = [ '-j', '--flat-playlist', '--playlist-reverse', ...args ]
- youtubeDL.getInfo(url, options, processOptions, async (err, info) => {
+ youtubeDL.getInfo(url, options, processOptions, (err, info) => {
if (err) return rej(err)
return res(info)