aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-import.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/models/video/video-import.ts')
-rw-r--r--server/models/video/video-import.ts24
1 files changed, 23 insertions, 1 deletions
diff --git a/server/models/video/video-import.ts b/server/models/video/video-import.ts
index 1d8296060..b8e941623 100644
--- a/server/models/video/video-import.ts
+++ b/server/models/video/video-import.ts
@@ -1,4 +1,4 @@
1import { WhereOptions } from 'sequelize' 1import { Op, WhereOptions } from 'sequelize'
2import { 2import {
3 AfterUpdate, 3 AfterUpdate,
4 AllowNull, 4 AllowNull,
@@ -161,6 +161,28 @@ export class VideoImportModel extends Model<Partial<AttributesOnly<VideoImportMo
161 ]).then(([ total, data ]) => ({ total, data })) 161 ]).then(([ total, data ]) => ({ total, data }))
162 } 162 }
163 163
164 static async urlAlreadyImported (channelId: number, targetUrl: string): Promise<boolean> {
165 const element = await VideoImportModel.unscoped().findOne({
166 where: {
167 targetUrl,
168 state: {
169 [Op.in]: [ VideoImportState.PENDING, VideoImportState.PROCESSING, VideoImportState.SUCCESS ]
170 }
171 },
172 include: [
173 {
174 model: VideoModel,
175 required: true,
176 where: {
177 channelId
178 }
179 }
180 ]
181 })
182
183 return !!element
184 }
185
164 getTargetIdentifier () { 186 getTargetIdentifier () {
165 return this.targetUrl || this.magnetUri || this.torrentName 187 return this.targetUrl || this.magnetUri || this.torrentName
166 } 188 }