diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/youtube-dl.ts | 2 | ||||
-rw-r--r-- | server/initializers/migrations/0612-captions-unique.ts | 23 | ||||
-rw-r--r-- | server/models/video/video.ts | 2 |
3 files changed, 25 insertions, 2 deletions
diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 9d2e54fb5..fac3da6ba 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts | |||
@@ -76,7 +76,7 @@ function getYoutubeDLSubs (url: string, opts?: object): Promise<YoutubeDLSubs> { | |||
76 | logger.debug('Get subtitles from youtube dl.', { url, files }) | 76 | logger.debug('Get subtitles from youtube dl.', { url, files }) |
77 | 77 | ||
78 | const subtitles = files.reduce((acc, filename) => { | 78 | const subtitles = files.reduce((acc, filename) => { |
79 | const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i) | 79 | const matched = filename.match(/\.([a-z]{2})(-[a-z]+)?\.(vtt|ttml)/i) |
80 | if (!matched || !matched[1]) return acc | 80 | if (!matched || !matched[1]) return acc |
81 | 81 | ||
82 | return [ | 82 | return [ |
diff --git a/server/initializers/migrations/0612-captions-unique.ts b/server/initializers/migrations/0612-captions-unique.ts new file mode 100644 index 000000000..368838a2a --- /dev/null +++ b/server/initializers/migrations/0612-captions-unique.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | async function up (utils: { | ||
4 | transaction: Sequelize.Transaction | ||
5 | queryInterface: Sequelize.QueryInterface | ||
6 | sequelize: Sequelize.Sequelize | ||
7 | db: any | ||
8 | }): Promise<void> { | ||
9 | |||
10 | await utils.sequelize.query( | ||
11 | 'DELETE FROM "videoCaption" v1 USING (SELECT MIN(id) as id, "filename" FROM "videoCaption" ' + | ||
12 | 'GROUP BY "filename" HAVING COUNT(*) > 1) v2 WHERE v1."filename" = v2."filename" AND v1.id <> v2.id' | ||
13 | ) | ||
14 | } | ||
15 | |||
16 | function down (options) { | ||
17 | throw new Error('Not implemented.') | ||
18 | } | ||
19 | |||
20 | export { | ||
21 | up, | ||
22 | down | ||
23 | } | ||
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index b10c6e38e..e9afb2c18 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -917,7 +917,7 @@ export class VideoModel extends Model { | |||
917 | }, | 917 | }, |
918 | include: [ | 918 | include: [ |
919 | { | 919 | { |
920 | attributes: [ 'language', 'fileUrl' ], | 920 | attributes: [ 'filename', 'language', 'fileUrl' ], |
921 | model: VideoCaptionModel.unscoped(), | 921 | model: VideoCaptionModel.unscoped(), |
922 | required: false | 922 | required: false |
923 | }, | 923 | }, |