Compare commits

...
10 Commits
3 changed files with 50 additions and 20 deletions

No files matched your search

+14
View File
@@ -1,5 +1,19 @@
# Changelog # Changelog
## [3.18.3](https://github.com/Masutayunikon/FanKarr/compare/v3.18.2...v3.18.3) (2026-05-27)
### Bug Fixes
* **synology:** double prefix dbid_ et fallback hash ([2587768](https://github.com/Masutayunikon/FanKarr/commit/25877685eaf02b3b1c02ff06db618a37aebf0e6b))
## [3.18.2](https://github.com/Masutayunikon/FanKarr/compare/v3.18.1...v3.18.2) (2026-05-27)
### Bug Fixes
* **client:** synology use default savepath when 403 ([63f6c12](https://github.com/Masutayunikon/FanKarr/commit/63f6c1276bd48a14e5806ff997b6be63c458d94c))
## [3.18.1](https://github.com/Masutayunikon/FanKarr/compare/v3.18.0...v3.18.1) (2026-05-27) ## [3.18.1](https://github.com/Masutayunikon/FanKarr/compare/v3.18.0...v3.18.1) (2026-05-27)
+35 -19
View File
@@ -116,11 +116,13 @@ const DS: TorrentClientDriver = {
const dl = transfer.size_downloaded ?? 0 const dl = transfer.size_downloaded ?? 0
// Synology expose le hash BT dans additional.detail.hash // Synology expose le hash BT dans additional.detail.hash
// Fallback sur dbid_ pour les tâches non-BT (DDL, etc.) // Fallback sur l'ID Synology natif (déjà au format "dbid_X")
const rawHash = detail.hash const rawHash = String(detail.hash ?? '').trim()
const hash = (typeof rawHash === 'string' && rawHash.length > 0) const hash = rawHash.length > 0
? rawHash.toLowerCase() ? rawHash.toLowerCase()
: `dbid_${t.id}` : String(t.id ?? '').toLowerCase()
if (!rawHash) logger.debug('synology-ds', `Hash BT absent pour "${t.title}" — matching par titre (ID: ${t.id})`)
return { return {
hash, hash,
@@ -144,22 +146,36 @@ const DS: TorrentClientDriver = {
if (options?.file_index != null) logger.warn('synology-ds', 'Sélection de fichier non supportée — téléchargement complet') if (options?.file_index != null) logger.warn('synology-ds', 'Sélection de fichier non supportée — téléchargement complet')
const sid = await dsLogin(config) const sid = await dsLogin(config)
const body = new URLSearchParams({ const makeBody = (withDestination: boolean) => {
api : 'SYNO.DownloadStation.Task', const body = new URLSearchParams({
version: '1', api : 'SYNO.DownloadStation.Task',
method : 'create', version: '1',
_sid : sid, method : 'create',
uri : url, _sid : sid,
}) uri : url,
if (config.savePath) body.append('destination', String(config.savePath)) })
if (withDestination && config.savePath) body.append('destination', String(config.savePath))
return body
}
const doRequest = async (body: URLSearchParams) => {
const res = await fetch(`${config.url}/webapi/DownloadStation/task.cgi`, {
method : 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body : body.toString(),
})
if (!res.ok) throw new Error(`HTTP ${res.status}`)
return res.json()
}
let data = await doRequest(makeBody(true))
// Code 403 = destination inexistante sur le NAS → réessai sans destination
if (!data.success && data.error?.code === 403 && config.savePath) {
logger.warn('synology-ds', `Dossier cible "${config.savePath}" introuvable (code 403) — ajout sans destination`)
data = await doRequest(makeBody(false))
}
const res = await fetch(`${config.url}/webapi/DownloadStation/task.cgi`, {
method : 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body : body.toString(),
})
if (!res.ok) throw new Error(`HTTP ${res.status}`)
const data = await res.json()
if (!data.success) throw new Error(`Ajout échoué : ${JSON.stringify(data.error)}`) if (!data.success) throw new Error(`Ajout échoué : ${JSON.stringify(data.error)}`)
logger.info('synology-ds', `Torrent ajouté avec succès${config.savePath ? ` (dossier: ${config.savePath})` : ''}`) logger.info('synology-ds', `Torrent ajouté avec succès${config.savePath ? ` (dossier: ${config.savePath})` : ''}`)
+1 -1
View File
@@ -1 +1 @@
3.18.1 3.18.3