diff --git a/README.md b/README.md index 3e6f2e1..765bcac 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@

- app version 1.6.0 + app version 1.6.2 Swift 4.0 @@ -25,6 +25,12 @@ #### An app for Download WWDC subtitles ### Whats New: + +**version 1.6.2:** + +- Now can download link of Sample codes for WWDC 2019, 2018, 2017, 2016 videos +- Some minor bugs fixed + **version 1.6.1:** - WWDC 2019 Added. diff --git a/Releases/WWDC.srt.zip b/Releases/WWDC.srt.zip index c16d0f3..fd08919 100644 Binary files a/Releases/WWDC.srt.zip and b/Releases/WWDC.srt.zip differ diff --git a/WWDC.srt.xcodeproj/xcuserdata/SeyedSamad.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist b/WWDC.srt.xcodeproj/xcuserdata/SeyedSamad.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist index 5846676..a2558f0 100644 --- a/WWDC.srt.xcodeproj/xcuserdata/SeyedSamad.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist +++ b/WWDC.srt.xcodeproj/xcuserdata/SeyedSamad.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist @@ -299,7 +299,7 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.972092" + timestampString = "588417031.690729" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "38" @@ -316,11 +316,11 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.972165" + timestampString = "588417031.690802" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "75" - endingLineNumber = "75" + startingLineNumber = "78" + endingLineNumber = "78" landmarkName = "executeOld()" landmarkType = "7"> @@ -333,7 +333,7 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.9722281" + timestampString = "588417031.690853" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "46" @@ -350,11 +350,11 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.972288" + timestampString = "588417031.690889" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "83" - endingLineNumber = "83" + startingLineNumber = "86" + endingLineNumber = "86" landmarkName = "executeOld()" landmarkType = "7"> @@ -367,7 +367,7 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.97235" + timestampString = "588417031.690924" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "51" @@ -384,7 +384,7 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.97242" + timestampString = "588417031.690958" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "61" @@ -401,7 +401,7 @@ condition = "self.sessionNumber == "708"" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/ParseHtmlVideoPageOperation.swift" - timestampString = "571226522.972479" + timestampString = "588417031.690992" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "67" @@ -417,27 +417,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/WWDCVideosController.swift" - timestampString = "571226522.97254" + timestampString = "588417031.691027" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "183" - endingLineNumber = "183" - landmarkName = "getStringContent(fromURL:)" - landmarkType = "7"> - - - - @@ -449,11 +433,11 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/WWDCVideosController.swift" - timestampString = "571226522.973217" + timestampString = "588417031.691063" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" - startingLineNumber = "172" - endingLineNumber = "172" + startingLineNumber = "217" + endingLineNumber = "217" landmarkName = "getStringContent(fromURL:)" landmarkType = "7"> @@ -689,7 +673,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/WWDCVideosController.swift" - timestampString = "571226522.973803" + timestampString = "588417031.691193" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "123" @@ -721,7 +705,7 @@ ignoreCount = "0" continueAfterRunningActions = "No" filePath = "WWDCSubGetter/WWDCVideosController.swift" - timestampString = "571226522.9741811" + timestampString = "588417031.6912481" startingColumnNumber = "9223372036854775807" endingColumnNumber = "9223372036854775807" startingLineNumber = "92" diff --git a/WWDCSubGetter/Base.lproj/Main.storyboard b/WWDCSubGetter/Base.lproj/Main.storyboard index 12d7263..b6b0240 100644 --- a/WWDCSubGetter/Base.lproj/Main.storyboard +++ b/WWDCSubGetter/Base.lproj/Main.storyboard @@ -510,7 +510,6 @@ - @@ -645,7 +644,7 @@ DQ - + diff --git a/WWDCSubGetter/Info.plist b/WWDCSubGetter/Info.plist index 6994577..5f0562f 100644 --- a/WWDCSubGetter/Info.plist +++ b/WWDCSubGetter/Info.plist @@ -17,7 +17,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.6.1 + 1.6.2 CFBundleVersion 1 LSApplicationCategoryType diff --git a/WWDCSubGetter/ParseHtmlVideoPageOperation.swift b/WWDCSubGetter/ParseHtmlVideoPageOperation.swift index fdd32db..5c27a76 100644 --- a/WWDCSubGetter/ParseHtmlVideoPageOperation.swift +++ b/WWDCSubGetter/ParseHtmlVideoPageOperation.swift @@ -66,9 +66,12 @@ class ParseHtmlVideoPageOperation: Operation { case .sampleCode: let sampleCodesURLStrings = WWDCVideosController.getSampleCodeURL(fromHTML: htmlText) let sampleCodesURLStrings2 = WWDCVideosController.getSampleCodeURL2(fromHTML: htmlText) - + let sampleCodesURLStrings3 = WWDCVideosController.getSampleCodeURL3(fromHTML: htmlText) + linksModel.sampleCodesLinks.append(contentsOf: sampleCodesURLStrings) linksModel.sampleCodesLinks.append(contentsOf: sampleCodesURLStrings2) + linksModel.sampleCodesLinks.append(contentsOf: sampleCodesURLStrings3) + } } diff --git a/WWDCSubGetter/WWDCVideosController.swift b/WWDCSubGetter/WWDCVideosController.swift index 0865827..d4b5c81 100644 --- a/WWDCSubGetter/WWDCVideosController.swift +++ b/WWDCSubGetter/WWDCVideosController.swift @@ -155,6 +155,51 @@ class WWDCVideosController { return sampleURLPaths } + class func getSampleCodeURL3(fromHTML: String) -> [String] { +// let pat = "(href=\"[^ ]*?/content/samplecode/.*?=\")" + let pat = "href=\"([^ ]*?/documentation/.*?)\"" + let regex = try! NSRegularExpression(pattern: pat, options: []) + let matches = regex.matches(in: fromHTML, options: [], range: NSRange(location: 0, length: fromHTML.count)) + var sampleURLPaths : [String] = [] + for match in matches { + let range = match.range(at: 1) + var path = (fromHTML as NSString).substring(with: range) + + // Tack on the hostname if it's not already there (some URLs are listed as + // relative URL while some are fully-qualified). + let prefixReplacementString: String + if !path.contains("href=\"http") { + prefixReplacementString = "http(?:s)?://developer.apple.com" + } else { + prefixReplacementString = "" + } + path = path.replacingOccurrences(of: "href=\"", with: prefixReplacementString) + + // Strip target attribute suffix + path = path.replacingOccurrences(of: "\" target=\"", with: "/") + + sampleURLPaths.append(path) + } + + var sampleArchivePaths : [String] = [] + for urlPath in sampleURLPaths { + let htmlText = getStringContent(fromURL: urlPath) + + let pat = "href=\"([^ ]*?/published/.*?.zip)\"" + let regex = try! NSRegularExpression(pattern: pat, options: []) + let matches = regex.matches(in: htmlText, options: [], range: NSRange(location: 0, length: htmlText.count)) + for match in matches { + let range = match.range(at: 1) + let path = (htmlText as NSString).substring(with: range) + + sampleArchivePaths.append(path) + } + + } + + return sampleArchivePaths + } + class func getStringContent(fromURL: String) -> (String) { /* Configure session, choose between: @@ -184,8 +229,11 @@ class WWDCVideosController { /* Success */ // let statusCode = (response as! NSHTTPURLResponse).statusCode // print("URL Session Task Succeeded: HTTP \(statusCode)") - result = String.init(data: data!, encoding: - .utf8)! + if let data = data, let string = String.init(data: data, encoding: + .utf8) { + result = string + + } } else { /* Failure */