<commit_before>import { truncate } from 'lodash'
import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers'
import { logger } from './logger'
import { generateVideoTmpPath } from './utils'
import { YoutubeDlUpdateScheduler } from '../lib/schedulers/youtube-dl-update-scheduler'

export type YoutubeDLInfo = {
  name?: string
  description?: string
  category?: number
  licence?: number
  nsfw?: boolean
  tags?: string[]
  thumbnailUrl?: string
}

function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> {
  return new Promise<YoutubeDLInfo>(async (res, rej) => {
    const options = [ '-j', '--flat-playlist' ]

    const youtubeDL = await safeGetYoutubeDL()
    youtubeDL.getInfo(url, options, (err, info) => {
      if (err) return rej(err)

      const obj = buildVideoInfo(normalizeObject(info))
      if (obj.name && obj.name.length < CONSTRAINTS_FIELDS.VIDEOS.NAME.min) obj.name += ' video'<commit_msg>Do not import live streaming<commit_after>import { truncate } from 'lodash'
import { CONSTRAINTS_FIELDS, VIDEO_CATEGORIES } from '../initializers'
import { logger } from './logger'
import { generateVideoTmpPath } from './utils'
import { YoutubeDlUpdateScheduler } from '../lib/schedulers/youtube-dl-update-scheduler'

export type YoutubeDLInfo = {
  name?: string
  description?: string
  category?: number
  licence?: number
  nsfw?: boolean
  tags?: string[]
  thumbnailUrl?: string
}

function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> {
  return new Promise<YoutubeDLInfo>(async (res, rej) => {
    const options = [ '-j', '--flat-playlist' ]

    const youtubeDL = await safeGetYoutubeDL()
    youtubeDL.getInfo(url, options, (err, info) => {
      if (err) return rej(err)
      if (info.is_live === true) return rej(new Error('Cannot download a live streaming.'))

      const obj = buildVideoInfo(normalizeObject(info))
      if (obj.name && obj.name.length < CONSTRAINTS_FIELDS.VIDEOS.NAME.min) obj.name += ' video'
{'fraction_non_alphanumeric': 0.13268937468225725, 'fraction_numerical': 0.0, 'mean_word_length': 4.23404255319149, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5259213', 'n_tokens_mistral': 667, 'n_tokens_neox': 628, 'n_words': 159}