Exemplo n.º 1
0
        public void EnsureTrackFile(ArtistResource artist, int albumId, int albumReleaseId, int trackId, Quality quality)
        {
            var result = Tracks.GetTracksInArtist(artist.Id).Single(v => v.Id == trackId);

            if (result.TrackFile == null)
            {
                var path = Path.Combine(ArtistRootFolder, artist.ArtistName, "Track.mp3");

                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllText(path, "Fake Track");

                Commands.PostAndWait(new ManualImportCommand {
                    Files = new List <ManualImportFile> {
                        new ManualImportFile {
                            Path           = path,
                            ArtistId       = artist.Id,
                            AlbumId        = albumId,
                            AlbumReleaseId = albumReleaseId,
                            TrackIds       = new List <int> {
                                trackId
                            },
                            Quality = new QualityModel(quality)
                        }
                    }
                });
                Commands.WaitAll();

                var track = Tracks.GetTracksInArtist(artist.Id).Single(x => x.Id == trackId);

                track.TrackFileId.Should().NotBe(0);
            }
        }
Exemplo n.º 2
0
        public void EnsureBookFile(AuthorResource author, int bookId, string foreignEditionId, Quality quality)
        {
            var result = Books.GetBooksInAuthor(author.Id).Single(v => v.Id == bookId);

            // if (result.BookFile == null)
            if (true)
            {
                var path = Path.Combine(AuthorRootFolder, author.AuthorName, "Track.mp3");

                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllText(path, "Fake Track");

                Commands.PostAndWait(new ManualImportCommand
                {
                    Files = new List <ManualImportFile>
                    {
                        new ManualImportFile
                        {
                            Path             = path,
                            AuthorId         = author.Id,
                            BookId           = bookId,
                            ForeignEditionId = foreignEditionId,
                            Quality          = new QualityModel(quality)
                        }
                    }
                });
                Commands.WaitAll();

                var track = Books.GetBooksInAuthor(author.Id).Single(x => x.Id == bookId);

                // track.BookFileId.Should().NotBe(0);
            }
        }
Exemplo n.º 3
0
        public MovieFileResource EnsureMovieFile(MovieResource movie, Quality quality)
        {
            var result = Movies.Get(movie.Id);

            if (result.MovieFile == null)
            {
                var path = Path.Combine(MovieRootFolder, movie.Title, string.Format("{0} ({1}) - {2}.strm", movie.Title, movie.Year, quality.Name));

                Directory.CreateDirectory(Path.GetDirectoryName(path));

                var sourcePath = Path.Combine(TestContext.CurrentContext.TestDirectory, "ApiTests", "Files", "H264_sample.mp4");

                //File.Copy(sourcePath, path);
                File.WriteAllText(path, "Fake Movie");

                Commands.PostAndWait(new RefreshMovieCommand(new List <int> {
                    movie.Id
                }));
                Commands.WaitAll();

                result = Movies.Get(movie.Id);

                result.MovieFile.Should().NotBeNull();
            }

            return(result.MovieFile);
        }
Exemplo n.º 4
0
        public MovieFileResource EnsureMovieFile(MovieResource movie, Quality quality)
        {
            var result = Movies.Get(movie.Id);

            if (result.MovieFile == null)
            {
                var path = Path.Combine(MovieRootFolder, movie.Title, string.Format("{0} - {1}.mkv", movie.Title, quality.Name));

                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllText(path, "Fake Movie");

                Commands.PostAndWait(new CommandResource {
                    Name = "refreshmovie", Body = new RefreshMovieCommand(movie.Id)
                });
                Commands.WaitAll();

                result = Movies.Get(movie.Id);

                result.MovieFile.Should().NotBeNull();
            }

            return(result.MovieFile);
        }
Exemplo n.º 5
0
        public EpisodeFileResource EnsureEpisodeFile(SeriesResource series, int season, int episode, Quality quality)
        {
            var result = Episodes.GetEpisodesInSeries(series.Id).Single(v => v.SeasonNumber == season && v.EpisodeNumber == episode);

            if (result.EpisodeFile == null)
            {
                var path = Path.Combine(SeriesRootFolder, series.Title, string.Format("Series.S{0}E{1}.{2}.mkv", season, episode, quality.Name));

                Directory.CreateDirectory(Path.GetDirectoryName(path));
                File.WriteAllText(path, "Fake Episode");

                Commands.PostAndWait(new CommandResource {
                    Name = "refreshseries", Body = new RefreshSeriesCommand(series.Id)
                });
                Commands.WaitAll();

                result = Episodes.GetEpisodesInSeries(series.Id).Single(v => v.SeasonNumber == season && v.EpisodeNumber == episode);

                result.EpisodeFile.Should().NotBeNull();
            }

            return(result.EpisodeFile);
        }