Beispiel #1
0
        private static async Task M3U8Down(Stopwatch stopwatch)
        {
            //机动部队
            //https://iqiyi.qq-zuidazy.com/20190506/10110_005140a1/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10109_da4bd19a/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10108_b2bd8bb2/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10107_8b4c62e3/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10106_32bdc1be/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10105_fbb1785b/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10104_771a135b/800k/hls/index.m3u8
            //https://iqiyi.qq-zuidazy.com/20190506/10103_5703cff8/800k/hls/index.m3u8
            var m3u8downloader = new M3U8Downloader("https://iqiyi.qq-zuidazy.com/20190524/11140_de848fc5/800k/hls/index.m3u8", "C:\\Test");

            m3u8downloader.SuggestedFileName = "18.m3u8";
            await m3u8downloader.LoadAsync();

            await m3u8downloader.DownloadFileAsync((e) =>
            {
                //Console.WriteLine(e); // Current Progress

                Console.WriteLine($"Time:{e.Time} AverageSpeed:{e.AverageSpeed.SizeSuffix()} CurrentValue:{e.CurrentValue.SizeSuffix()} Speed:{e.Speed.SizeSuffix()} Percentage:{e.Percentage}");
                if (e.Percentage >= 100)
                {
                    stopwatch.Stop();
                    Console.WriteLine(stopwatch.ElapsedMilliseconds);
                }
            });
        }
Beispiel #2
0
        private static async Task <M3U8Downloader> ConfigureDownloader(Options options)
        {
            var m3u8 = new M3U8Downloader();

            if (string.IsNullOrEmpty(options.DownloadDirectory))
            {
                options.DownloadDirectory = Directory.GetCurrentDirectory();
            }

            m3u8 = new M3U8Downloader(new Uri(options.DownloadDirectory));

            if (!string.IsNullOrEmpty(options.HeaderFile))
            {
                var headerParser = new HeaderParser();
                m3u8.SetHttpHeader(headerParser.GetHeader(options.HeaderFile));
            }

            if (string.IsNullOrEmpty(options.FormatFile))
            {
                await m3u8.LoadPlaylistAsync(options.BaseUrl, options.PlaylistName);

                m3u8.SelectedFormat = m3u8.Playlist.Formats[options.FormatSelected];
            }
            else
            {
                m3u8.Playlist = new Playlist();
                m3u8.SetBaseURL(new Uri(options.BaseUrl));
                m3u8.Playlist.Formats.Add(new Format()
                {
                    FileName = options.FormatFile
                });
                m3u8.SelectedFormat = m3u8.Playlist.Formats[0];
            }

            return(m3u8);
        }