@@ -12,7 +12,7 @@ let iTunesUCourseID = 1309275316
1212
1313enum ResourceType : String , CustomStringConvertible {
1414 // Raw Type: video/x-m4v, video/mp4
15- case lecture = " Video "
15+ case lecture = " . "
1616 case friday = " Friday Session "
1717 // Raw Type: application/pdf
1818 case slides = " Slides "
@@ -41,16 +41,10 @@ struct Resource: CustomStringConvertible {
4141 let url : String
4242 let summary : String ?
4343
44- init ? ( title: String , rawType : String , url: String , summary: String ? ) {
44+ init ? ( title: String , url: String , summary: String ? ) {
4545 self . url = url
46-
47- if rawType. contains ( " video " ) {
48- type = title. hasPrefix ( " Friday " ) ? . friday : . lecture
49- } else if let resType = ResourceType . all. first ( where: { title. contains ( $0. rawValue) } ) {
50- type = resType
51- } else {
52- fatalError ( " Unknown Raw Type \( rawType) " )
53- }
46+
47+ type = ResourceType . all. first { title. contains ( $0. rawValue) } !
5448
5549 var parts : [ String ]
5650 switch type {
@@ -106,7 +100,6 @@ class ParsingDelegate: NSObject, XMLParserDelegate {
106100
107101 var title : String ?
108102 var isParsingTitle = false
109- var type : String ?
110103 var url : String ?
111104 var summary : String ?
112105 var isParsingSummary = false
@@ -120,7 +113,6 @@ class ParsingDelegate: NSObject, XMLParserDelegate {
120113 case " summary " :
121114 isParsingSummary = true
122115 case " link " :
123- type = attributeDict [ " type " ]
124116 url = attributeDict [ " href " ]
125117 default :
126118 break
@@ -149,15 +141,14 @@ class ParsingDelegate: NSObject, XMLParserDelegate {
149141 isParsingSummary = false
150142 case " entry " :
151143 total += 1
152- if let res = Resource ( title: title!, rawType : type! , url: url!, summary: summary) {
144+ if let res = Resource ( title: title!, url: url!, summary: summary) {
153145 resources. append ( res)
154146 } else {
155147 totalSkipped += 1
156148 debugPrint ( " Skipped \( title ?? " Titleless " ) " )
157149 }
158150 title = nil
159151 isParsingTitle = false
160- type = nil
161152 url = nil
162153 summary = nil
163154 isParsingSummary = false
0 commit comments