diff options
author | Chocobozzz <me@florianbigard.com> | 2021-04-08 15:16:01 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-04-08 15:16:01 +0200 |
commit | dc48fdbe68e9dd3a3a6028181e61d8595d98e654 (patch) | |
tree | b641873412bfb4ff2a754a27762cd533c735e7d8 /server | |
parent | 27ec473f5306621643fcb169be7cfe6b15136265 (diff) | |
parent | b9244002fcc48dda7f3a588980d910a40429238f (diff) | |
download | PeerTube-dc48fdbe68e9dd3a3a6028181e61d8595d98e654.tar.gz PeerTube-dc48fdbe68e9dd3a3a6028181e61d8595d98e654.tar.zst PeerTube-dc48fdbe68e9dd3a3a6028181e61d8595d98e654.zip |
Merge branch 'release/3.1.0' into develop
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 | }, |