-
Notifications
You must be signed in to change notification settings - Fork 3
/
ChapterExtractor.cs
46 lines (39 loc) · 1.35 KB
/
ChapterExtractor.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
namespace JarrettVance.ChapterTools
{
public abstract class ChapterExtractor
{
public abstract string[] Extensions { get; }
public virtual bool SupportsMultipleStreams { get { return true; } }
public abstract List<ChapterInfo> GetStreams(string location);
public event EventHandler<ProgramChainArg> StreamDetected;
public event EventHandler<ProgramChainArg> ChaptersLoaded;
public event EventHandler ExtractionComplete;
public static string ComputeMD5Sum(string path)
{
return BitConverter.ToString(new
MD5CryptoServiceProvider().ComputeHash(System.IO.File.ReadAllBytes(path)))
.Replace("-", "").ToLower();
}
protected void OnExtractionComplete()
{
if (ExtractionComplete != null) ExtractionComplete(this, EventArgs.Empty);
}
protected void OnStreamDetected(ChapterInfo pgc)
{
if (StreamDetected != null) StreamDetected(this, new ProgramChainArg() { ProgramChain = pgc });
}
protected void OnChaptersLoaded(ChapterInfo pgc)
{
if (ChaptersLoaded != null) ChaptersLoaded(this, new ProgramChainArg() { ProgramChain = pgc });
}
}
public class ProgramChainArg : EventArgs
{
public ChapterInfo ProgramChain { get; set; }
}
}