private async Task <bool> SaveMoviePictureAsync(VideoItem video, byte[] img)
        {
            if (await FetcherHelpers.SaveBytes(video.Id, "moviePic", img, "jpg", false))
            {
                await DispatchHelper.InvokeInUIThread(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    video.HasMoviePicture = true;
                });

                return(true);
            }
            return(false);
        }
Exemple #2
0
        public async Task <bool> SaveAlbumImageAsync(AlbumItem album, byte[] img)
        {
            if (await FetcherHelpers.SaveBytes(album.Id, "albumPic", img, "jpg", false))
            {
                await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () =>
                {
                    album.AlbumCoverUri = $"albumPic/{album.Id}.jpg";
                });

                return(true);
            }
            return(false);
        }
        private async Task <bool> SaveMoviePictureAsync(VideoItem video, byte[] img)
        {
            if (await FetcherHelpers.SaveBytes(video.Id, "moviePic", img, "jpg", false))
            {
                await DispatchHelper.InvokeAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                {
                    // Thumbnail is only refreshed when IsPictureLoaded changes, so first we set HasMoviePicture,
                    // then IsPictureLoaded
                    video.HasMoviePicture = true;
                    video.IsPictureLoaded = true;
                });

                return(true);
            }
            return(false);
        }
        private async Task <bool> SaveMovieSubtitleAsync(VideoItem video, byte[] sub)
        {
            if (await FetcherHelpers.SaveBytes(video.Id, "movieSub", sub, "zip", true))
            {
                var ext = await FetcherHelpers.ExtractFromArchive(video.Id, $"{ApplicationData.Current.TemporaryFolder.Path}\\{video.Id}.zip");

                if (!string.IsNullOrEmpty(ext))
                {
                    await DispatchHelper.InvokeInUIThread(Windows.UI.Core.CoreDispatcherPriority.Normal, () =>
                    {
                        video.IsSubtitlePreLoaded = true;
                        video.SubtitleExtension   = ext;
                    });

                    return(true);
                }
            }
            return(false);
        }
Exemple #5
0
        public async Task <bool> SaveArtistImageAsync(ArtistItem artist, byte[] img)
        {
            if (await FetcherHelpers.SaveBytes(artist.Id, "artistPic-original", img, "jpg", false))
            {
                // saving full hd max img
                var stream = await ImageHelper.ResizedImage(img, 1920, 1080);

                await FetcherHelpers.SaveBytes(artist.Id, "artistPic-fullsize", stream, "jpg", false);

                stream = await ImageHelper.ResizedImage(img, 250, 250);

                await FetcherHelpers.SaveBytes(artist.Id, "artistPic-thumbnail", stream, "jpg", false);

                await DispatchHelper.InvokeInUIThread(CoreDispatcherPriority.Normal, () => { artist.IsPictureLoaded = true; });

                return(true);
            }
            return(false);
        }
Exemple #6
0
        public async Task <DownloadableFile> GetLatestAsync()
        {
            var fileNamePatternAndFormat = GetFileNamePatternAndFormat();

            var downloadableFile = await FetcherHelpers.GetLatestDownloadableFileAsync(
                _httpClient,
                BaseUrl,
                fileNamePatternAndFormat.Pattern,
                fileNamePatternAndFormat.Format,
                CancellationToken.None).ConfigureAwait(false);

            if (downloadableFile == null)
            {
                throw new TorSharpException(
                          $"No version of Tor could be found under base URL {BaseUrl.AbsoluteUri} with pattern " +
                          $"{fileNamePatternAndFormat.Pattern}.");
            }

            return(downloadableFile);
        }
Exemple #7
0
        private async Task <DownloadableFile> GetLatestOrNullFromFileListingAsync(
            Uri baseUrl,
            CancellationToken token)
        {
            var directory = GetFileListingDirectory(baseUrl);
            var osBaseUrl = new Uri(baseUrl, $"{directory}/");
            var fileNamePatternAndFormat = GetFileNamePatternAndFormat(osBaseUrl);

            var downloadableFile = await FetcherHelpers.GetLatestDownloadableFileAsync(
                _httpClient,
                osBaseUrl,
                fileNamePatternAndFormat.Pattern,
                fileNamePatternAndFormat.Format,
                token).ConfigureAwait(false);

            if (downloadableFile == null)
            {
                throw new TorSharpException(
                          $"No version of Privoxy could be found under base URL {osBaseUrl.AbsoluteUri} with pattern " +
                          $"{fileNamePatternAndFormat.Pattern}.");
            }

            return(downloadableFile);
        }