-
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatic import from remote drive (#86)
* Add initial files for handling automatic importing from seedboxes * Initial structure and storage driver integration * Add method to find files recursively * Remove . from file extensions * Add sample config for seedboxes * Filter which movies need to be import from remote storage * Basic importing of movies from remote storage * Add support for importing episodes * Update package-lock.json * Update package-lock.json * Add rest endpoint to import media from remote storage * Only import matched episodes and store episodes in series directories * Add option to disable an auto importer config
- Loading branch information
1 parent
bfe5736
commit b689a7b
Showing
19 changed files
with
3,648 additions
and
6,528 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { extname, normalize as normalizePath } from 'path'; | ||
import SeedboxImportFTP from './SeedboxImportDrivers/SeedboxImportFTP'; | ||
import WarnExtendableError from '../errors/WarnExtendableError'; | ||
import logger from '../../submodules/logger'; | ||
import index from 'async'; | ||
|
||
export default class Seedbox { | ||
constructor(seedboxConfig) { | ||
this.moviePath = normalizePath(seedboxConfig.mediaImport.movieDirectory); | ||
this.seriesPath = normalizePath(seedboxConfig.mediaImport.seriesDirectory); | ||
this.name = seedboxConfig.name; | ||
|
||
this.initStorageDriver(seedboxConfig.storageDriver, seedboxConfig.storageDriverOptions); | ||
} | ||
|
||
initStorageDriver(seedboxStorageDriver, seedboxStorageDriverOptions) { | ||
switch (seedboxStorageDriver.toLowerCase()) { | ||
case 'ftp': | ||
this.storageDriver = new SeedboxImportFTP(seedboxStorageDriverOptions); | ||
return; | ||
} | ||
|
||
return new WarnExtendableError('Invalid seedbox storage driver'); | ||
} | ||
|
||
async findAll(indexPath, fileTypes) { | ||
logger.log('DEBUG', `Finding files in ${indexPath}`); | ||
|
||
const toIndex = []; | ||
const indexed = []; | ||
|
||
toIndex.push(indexPath); | ||
|
||
while (toIndex.length > 0) { | ||
let current = toIndex.pop(); | ||
|
||
const entries = await this.storageDriver.list(current); | ||
|
||
for (const entry of entries) { | ||
switch (entry.type) { | ||
case 0: // Type 0 is a file | ||
if (fileTypes.indexOf(extname(`${current}/${entry.name}`).replace('.','')) !== -1) | ||
indexed.push(normalizePath(`${current}/${entry.name}`)); | ||
break; | ||
case 1: // Type 1 is a directory | ||
toIndex.push(normalizePath(`${current}/${entry.name}`)); | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return indexed; | ||
} | ||
} |
Oops, something went wrong.