From 4c7449d2add412e2cef4d55b357d58abaa0ae83b Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Apr 2021 14:29:03 +0200 Subject: Fix subtitles import --- server/helpers/youtube-dl.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 8537a5772..5b46f704a 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -76,7 +76,7 @@ function getYoutubeDLSubs (url: string, opts?: object): Promise { logger.debug('Get subtitles from youtube dl.', { url, files }) const subtitles = files.reduce((acc, filename) => { - const matched = filename.match(/\.([a-z]{2})\.(vtt|ttml)/i) + const matched = filename.match(/\.([a-z]{2})(-[a-z]+)?\.(vtt|ttml)/i) if (!matched || !matched[1]) return acc return [ -- cgit v1.2.3 From 083328eb27ec2b08a22a390363b11ae66869eba3 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Apr 2021 14:45:40 +0200 Subject: Remove duplicate captions --- server/initializers/constants.ts | 2 +- .../migrations/0612-captions-unique.ts | 23 ++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 server/initializers/migrations/0612-captions-unique.ts (limited to 'server') diff --git a/server/initializers/constants.ts b/server/initializers/constants.ts index 1623e6f42..50467f408 100644 --- a/server/initializers/constants.ts +++ b/server/initializers/constants.ts @@ -24,7 +24,7 @@ import { CONFIG, registerConfigChangedHandler } from './config' // --------------------------------------------------------------------------- -const LAST_MIGRATION_VERSION = 610 +const LAST_MIGRATION_VERSION = 612 // --------------------------------------------------------------------------- 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 @@ +import * as Sequelize from 'sequelize' + +async function up (utils: { + transaction: Sequelize.Transaction + queryInterface: Sequelize.QueryInterface + sequelize: Sequelize.Sequelize + db: any +}): Promise { + + await utils.sequelize.query( + 'DELETE FROM "videoCaption" v1 USING (SELECT MIN(id) as id, "filename" FROM "videoCaption" ' + + 'GROUP BY "filename" HAVING COUNT(*) > 1) v2 WHERE v1."filename" = v2."filename" AND v1.id <> v2.id' + ) +} + +function down (options) { + throw new Error('Not implemented.') +} + +export { + up, + down +} -- cgit v1.2.3 From 1afb3c474ae1194748a6fba901058c720e01be0c Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 8 Apr 2021 15:04:14 +0200 Subject: Fix outbox fetch with subtitled videos --- server/models/video/video.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'server') diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 9d89efa5b..3c4f3d3df 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -916,7 +916,7 @@ export class VideoModel extends Model { }, include: [ { - attributes: [ 'language', 'fileUrl' ], + attributes: [ 'filename', 'language', 'fileUrl' ], model: VideoCaptionModel.unscoped(), required: false }, -- cgit v1.2.3