Example #1
0
        public static NicoVideoCacheRequest CacheRequestInfoFromFileName(IStorageFile file)
        {
            // キャッシュリクエストを削除
            // 2重に拡張子を利用しているので二回GetFileNameWithoutExtensionを掛けることでIDを取得
            var match   = NicoVideoIdRegex.Match(file.Name);
            var id      = match.Value;
            var quality = NicoVideoQualityFileNameHelper.NicoVideoQualityFromFileNameExtention(file.Name);

            return(new NicoVideoCacheRequest()
            {
                RawVideoId = id, Quality = quality
            });
        }
Example #2
0
        private async Task RetrieveCacheCompletedVideos()
        {
            var videoFolder = await _HohoemaApp.GetVideoCacheFolder();

            if (videoFolder != null)
            {
                var files = await videoFolder.GetFilesAsync();

                foreach (var file in files)
                {
                    if (file.FileType != ".mp4")
                    {
                        continue;
                    }

                    // ファイル名の最後方にある[]の中身の文字列を取得
                    // (動画タイトルに[]が含まれる可能性に配慮)
                    var match   = NicoVideoIdRegex.Match(file.Name);
                    var id      = match.Value;
                    var quality = NicoVideoQualityFileNameHelper.NicoVideoQualityFromFileNameExtention(file.Name);
                    var info    = new NicoVideoCacheRequest()
                    {
                        RawVideoId = id,
                        Quality    = quality,
                    };

                    if (string.IsNullOrEmpty(id))
                    {
                        continue;
                    }

                    var nicoVideo = await GetNicoVideoAsync(info.RawVideoId, false);

                    var div = nicoVideo.GetDividedQualityNicoVideo(quality);

                    await nicoVideo.RestoreCache(quality, file.Path);

                    await CacheRequested(info);

                    VideoCacheStateChanged?.Invoke(this, info, NicoVideoCacheState.Cached);

                    Debug.Write(".");
                }
            }
        }