@@ -10,11 +10,15 @@ public class UEPubReader {
10
10
11
11
public string epubFolderLocation { get ; private set ; }
12
12
13
- public Dictionary < string , string > chapters ;
13
+ private Dictionary < string , string > bookItems ;
14
+ private List < string > spine ;
14
15
15
16
private string opfFileString ;
16
17
17
18
public UEPubReader ( string file ) {
19
+ bookItems = new Dictionary < string , string > ( ) ;
20
+ spine = new List < string > ( ) ;
21
+
18
22
var fileArray = file . Split ( '.' ) ;
19
23
20
24
if ( fileArray [ fileArray . Length - 1 ] . ToLower ( ) != "epub" ) {
@@ -40,5 +44,24 @@ private void ParseContainer(){
40
44
doc . SelectSingleNode ( "/container/rootfiles/rootfile" ) ;
41
45
opfFileString = rootFile . Attributes [ "full-path" ] . InnerText ;
42
46
}
47
+
48
+ private void ParseOPF ( ) {
49
+ var opfFile = epubFolderLocation + "/" + opfFileString ;
50
+
51
+ XmlDocument doc = new XmlDocument ( ) ;
52
+ doc . Load ( opfFile ) ;
53
+
54
+ var nodes = doc . SelectNodes ( "/package/manifest" ) ;
55
+
56
+ foreach ( XmlNode node in nodes ) {
57
+ bookItems [ node . Attributes [ "id" ] . InnerText ] = node . Attributes [ "href" ] . InnerText ;
58
+ }
59
+
60
+ nodes = doc . SelectNodes ( "/package/spine" ) ;
61
+
62
+ foreach ( XmlNode node in nodes ) {
63
+ spine . Add ( node . Attributes [ "idref" ] . InnerText ) ;
64
+ }
65
+ }
43
66
}
44
67
}
0 commit comments