@Override public void importFile(Collection<IMolecule> molecules, File file, String repository) { IMDBEntry entry = lookUpIMDB(file); if (entry == null) { System.out.println( "Failed to retrieve an IMDB entry for this file. Do you want to import this file anyway? [y/N]"); if (askUserYesNo()) { IMoleculeImporter importer = MoleculeHandlerFactory.getInstance().getNextImporter(file, this); importer.importFile(molecules, file); } return; } boolean isRemote = true; String targetDirName = Configuration.getRepository(repository); if (repository != null && targetDirName == null) { System.out.println("Unkown remote location \"" + repository + "\". Check your config."); return; } if (targetDirName == null) { targetDirName = Configuration.get().getString("base.dir"); isRemote = false; } String fileName = GenericImporter.copyFile(file, targetDirName); if (fileName == null) { System.out.println("Error. No file imported."); return; } IAtom title = Atom.build().withData(entry.getTitle()).withTag("title").buildWithDataAndTag(); AtomBuilder binRefBuilder = Atom.build() .withData("/" + fileName) .withTag(CoreTags.FILEREF_TAG) .withTag(CoreTags.FILETYPE_VIDEO); if (isRemote) { binRefBuilder.withTag(CoreTags.FILEREF_REMOTE_TAG); } MoleculeBuilder mBuilder = Molecule.build() .withAtom(title) .withAtom(binRefBuilder.buildWithDataAndTag()) .withTag("video"); if (entry.isSeries()) { mBuilder.withTag("series"); } else { mBuilder.withTag("movie"); } if (isRemote) { IAtom remote = Atom.build() .withData(repository) .withTag(CoreTags.FILEREF_REMOTE_LOCATION) .buildWithDataAndTag(); mBuilder.withAtom(remote); } if (entry.getImdbRating() != null) { IAtom rating = Atom.build().withData(entry.getImdbRating()).withTag("IMDB-rating").buildWithDataAndTag(); mBuilder.withAtom(rating); } if (entry.getYear() != null) { IAtom year = Atom.build().withData(entry.getYear()).withTag("year").buildWithDataAndTag(); mBuilder.withAtom(year); } if (entry.getImdbUrl() != null) { IAtom url = Atom.build().withData(entry.getImdbUrl()).withTag("url").buildWithDataAndTag(); mBuilder.withAtom(url); } IMolecule molecule = mBuilder.buildWithAtomsAndTags(); ATService.getMoleculeService().save(molecule); molecules.add(molecule); }