-import { registerTSPaths } from '../helpers/register-ts-paths'
-registerTSPaths()
-
import { program } from 'commander'
import { accessSync, constants } from 'fs'
import { remove } from 'fs-extra'
import { join } from 'path'
-import { sha256 } from '@shared/core-utils/crypto'
+import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl'
+import { wait } from '@shared/core-utils'
+import { sha256 } from '@shared/extra-utils'
import { doRequestAndSaveToFile } from '../helpers/requests'
import {
assignToken,
getLogger,
getServerCredentials
} from './cli'
-import { wait } from '@shared/server-commands'
-import { YoutubeDLCLI, YoutubeDLInfo, YoutubeDLInfoBuilder } from '@server/helpers/youtube-dl'
+
import prompt = require('prompt')
const processOptions = {
.option('--last <last>', 'Process last n elements of returned playlist')
.option('--wait-interval <waitInterval>', 'Duration between two video imports (in seconds)', convertIntoMs)
.option('-T, --tmpdir <tmpdir>', 'Working directory', __dirname)
- .usage("[global options] [ -- youtube-dl options]")
+ .usage('[global options] [ -- youtube-dl options]')
.parse(process.argv)
const options = command.opts()
for (const [ index, info ] of infoArray.entries()) {
try {
if (index > 0 && options.waitInterval && !skipInterval) {
- log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000)
+ log.info('Wait for %d seconds before continuing.', options.waitInterval / 1000)
await wait(options.waitInterval)
}
const videoInfo = await fetchObject(youtubeInfo)
log.debug('Fetched object.', videoInfo)
- if (options.since && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() < options.since.getTime()) {
+ if (
+ options.since &&
+ videoInfo.originallyPublishedAtWithoutTime &&
+ videoInfo.originallyPublishedAtWithoutTime.getTime() < options.since.getTime()
+ ) {
log.info('Video "%s" has been published before "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.since))
return true
}
- if (options.until && videoInfo.originallyPublishedAt && videoInfo.originallyPublishedAt.getTime() > options.until.getTime()) {
+ if (
+ options.until &&
+ videoInfo.originallyPublishedAtWithoutTime &&
+ videoInfo.originallyPublishedAtWithoutTime.getTime() > options.until.getTime()
+ ) {
log.info('Video "%s" has been published after "%s", don\'t upload it.\n', videoInfo.name, formatDate(options.until))
return true
}
const youtubeDLBinary = await YoutubeDLCLI.safeGet()
const output = await youtubeDLBinary.download({
url: videoInfo.url,
- format: YoutubeDLCLI.getYoutubeDLVideoFormat([]),
+ format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false),
output: path,
additionalYoutubeDLArgs: command.args,
processOptions
const attributes = {
...baseAttributes,
- originallyPublishedAt: videoInfo.originallyPublishedAt
- ? videoInfo.originallyPublishedAt.toISOString()
+ originallyPublishedAtWithoutTime: videoInfo.originallyPublishedAtWithoutTime
+ ? videoInfo.originallyPublishedAtWithoutTime.toISOString()
: null,
thumbnailfile,
const youtubeDLCLI = await YoutubeDLCLI.safeGet()
const result = await youtubeDLCLI.getInfo({
url,
- format: YoutubeDLCLI.getYoutubeDLVideoFormat([]),
+ format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false),
processOptions
})
function getYoutubeDLInfo (youtubeDLCLI: YoutubeDLCLI, url: string, args: string[]) {
return youtubeDLCLI.getInfo({
url,
- format: YoutubeDLCLI.getYoutubeDLVideoFormat([]),
+ format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false),
additionalYoutubeDLArgs: [ '-j', '--flat-playlist', '--playlist-reverse', ...args ],
processOptions
})