Esempio n. 1
0
        public async Task SubtitleIdentification()
        {
            _manager.Setup(x => x.GetAll(null, new Sort <Library>(), default)).ReturnsAsync(new[]
            {
                new Library {
                    Paths = new [] { "/kyoo", "/kyoo/Library/" }
                }
            });
            Track track = await _identifier.IdentifyTrack("/kyoo/Library/Collection/Show (2000)/Show.eng.default.str");

            Assert.True(track.IsExternal);
            Assert.Equal("eng", track.Language);
            Assert.Equal("subrip", track.Codec);
            Assert.True(track.IsDefault);
            Assert.False(track.IsForced);
            Assert.StartsWith("/kyoo/Library/Collection/Show (2000)/Show", track.Episode.Path);
        }
Esempio n. 2
0
        /// <inheritdoc />
        public async Task Run(TaskParameters arguments, IProgress <float> progress, CancellationToken cancellationToken)
        {
            string path = arguments["path"].As <string>();

            try
            {
                progress.Report(0);
                Track track = await _identifier.IdentifyTrack(path);

                progress.Report(25);

                if (track.Episode == null)
                {
                    throw new TaskFailedException($"No episode identified for the track at {path}");
                }
                if (track.Episode.ID == 0)
                {
                    if (track.Episode.Slug != null)
                    {
                        track.Episode = await _libraryManager.Get <Episode>(track.Episode.Slug);
                    }
                    else if (track.Episode.Path != null)
                    {
                        track.Episode = await _libraryManager.GetOrDefault <Episode>(x => x.Path.StartsWith(track.Episode.Path));

                        if (track.Episode == null)
                        {
                            throw new TaskFailedException($"No episode found for the track at: {path}.");
                        }
                    }
                    else
                    {
                        throw new TaskFailedException($"No episode identified for the track at {path}");
                    }
                }

                progress.Report(50);
                await _libraryManager.Create(track);

                progress.Report(100);
            }
            catch (IdentificationFailedException ex)
            {
                throw new TaskFailedException(ex);
            }
        }