-async function getCategory (categories: string[], url: string) {
- if (!categories) return undefined
-
- const categoryString = categories[0]
-
- if (categoryString === 'News & Politics') return 11
-
- const res = await getVideoCategories(url)
- const categoriesServer = res.body
-
- for (const key of Object.keys(categoriesServer)) {
- const categoryServer = categoriesServer[key]
- if (categoryString.toLowerCase() === categoryServer.toLowerCase()) return parseInt(key, 10)
- }
-
- return undefined
-}
-
-function getLicence (licence: string) {
- if (!licence) return undefined
-
- if (licence.includes('Creative Commons Attribution licence')) return 1
-
- return undefined
-}
-
-function normalizeObject (obj: any) {
- const newObj: any = {}
-
- for (const key of Object.keys(obj)) {
- // Deprecated key
- if (key === 'resolution') continue
-
- const value = obj[key]
-
- if (typeof value === 'string') {
- newObj[key] = value.normalize()
- } else {
- newObj[key] = value
- }
- }