gpt4 book ai didi

android - iOS 从 Google Drive Swift 流视频

转载 作者:行者123 更新时间:2023-11-30 13:07:36 25 4
gpt4 key购买 nike

我正在构建一个 iOS 应用程序,它可以从 Google 驱动视频流,视频链接如下所示

https://drive.google.com/file/d/0B2Kri7-TaAFJSlJ4UTJuSElGamM/preview

从上面的 URL 获取 Stream Link 的唯一方法是解码 webView HTML

代码:

let myURLString = "https://drive.google.com/file/d/0B2Kri7-TaAFJSlJ4UTJuSElGamM/preview"

if let myURL = NSURL(string: myURLString) {

do {
let myHTMLString = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)
print("HTML : \(myHTMLString)")

} catch {
print("Error : \(error)")
}
} else {
print("Error: \(myURLString) doesn't URL")
}

这样做之后我得到了 webView 的 HTML

问题是:

我在 HTML 中寻找的是这个“fmt_stream_map”,它包含我也需要的所有流媒体链接流视频,但我不知道如何访问它并获取来自其中的 Steam 链接。

PS:我正在与一位 Android 开发人员合作,他告诉我他使用了 this解决问题的方法,但他无法向我解释,而且我不懂java

最佳答案

我使用以下方法解决了问题:

        let myURLString = "https://drive.google.com/file/d/0B1XhqDeOfqG7UWZSaG1ZbFFhSzQ/preview"

if let myURL = NSURL(string: myURLString) {

do {
let myHTMLString = try String(contentsOfURL: myURL, encoding: NSUTF8StringEncoding)

let t = myHTMLString

if let rangeOfZero = t.rangeOfString("plid", options: NSStringCompareOptions.BackwardsSearch) {

let suffix = String(t.characters.suffixFrom(rangeOfZero.endIndex))

// print(suffix)

let input = "\(suffix)"
let detector = try! NSDataDetector(types: NSTextCheckingType.Link.rawValue)
let matches = detector.matchesInString(input, options: [], range: NSRange(location: 0, length: input.utf8.count))

// print(matches)
for match in matches {

let url = (input as NSString).substringWithRange(match.range)

linksA.append(url)

}

theLink()

} else {
print("noooo")
}
} catch {
print("Error : \(error)")
}
} else {
print("Error: \(myURLString) doesn't URL")
}

之后您需要使用此方法解码流链接:

    func theLink() {


/// /[u]00../g


let firstElement = linksA.first

let t = firstElement!.stringByReplacingOccurrencesOfString(",35", withString: "")

let deUrl = t.characters.split{$0 == "|"}.map(String.init)

let link = deUrl[0]

// the link needs to be decoded

let i = link.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)


let p = i!.stringByReplacingOccurrencesOfString("%5Cu", withString: "")


// you can see how the link should look like here :
// http://ddecode.com/hexdecoder/?results=d82d4e564eccc1a6b96ee7c5c1e1c3b2

// %252C : ,
// 003d : =
// 0026 : &

let re = p.stringByReplacingOccurrencesOfString("003d", withString: "=")
let y = re.stringByReplacingOccurrencesOfString("0026", withString: "&")
let c = y.stringByReplacingOccurrencesOfString("%252C", withString: ",")

print(c) }

你可以看到所有代码Here

关于android - iOS 从 Google Drive Swift 流视频,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39157727/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com