コード例 #1
0
ファイル: ShellService.cs プロジェクト: tavaratv/novaroma
        public async Task DownloadSubtitle(string filePath)
        {
            var downloadable = await _engine.GetDownloadable(filePath);

            if (downloadable != null)
            {
                var downloaded = false;

                var movie = downloadable as Movie;
                if (movie != null)
                {
                    downloaded = await _engine.DownloadSubtitleForMovie(movie);
                }
                else
                {
                    var episode = downloadable as TvShowEpisode;
                    if (episode != null)
                    {
                        downloaded = await _engine.DownloadSubtitleForTvShowEpisode(episode);
                    }
                }

                if (!downloaded)
                {
                    await Helper.ManualSubtitleDownload(_engine, _exceptionHandler, _dialogService, downloadable);

                    if (downloadable.Media.IsModified)
                    {
                        await _engine.UpdateEntity(downloadable.Media);
                    }
                }
            }
            else
            {
                var downloaded = await _engine.DownloadSubtitle(filePath);

                if (downloaded)
                {
                    return;
                }

                var fileInfo = new FileInfo(filePath);
                if (fileInfo.Exists)
                {
                    await Helper.ManualSubtitleDownload(_engine, _exceptionHandler, _dialogService, fileInfo);
                }
            }
        }