Compare commits

...
4 Commits
4 changed files with 36 additions and 10 deletions

No files matched your search

+7
View File
@@ -1,5 +1,12 @@
# Changelog
## [2.1.2](https://github.com/Masutayunikon/FanKarr/compare/v2.1.1...v2.1.2) (2026-03-23)
### Bug Fixes
* path now work on every device ([cfc3440](https://github.com/Masutayunikon/FanKarr/commit/cfc3440a95cb73802778e01d5f256f473e0cc952))
## [2.1.1](https://github.com/Masutayunikon/FanKarr/compare/v2.1.0...v2.1.1) (2026-03-23)
+2 -2
View File
@@ -206,9 +206,9 @@ function buildResolvedEpisodes(sd: any, hash: string, seasonFilter?: number): an
let filePath: string | null = null
for (const p of paths) {
if (typeof p === 'string') {
if (!filePath) filePath = p // legacy fallback
if (!filePath) filePath = p.replace(/\\/g, '/') // legacy fallback
} else if (p?.infohash?.toLowerCase() === h) {
filePath = p.path
filePath = p.path.replace(/\\/g, '/')
break
}
}
+22 -7
View File
@@ -80,7 +80,7 @@ function findTorrentByHash(hash: string, seriesData: any[]): { torrent: any; ser
}
// Construit la map filename → { season_number, original_filename, fullPath }
// en matchant par infohash dans ep.paths[]
// Supporte les deux formats : { infohash, path } et string (legacy)
function buildFileMap(
serieData : any,
hash : string,
@@ -92,14 +92,25 @@ function buildFileMap(
for (const season of serieData.seasons ?? []) {
if (seasonFilter !== undefined && season.season_number !== seasonFilter) continue
for (const ep of season.episodes ?? []) {
const match = (ep.paths ?? []).find((p: any) => p.infohash?.toLowerCase() === h)
if (!match) continue
const filename = match.path.split('/').pop() ?? match.path
const paths: any[] = ep.paths ?? []
let matchedPath: string | null = null
for (const p of paths) {
if (typeof p === 'string') {
if (!matchedPath) matchedPath = p.replace(/\\/g, '/')
} else if (p?.infohash?.toLowerCase() === h) {
matchedPath = p.path.replace(/\\/g, '/')
break
}
}
if (!matchedPath) continue
const filename = matchedPath.split('/').pop() ?? matchedPath
const original = ep.original_filename ?? filename
map.set(filename, {
season_number : season.season_number,
original_filename: original,
fullPath : match.path,
fullPath : matchedPath,
})
}
}
@@ -224,8 +235,12 @@ async function organizeTorrent(hash: string, name: string, savePath: string, ser
if (torrent._episode) {
const ep = torrent._episode
const season = torrent._season
const match = (ep.paths ?? []).find((p: any) => p.infohash?.toLowerCase() === hash.toLowerCase())
const filePath = match?.path ?? null
const paths: any[] = ep.paths ?? []
let filePath: string | null = null
for (const p of paths) {
if (typeof p === 'string') { if (!filePath) filePath = p.replace(/\\/g, '/') }
else if (p?.infohash?.toLowerCase() === hash.toLowerCase()) { filePath = p.path.replace(/\\/g, '/'); break }
}
const filename = filePath?.split('/').pop() ?? name
const original = ep.original_filename ?? filename
const destDir = path.join(mediaPath, serieTitle, seasonFolder(season.season_number ?? 1))
+5 -1
View File
@@ -54,9 +54,13 @@ export async function scanMediaPath(
for (const season of sd.seasons ?? []) {
for (const ep of season.episodes ?? []) {
for (const p of ep.paths ?? []) {
if (typeof p === 'string') {
// Legacy : pas d'infohash disponible, on skip pour le scan
continue
}
const hash = p.infohash?.toLowerCase()
if (!hash || !p.path) continue
const filename = p.path.split('/').pop()
const filename = p.path.replace(/\\/g, '/').split('/').pop()
if (filename) filenameIndex.set(filename, hash)
}
}