diff options
author | Chocobozzz <me@florianbigard.com> | 2018-02-20 18:56:43 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-02-20 19:05:14 +0100 |
commit | a41e183c03ec60dae8cd7d62ca05036876b78824 (patch) | |
tree | 354651f11a25e6f70af57c046395982fcd4fa591 /server/tools/import-videos.ts | |
parent | b6fe1f985c34ced6895ec1482e68b356c0f21877 (diff) | |
download | PeerTube-a41e183c03ec60dae8cd7d62ca05036876b78824.tar.gz PeerTube-a41e183c03ec60dae8cd7d62ca05036876b78824.tar.zst PeerTube-a41e183c03ec60dae8cd7d62ca05036876b78824.zip |
Add nsfw support in import-videos
Diffstat (limited to 'server/tools/import-videos.ts')
-rw-r--r-- | server/tools/import-videos.ts | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/server/tools/import-videos.ts b/server/tools/import-videos.ts index d29a2c6f3..11f0257a9 100644 --- a/server/tools/import-videos.ts +++ b/server/tools/import-videos.ts | |||
@@ -114,7 +114,7 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, languag | |||
114 | let tags = [] | 114 | let tags = [] |
115 | if (Array.isArray(videoInfo.tags)) { | 115 | if (Array.isArray(videoInfo.tags)) { |
116 | tags = videoInfo.tags | 116 | tags = videoInfo.tags |
117 | .filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max) | 117 | .filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max && t.length > CONSTRAINTS_FIELDS.VIDEOS.TAG.min) |
118 | .map(t => t.normalize()) | 118 | .map(t => t.normalize()) |
119 | .slice(0, 5) | 119 | .slice(0, 5) |
120 | } | 120 | } |
@@ -134,7 +134,7 @@ async function uploadVideoOnPeerTube (videoInfo: any, videoPath: string, languag | |||
134 | category, | 134 | category, |
135 | licence, | 135 | licence, |
136 | language, | 136 | language, |
137 | nsfw: false, | 137 | nsfw: isNSFW(videoInfo), |
138 | commentsEnabled: true, | 138 | commentsEnabled: true, |
139 | description: videoInfo.description, | 139 | description: videoInfo.description, |
140 | tags, | 140 | tags, |
@@ -227,9 +227,18 @@ function fetchObject (info: any) { | |||
227 | } | 227 | } |
228 | 228 | ||
229 | function buildUrl (info: any) { | 229 | function buildUrl (info: any) { |
230 | const webpageUrl = info.webpage_url as string | ||
231 | if (webpageUrl && webpageUrl.match(/^https?:\/\//)) return webpageUrl | ||
232 | |||
230 | const url = info.url as string | 233 | const url = info.url as string |
231 | if (url && url.match(/^https?:\/\//)) return info.url | 234 | if (url && url.match(/^https?:\/\//)) return url |
232 | 235 | ||
233 | // It seems youtube-dl does not return the video url | 236 | // It seems youtube-dl does not return the video url |
234 | return 'https://www.youtube.com/watch?v=' + info.id | 237 | return 'https://www.youtube.com/watch?v=' + info.id |
235 | } | 238 | } |
239 | |||
240 | function isNSFW (info: any) { | ||
241 | if (info.age_limit && info.age_limit >= 16) return true | ||
242 | |||
243 | return false | ||
244 | } | ||