From 56daae07096d3049ed56ce58df28884f749a89c1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E9=99=88=E7=9A=93?= <353374337@qq.com>
Date: Fri, 5 Oct 2018 12:39:32 +0800
Subject: [PATCH] =?UTF-8?q?=E7=AC=AC=E4=B8=80=E9=83=A8=E5=AE=9E=E7=8E=B0?=
=?UTF-8?q?=E8=A7=A3=E6=9E=90m3u8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitattributes | 63 +++++
.gitignore | 261 ++++++++++++++++++
.../HaoYue.MediaDownloader.sln | 25 ++
.../HaoYue.MediaDownloader/App.config | 6 +
.../HaoYue.MediaDownloader/App.xaml | 17 ++
.../HaoYue.MediaDownloader/App.xaml.cs | 17 ++
.../HaoYue.MediaDownloader.csproj | 108 ++++++++
.../HaoYue.MediaDownloader/HttpHelper.cs | 127 +++++++++
.../HaoYue.MediaDownloader/MainWindow.xaml | 26 ++
.../HaoYue.MediaDownloader/MainWindow.xaml.cs | 106 +++++++
.../Properties/AssemblyInfo.cs | 55 ++++
.../Properties/Resources.Designer.cs | 71 +++++
.../Properties/Resources.resx | 117 ++++++++
.../Properties/Settings.Designer.cs | 30 ++
.../Properties/Settings.settings | 7 +
.../HaoYue.MediaDownloader/packages.config | 5 +
16 files changed, 1041 insertions(+)
create mode 100644 .gitattributes
create mode 100644 .gitignore
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader.sln
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.config
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml.cs
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/HaoYue.MediaDownloader.csproj
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/HttpHelper.cs
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml.cs
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/AssemblyInfo.cs
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.Designer.cs
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.resx
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.Designer.cs
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.settings
create mode 100644 HaoYue.MediaDownloader/HaoYue.MediaDownloader/packages.config
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..1ff0c42
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,63 @@
+###############################################################################
+# Set default behavior to automatically normalize line endings.
+###############################################################################
+* text=auto
+
+###############################################################################
+# Set default behavior for command prompt diff.
+#
+# This is need for earlier builds of msysgit that does not have it on by
+# default for csharp files.
+# Note: This is only used by command line
+###############################################################################
+#*.cs diff=csharp
+
+###############################################################################
+# Set the merge driver for project and solution files
+#
+# Merging from the command prompt will add diff markers to the files if there
+# are conflicts (Merging from VS is not affected by the settings below, in VS
+# the diff markers are never inserted). Diff markers may cause the following
+# file extensions to fail to load in VS. An alternative would be to treat
+# these files as binary and thus will always conflict and require user
+# intervention with every merge. To do so, just uncomment the entries below
+###############################################################################
+#*.sln merge=binary
+#*.csproj merge=binary
+#*.vbproj merge=binary
+#*.vcxproj merge=binary
+#*.vcproj merge=binary
+#*.dbproj merge=binary
+#*.fsproj merge=binary
+#*.lsproj merge=binary
+#*.wixproj merge=binary
+#*.modelproj merge=binary
+#*.sqlproj merge=binary
+#*.wwaproj merge=binary
+
+###############################################################################
+# behavior for image files
+#
+# image files are treated as binary by default.
+###############################################################################
+#*.jpg binary
+#*.png binary
+#*.gif binary
+
+###############################################################################
+# diff behavior for common document formats
+#
+# Convert binary document formats to text before diffing them. This feature
+# is only available from the command line. Turn it on by uncommenting the
+# entries below.
+###############################################################################
+#*.doc diff=astextplain
+#*.DOC diff=astextplain
+#*.docx diff=astextplain
+#*.DOCX diff=astextplain
+#*.dot diff=astextplain
+#*.DOT diff=astextplain
+#*.pdf diff=astextplain
+#*.PDF diff=astextplain
+#*.rtf diff=astextplain
+#*.RTF diff=astextplain
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..3c4efe2
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,261 @@
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# DNX
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.pch
+*.pdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# TODO: Comment the next line if you want to checkin your web deploy settings
+# but database connection strings (with potential passwords) will be unencrypted
+#*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want to
+# checkin your Azure Web App publish settings, but sensitive information contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/packages/*
+# except build/, which is used as an MSBuild target.
+!**/packages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/packages/repositories.config
+# NuGet v3's project.json files produces more ignoreable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+node_modules/
+orleans.codegen.cs
+
+# Since there are multiple workflows, uncomment next line to ignore bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+
+# SQL Server files
+*.mdf
+*.ldf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
\ No newline at end of file
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader.sln b/HaoYue.MediaDownloader/HaoYue.MediaDownloader.sln
new file mode 100644
index 0000000..7516874
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader.sln
@@ -0,0 +1,25 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 15
+VisualStudioVersion = 15.0.27703.2026
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HaoYue.MediaDownloader", "HaoYue.MediaDownloader\HaoYue.MediaDownloader.csproj", "{5DBDA955-1253-4DA7-8688-A9C9A0DA9BE9}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {5DBDA955-1253-4DA7-8688-A9C9A0DA9BE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {5DBDA955-1253-4DA7-8688-A9C9A0DA9BE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {5DBDA955-1253-4DA7-8688-A9C9A0DA9BE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {5DBDA955-1253-4DA7-8688-A9C9A0DA9BE9}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {CB43CA6F-26B2-469E-B70C-D4AF311882CE}
+ EndGlobalSection
+EndGlobal
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.config b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.config
new file mode 100644
index 0000000..88fa402
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.config
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml
new file mode 100644
index 0000000..189b4e6
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml.cs b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml.cs
new file mode 100644
index 0000000..391d3ca
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/App.xaml.cs
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using System.Linq;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace HaoYue.MediaDownloader
+{
+ ///
+ /// App.xaml 的交互逻辑
+ ///
+ public partial class App : Application
+ {
+ }
+}
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/HaoYue.MediaDownloader.csproj b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/HaoYue.MediaDownloader.csproj
new file mode 100644
index 0000000..7b0b20b
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/HaoYue.MediaDownloader.csproj
@@ -0,0 +1,108 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {5DBDA955-1253-4DA7-8688-A9C9A0DA9BE9}
+ WinExe
+ HaoYue.MediaDownloader
+ HaoYue.MediaDownloader
+ v4.5.2
+ 512
+ {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 4
+ true
+
+
+ AnyCPU
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ AnyCPU
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\ControlzEx.3.0.2.4\lib\net45\ControlzEx.dll
+
+
+ ..\packages\MahApps.Metro.1.6.5\lib\net45\MahApps.Metro.dll
+
+
+
+
+ ..\packages\ControlzEx.3.0.2.4\lib\net45\System.Windows.Interactivity.dll
+
+
+
+
+
+
+
+
+ 4.0
+
+
+
+
+
+
+
+ MSBuild:Compile
+ Designer
+
+
+ MSBuild:Compile
+ Designer
+
+
+ App.xaml
+ Code
+
+
+
+ MainWindow.xaml
+ Code
+
+
+
+
+ Code
+
+
+ True
+ True
+ Resources.resx
+
+
+ True
+ Settings.settings
+ True
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/HttpHelper.cs b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/HttpHelper.cs
new file mode 100644
index 0000000..c8c5c70
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/HttpHelper.cs
@@ -0,0 +1,127 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace HaoYue.MediaDownloader
+{
+ public static class HttpHelper
+ {
+ ///
+ /// Http方式下载文件
+ ///
+ /// http地址
+ /// 本地文件
+ ///
+ public static bool Download(string url, string localfile)
+ {
+ bool flag = false;
+ long startPosition = 0; // 上次下载的文件起始位置
+ FileStream writeStream; // 写入本地文件流对象
+
+ long remoteFileLength = GetHttpLength(url);// 取得远程文件长度
+ System.Console.WriteLine("remoteFileLength=" + remoteFileLength);
+ if (remoteFileLength == 745)
+ {
+ System.Console.WriteLine("远程文件不存在.");
+ return false;
+ }
+
+ // 判断要下载的文件夹是否存在
+ if (File.Exists(localfile))
+ {
+
+ writeStream = File.OpenWrite(localfile); // 存在则打开要下载的文件
+ startPosition = writeStream.Length; // 获取已经下载的长度
+
+ if (startPosition >= remoteFileLength)
+ {
+ System.Console.WriteLine("本地文件长度" + startPosition + "已经大于等于远程文件长度" + remoteFileLength);
+ writeStream.Close();
+
+ return false;
+ }
+ else
+ {
+ writeStream.Seek(startPosition, SeekOrigin.Current); // 本地文件写入位置定位
+ }
+ }
+ else
+ {
+ writeStream = new FileStream(localfile, FileMode.Create);// 文件不保存创建一个文件
+ startPosition = 0;
+ }
+
+
+ try
+ {
+ HttpWebRequest myRequest = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接
+
+ if (startPosition > 0)
+ {
+ myRequest.AddRange((int)startPosition);// 设置Range值,与上面的writeStream.Seek用意相同,是为了定义远程文件读取位置
+ }
+
+
+ Stream readStream = myRequest.GetResponse().GetResponseStream();// 向服务器请求,获得服务器的回应数据流
+
+
+ byte[] btArray = new byte[512];// 定义一个字节数据,用来向readStream读取内容和向writeStream写入内容
+ int contentSize = readStream.Read(btArray, 0, btArray.Length);// 向远程文件读第一次
+
+ long currPostion = startPosition;
+
+ while (contentSize > 0)// 如果读取长度大于零则继续读
+ {
+ currPostion += contentSize;
+ int percent = (int)(currPostion * 100 / remoteFileLength);
+ System.Console.WriteLine("percent=" + percent + "%");
+
+ writeStream.Write(btArray, 0, contentSize);// 写入本地文件
+ contentSize = readStream.Read(btArray, 0, btArray.Length);// 继续向远程文件读取
+ }
+
+ //关闭流
+ writeStream.Close();
+ readStream.Close();
+
+ flag = true; //返回true下载成功
+ }
+ catch (Exception)
+ {
+ writeStream.Close();
+ flag = false; //返回false下载失败
+ }
+
+ return flag;
+ }
+
+ // 从文件头得到远程文件的长度
+ private static long GetHttpLength(string url)
+ {
+ long length = 0;
+
+ try
+ {
+ HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);// 打开网络连接
+ HttpWebResponse rsp = (HttpWebResponse)req.GetResponse();
+
+ if (rsp.StatusCode == HttpStatusCode.OK)
+ {
+ length = rsp.ContentLength;// 从文件头得到远程文件的长度
+ }
+
+ rsp.Close();
+ return length;
+ }
+ catch (Exception e)
+ {
+ return length;
+ }
+
+ }
+ }
+}
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml
new file mode 100644
index 0000000..0b50635
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml
@@ -0,0 +1,26 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml.cs b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml.cs
new file mode 100644
index 0000000..356489c
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/MainWindow.xaml.cs
@@ -0,0 +1,106 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+//引用
+using MahApps.Metro.Controls;
+
+namespace HaoYue.MediaDownloader
+{
+ public class ModelOfM3u8
+ {
+ public string Path { get; set; }
+ ///
+ /// [0] 视频格式 [1]m3u8文件
+ ///
+ public int filetype { get; set; }
+ }
+
+ ///
+ /// MainWindow.xaml 的交互逻辑
+ ///
+ public partial class MainWindow : MetroWindow
+ {
+ public MainWindow()
+ {
+ InitializeComponent();
+ }
+
+ string mypath = Environment.CurrentDirectory;
+
+ private void DoStart(object sender, RoutedEventArgs e)
+ {
+ AddLog("处理");
+ if (this.TextUrl.Text == "")
+ {
+ AddLog("Url为空");
+ }
+ else
+ {
+ this.TextUrl.IsEnabled = false;
+ this.BtnDoStart.IsEnabled = false;
+ string ThisTaskDir = mypath + "\\Download\\" + DateTime.Now.ToString("yyyyMMdd-hhmmss.FFF") + "\\";
+
+ if (!Directory.Exists(ThisTaskDir))
+ {
+ Directory.CreateDirectory(ThisTaskDir);
+ AddLog("创建媒体任务目录 "+ThisTaskDir);
+ }
+
+ string FileName = this.TextUrl.Text.Substring(this.TextUrl.Text.LastIndexOf('/')+1);
+ string SiteDir = this.TextUrl.Text.Substring(0,this.TextUrl.Text.LastIndexOf('/'));
+
+ AddLog("开始下载m3u8文件 " + FileName);
+ HttpHelper.Download(this.TextUrl.Text,ThisTaskDir + FileName);
+ AddLog("下载完毕");
+
+ CheckM3u8File(ThisTaskDir + FileName);
+
+ AddLog("处理完毕");
+ }
+ }
+ private List CheckM3u8File(string FilePath)
+ {
+ AddLog("开始解析m3u8文件");
+ var ALLList = new List();
+ string FileText = File.ReadAllText(FilePath);
+ foreach (string s in FileText.Split('\n'))
+ {
+ if (s.Trim().Length > 0 && s.Trim().Substring(0, 1) != "#")//去空格后长度不为1 且不是注释
+ {
+ int filetype = 0;
+
+
+ if (s.Substring(s.LastIndexOf(".")).Contains("m3u8"))
+ {
+ filetype = 1;
+ }
+ ALLList.Add(new ModelOfM3u8() { Path = s ,filetype = filetype});
+
+ }
+ }
+ AddLog("解析完毕,共"+ALLList.Where(w => w.filetype == 0 ).Count()+"个ts视频切片");
+ return ALLList;
+ }
+
+ public void AddLog(string str)
+ {
+ this.ListLog.Items.Add(DateTime.Now.ToString("hh:mm:ss >") + str);
+ //要使用显示最后一行
+ this.ListLog.SelectedIndex = this.ListLog.Items.Count - 1;
+ this.ListLog.ScrollIntoView(this.ListLog.SelectedIndex);
+ //待续...
+ }
+ }
+}
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/AssemblyInfo.cs b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..388f97a
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/AssemblyInfo.cs
@@ -0,0 +1,55 @@
+using System.Reflection;
+using System.Resources;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+using System.Windows;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("HaoYue.MediaDownloader")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HaoYue.MediaDownloader")]
+[assembly: AssemblyCopyright("Copyright © 2018")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+//若要开始生成可本地化的应用程序,请设置
+//.csproj 文件中的 CultureYouAreCodingWith
+//例如,如果您在源文件中使用的是美国英语,
+//使用的是美国英语,请将 设置为 en-US。 然后取消
+//对以下 NeutralResourceLanguage 特性的注释。 更新
+//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
+
+//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
+
+
+[assembly: ThemeInfo(
+ ResourceDictionaryLocation.None, //主题特定资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //或应用程序资源字典中找到时使用)
+ ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
+ //(未在页面中找到资源时使用,
+ //、应用程序或任何主题专用资源字典中找到时使用)
+)]
+
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+// 可以指定所有值,也可以使用以下所示的 "*" 预置版本号和修订号
+// 方法是按如下所示使用“*”: :
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.Designer.cs b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..10393c8
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本: 4.0.30319.42000
+//
+// 对此文件的更改可能导致不正确的行为,如果
+// 重新生成代码,则所做更改将丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace HaoYue.MediaDownloader.Properties
+{
+
+
+ ///
+ /// 强类型资源类,用于查找本地化字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// 返回此类使用的缓存 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HaoYue.MediaDownloader.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 覆盖当前线程的 CurrentUICulture 属性
+ /// 使用此强类型的资源类的资源查找。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.resx b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.resx
new file mode 100644
index 0000000..af7dbeb
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.Designer.cs b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.Designer.cs
new file mode 100644
index 0000000..5b61f21
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.42000
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace HaoYue.MediaDownloader.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.settings b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.settings
new file mode 100644
index 0000000..033d7a5
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/HaoYue.MediaDownloader/HaoYue.MediaDownloader/packages.config b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/packages.config
new file mode 100644
index 0000000..c444da8
--- /dev/null
+++ b/HaoYue.MediaDownloader/HaoYue.MediaDownloader/packages.config
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file