mirror of
https://github.com/knightcrawler-stremio/knightcrawler.git
synced 2024-12-20 03:29:51 +00:00
[scraper] updates movie title to path
This commit is contained in:
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1620,8 +1620,8 @@
|
||||
}
|
||||
},
|
||||
"parse-torrent-title": {
|
||||
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#7597effa105bc1f0329a88aefea2291f2f7f11c1",
|
||||
"from": "git://github.com/TheBeastLT/parse-torrent-title.git#7597effa105bc1f0329a88aefea2291f2f7f11c1",
|
||||
"version": "git://github.com/TheBeastLT/parse-torrent-title.git#826ee1a8a832e8c18fcc0703f5b56a8b9acd4283",
|
||||
"from": "git://github.com/TheBeastLT/parse-torrent-title.git#826ee1a8a832e8c18fcc0703f5b56a8b9acd4283",
|
||||
"requires": {
|
||||
"moment": "^2.24.0"
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
"node-schedule": "^1.3.2",
|
||||
"nodejs-bing": "^0.1.0",
|
||||
"parse-torrent": "^6.1.2",
|
||||
"parse-torrent-title": "git://github.com/TheBeastLT/parse-torrent-title.git#7597effa105bc1f0329a88aefea2291f2f7f11c1",
|
||||
"parse-torrent-title": "git://github.com/TheBeastLT/parse-torrent-title.git#826ee1a8a832e8c18fcc0703f5b56a8b9acd4283",
|
||||
"peer-search": "^0.6.x",
|
||||
"pg": "^7.8.2",
|
||||
"pg-hstore": "^2.3.2",
|
||||
|
||||
@@ -30,7 +30,7 @@ async function parseTorrentFiles(torrent) {
|
||||
.then((newImdbId) => ({
|
||||
infoHash: torrent.infoHash,
|
||||
fileIndex: file.fileIndex,
|
||||
title: file.name,
|
||||
title: file.path || file.name,
|
||||
size: file.size,
|
||||
imdbId: newImdbId,
|
||||
})))))
|
||||
@@ -113,7 +113,7 @@ async function mapSeriesMovie(file, torrent) {
|
||||
return findMovieImdbId(file).then((imdbId) => [{
|
||||
infoHash: torrent.infoHash,
|
||||
fileIndex: file.fileIndex,
|
||||
title: file.name,
|
||||
title: file.path || file.name,
|
||||
size: file.size,
|
||||
imdbId: imdbId
|
||||
}])
|
||||
@@ -122,13 +122,14 @@ async function mapSeriesMovie(file, torrent) {
|
||||
function parseSeriesFile(file, parsedTorrentName) {
|
||||
const fileInfo = parse(file.name);
|
||||
// the episode may be in a folder containing season number
|
||||
if (!fileInfo.season && parsedTorrentName.season) {
|
||||
fileInfo.season = parsedTorrentName.season;
|
||||
} else if (!fileInfo.season && file.path.includes('/')) {
|
||||
if (!fileInfo.season && file.path.includes('/')) {
|
||||
const folders = file.path.split('/');
|
||||
const pathInfo = parse(folders[folders.length - 2]);
|
||||
fileInfo.season = pathInfo.season;
|
||||
}
|
||||
if (!fileInfo.season && parsedTorrentName.season) {
|
||||
fileInfo.season = parsedTorrentName.season;
|
||||
}
|
||||
// force episode to any found number if it was not parsed
|
||||
if (!fileInfo.episodes && !fileInfo.date) {
|
||||
const epMatcher = fileInfo.title.match(/(?<!movie\W*|film\W*)(?:^|\W)(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)/i);
|
||||
@@ -263,9 +264,9 @@ function decomposeDateEpisodeFiles(torrent, files, metadata) {
|
||||
|
||||
function decomposeEpisodeTitleFiles(torrent, files, metadata) {
|
||||
files
|
||||
.filter(file => !file.season)
|
||||
// .filter(file => !file.season)
|
||||
.map(file => {
|
||||
const episodeTitle = file.name.replace(/^.*-\s?(.+)\.\w{1,4}$/, '$1').trim();
|
||||
const episodeTitle = file.name.replace('_', ' ').replace(/^.*(?:E\d+[abc]?|-)\s?(.+)\.\w{1,4}$/, '$1').trim();
|
||||
const foundEpisode = metadata.videos
|
||||
.map(video => ({ ...video, distance: distance(episodeTitle, video.name) }))
|
||||
.sort((a, b) => b.distance - a.distance)[0];
|
||||
|
||||
Reference in New Issue
Block a user