[scraper] fixes subtitles assignment

This commit is contained in:
TheBeastLT
2020-05-04 18:43:11 +02:00
parent 4b31aa9024
commit 46b75f0466

View File

@@ -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)
};
}