[scraper] handle zero season in parser

This commit is contained in:
TheBeastLT
2021-01-06 21:25:02 +01:00
parent 49f6b6a633
commit a297f33aef

View File

@@ -10,16 +10,17 @@ function parseSeriesVideos(torrent, videos) {
function parseSeriesVideo(video, parsedTorrentName) {
const videoInfo = parse(video.name);
const hasSeason = Number.isInteger(videoInfo.season);
// the episode may be in a folder containing season number
if (!videoInfo.season && video.path.includes('/')) {
if (!hasSeason && video.path.includes('/')) {
const folders = video.path.split('/');
const pathInfo = parse(folders[folders.length - 2]);
videoInfo.season = pathInfo.season;
}
if (!videoInfo.season && parsedTorrentName.season) {
if (!hasSeason && parsedTorrentName.season) {
videoInfo.season = parsedTorrentName.season;
}
if (!videoInfo.season && videoInfo.seasons && videoInfo.seasons.length > 1) {
if (!hasSeason && videoInfo.seasons && videoInfo.seasons.length > 1) {
// in case single file was interpreted as having multiple seasons
videoInfo.season = videoInfo.seasons[0];
}