public async Task <StacNode> ExtractArchive(StacItemNode stacItemNode, IDestination destination, StacStoreService storeService) { StacNode newItemNode = stacItemNode; foreach (var processing in processingManager.GetProcessings(ProcessingType.ArchiveExtractor)) { if (!processing.CanProcess(newItemNode, destination)) { continue; } // Create a new destination for each processing IDestination procDestination = destination.To(stacItemNode, processing.GetRelativePath(stacItemNode, destination)); StacItemNode newStacItemNode = null; try { var processedResource = await processing.Process(newItemNode, procDestination); if (processedResource == null) { continue; } newStacItemNode = processedResource as StacItemNode; // Maybe the node is already a stac node if (newStacItemNode == null) { // No? Let's try to translate it to Stac newStacItemNode = await translatorManager.Translate <StacItemNode>(processedResource); if (newStacItemNode == null) { throw new InvalidDataException(string.Format("Impossible to translate node {0} into STAC.", processedResource.Uri)); } } } catch (Exception e) { logger.LogWarning("Exception extracting archive assets in {0} : {1}", newItemNode.Uri, e.Message); continue; } newItemNode = await storeService.StoreItemNodeAtDestination(newStacItemNode, destination); break; } return(newItemNode); }
private void CreatePlaylists(IList <FileInfo> movieFiles, UserOptions.Playlists config) { /* * - take each file and try to open .nfo/.tgmd * - from .nfo extract list of genres and put the to the dictionary * - process each item in dictionary * */ Dictionary <string, List <PlaylistItem> > _ItemsDictionary = new Dictionary <string, List <PlaylistItem> >(); if (config != null && movieFiles != null && movieFiles.Count != 0) { bool _useSingleFile = config.Criteria == PlaylistManager.NOSPLIT_CRITERIA; bool _useUnassigned = config.UseUnassignedPlaylist && !_useSingleFile; string criteria = config.Criteria; if (!string.IsNullOrEmpty(criteria)) { if (_useUnassigned) { // add the _unassigned as key for the items missing the criteria _ItemsDictionary.Add(UNASSIGNED_PLAYLIST_FILENAME, new List <PlaylistItem>()); } if (_useSingleFile) { // add the PlaylistManager.NOSPLIT_PLAYLIST_FILENAME as key for all items _ItemsDictionary.Add(config.SingleFilename, new List <PlaylistItem>()); } try { bool _addToUnassigned = false; foreach (FileInfo _file in movieFiles) { _addToUnassigned = false; try { MovieItem _movieItem = FileManager.GetMovieByFilePath(_file.FullName); //FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.Querying); // extract movieinfo from metadata/nfo files MovieInfo _info = ExtractMovieInfo(_file.FullName); if (_info != null) { List <string> _criteriaItems = null; // if more playlists will be generated then extract criteria items (else all items will be added to the PlaylistManager.NOSPLIT_PLAYLIST_FILENAME file if (!_useSingleFile) { _criteriaItems = ExtractCriteriaItems(criteria, _info); } if (_criteriaItems != null) { // will not enter here if single file mode // for each criteria item, if not in dictionary add it, if already there add movie to the list foreach (string _citem in _criteriaItems) { string _name = _citem; if (config.ForceEnglishResults) { _name = m_translatorManager.Translate(_name); } string _key = string.IsNullOrEmpty(_name) ? null : _name.ToLowerInvariant().Replace(Path.DirectorySeparatorChar, '_').Replace(Path.AltDirectorySeparatorChar, '_'); if (!string.IsNullOrEmpty(_key)) { if (!_ItemsDictionary.ContainsKey(_key)) { _ItemsDictionary.Add(_key, new List <PlaylistItem>()); } List <PlaylistItem> _list = _ItemsDictionary[_key]; _list.Add(new PlaylistItem(_file.FullName, _info)); } else { _addToUnassigned = true; } } //FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.Done); } else { if (_useSingleFile) { List <PlaylistItem> _list = _ItemsDictionary[config.SingleFilename]; _list.Add(new PlaylistItem(_file.FullName, _info)); //FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.Done); } else { //FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.NotFound); _addToUnassigned = true; } } } else { //FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.MetadataMissing); _addToUnassigned = true; } if (_useUnassigned && _addToUnassigned) { _ItemsDictionary[UNASSIGNED_PLAYLIST_FILENAME].Add(new PlaylistItem(_file.FullName, new MovieInfo())); } //Helpers.DoEvents(); } catch (Exception ex) { Loggy.Logger.DebugException("Processing playlist:", ex); } } // for } finally { //_translatorManager.ClearCache(); //_translatorManager = null; } } // ItemsDictionary has all required infos, can create playlist files CreatePlaylistFiles(_ItemsDictionary, config); } }