From 46b75f04662996a51b25bcd79a90dc403abcd3aa Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Mon, 4 May 2020 18:43:11 +0200 Subject: [PATCH] [scraper] fixes subtitles assignment --- scraper/lib/torrentSubtitles.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scraper/lib/torrentSubtitles.js b/scraper/lib/torrentSubtitles.js index afac28f..ae6f4cd 100644 --- a/scraper/lib/torrentSubtitles.js +++ b/scraper/lib/torrentSubtitles.js @@ -11,7 +11,9 @@ function assignSubtitles({ contents, videos, subtitles }) { .map(video => _parseVideo(video)); const assignedSubs = subtitles .map(subtitle => ({ subtitle, video: _mostProbableSubtitleVideo(subtitle, parsedVideos) })); - const unassignedSubs = assignedSubs.filter(assignedSub => !assignedSub.video); + const unassignedSubs = assignedSubs + .filter(assignedSub => !assignedSub.video) + .map(assignedSub => assignedSub.subtitle); assignedSubs .filter(assignedSub => assignedSub.video) @@ -23,13 +25,13 @@ function assignSubtitles({ contents, videos, subtitles }) { } function _parseVideo(video) { - const fileName = video.title.replace(/\.(\w{2,4})$/, ''); + const fileName = video.title.split('/').pop().replace(/\.(\w{2,4})$/, ''); const folderName = video.title.replace(/\/?[^/]+$/, ''); return { videoFile: video, fileName: fileName, folderName: folderName, - ...parse(fileName) + ...parse(video.title) }; }