Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.75 KB | None | 0 0
  1. //
  2. // videoResolvers.swift
  3. // AnimeIOS2
  4. //
  5. // Created by Luis Gracia Tejero on 06/08/2019.
  6. // Copyright © 2019 Luis Gracia Tejero. All rights reserved.
  7. //
  8.  
  9. import Foundation
  10. import Alamofire
  11. import SwiftSoup
  12. import Darwin
  13.  
  14. struct mp4Links {
  15. let link : String
  16. }
  17.  
  18. struct qualityLinks {
  19. let link : String
  20. let quality : String
  21. }
  22.  
  23. struct fembedData : Decodable {
  24. let data : [fembedLinks]
  25. }
  26.  
  27. struct fembedLinks: Decodable {
  28. let file : String
  29. let label : String
  30. }
  31.  
  32. struct fembed {
  33. static func aviableLinks(link: String, completion: @escaping ([qualityLinks])->()) {
  34. let fixedLink = link.replacingOccurrences(of: "/v/", with: "/api/source/")
  35.  
  36. Alamofire.request(fixedLink, method:.post).responseString { response in
  37. if let content: String = response.result.value {
  38. if response.response?.statusCode == 200 {
  39.  
  40. do {
  41. var diccionarioLink = [qualityLinks]()
  42.  
  43. let data = content.data(using: .utf8)!
  44.  
  45.  
  46. let theLinks = try JSONDecoder().decode(fembedData.self, from: data)
  47.  
  48. for x in theLinks.data{
  49. let codes = qualityLinks(link: x.file, quality: x.label)
  50. diccionarioLink.append(codes)
  51.  
  52. }
  53.  
  54. completion(diccionarioLink)
  55. } catch {
  56.  
  57. print("Error")
  58.  
  59.  
  60. }
  61.  
  62.  
  63.  
  64. } else {
  65. print("error need bypass")
  66. completion([qualityLinks]())
  67. print(response.response?.statusCode as Any)
  68.  
  69. } // If status code is different 200
  70. } // First If
  71. } // Alamofire
  72. } // Func
  73.  
  74. }
  75.  
  76.  
  77.  
  78. struct rapidVideo {
  79.  
  80. static func aviableLinks(link: String, completion: @escaping ([qualityLinks])->()) {
  81.  
  82. Alamofire.request(link).responseString { response in
  83. if let content: String = response.result.value {
  84. if response.response?.statusCode == 200 {
  85.  
  86. do {
  87. var diccionarioLink = [qualityLinks]()
  88.  
  89. let doc: Document = try SwiftSoup.parse(content)
  90. let sourceTags = try! doc.select("source")
  91. for tag: Element in sourceTags {
  92.  
  93. let link : String = try tag.attr("src").description
  94. let label : String = try tag.attr("label").description
  95. let dict = qualityLinks(link: link, quality: label)
  96. diccionarioLink.append(dict)
  97. }
  98.  
  99. completion(diccionarioLink)
  100.  
  101. } catch {
  102.  
  103. print("Error")
  104.  
  105.  
  106. }
  107.  
  108. } else {
  109. print("error need bypass")
  110. completion([qualityLinks]())
  111. print(response.response?.statusCode as Any)
  112.  
  113. } // If status code is different 200
  114. } // First If
  115. } // Alamofire
  116. } // Func
  117. }
  118.  
  119. struct natsukiLink: Decodable {
  120. let file : String
  121. }
  122.  
  123. struct natsuki {
  124.  
  125. static func aviableLinks(link: String, completion: @escaping (mp4Links)->()) {
  126.  
  127. let cf_clearance = UserDefaults.standard.string(forKey: "cf_clearance") ?? ""
  128. let agent = UserDefaults.standard.string(forKey: "agent") ?? "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/605.1.12 (KHTML, like Gecko) Version/11.1 Safari/605.1.12"
  129.  
  130.  
  131. let headers = ["device":"computer","cf_clearance":cf_clearance,"User-Agent":agent]
  132. let fixedLink = link.replacingOccurrences(of: "embed", with: "check")
  133.  
  134. Alamofire.request(fixedLink, headers: headers as? HTTPHeaders ).responseString { response in
  135. if let content: String = response.result.value {
  136. if response.response?.statusCode == 200 {
  137.  
  138. do {
  139. let data = content.data(using: .utf8)!
  140. let theLinks = try JSONDecoder().decode(natsukiLink.self, from: data)
  141. let link = mp4Links(link: theLinks.file)
  142. completion(link)
  143.  
  144. } catch {
  145.  
  146. }
  147.  
  148. } else {
  149. print("error need bypass")
  150. completion(mp4Links(link: "lol"))
  151. print(response.response?.statusCode as Any)
  152.  
  153. } // If status code is different 200
  154. } // First If
  155. } // Alamofire
  156. } // Func
  157. }
  158.  
  159. struct okruArray : Decodable {
  160. let videos : [okruQuality]
  161. }
  162.  
  163. struct okruQuality: Decodable {
  164. let name : String
  165. let url : String
  166. }
  167.  
  168. struct okru {
  169.  
  170. static func aviableLinks(link: String, completion: @escaping ([[String : String]],String)->()) {
  171.  
  172. Alamofire.request(link).responseString { response in
  173. if let content: String = response.result.value {
  174. if response.response?.statusCode == 200 {
  175.  
  176. do {
  177. var linksDict = [[String : String]]()
  178. let doc: Document = try SwiftSoup.parse(content)
  179. let scriptTags : Elements = try doc.select("[data-module=\"OKVideo\"]")
  180. var link : String = try scriptTags.attr("data-options").description
  181.  
  182. let J1 = link.components(separatedBy: "\\\"videos")
  183. let J2 = J1[1].components(separatedBy: ",\\\"metadataEmbedded")
  184.  
  185. link = "{\"videos" + J2[0].replacingOccurrences(of: "\\"", with: "\"").replacingOccurrences(of: "\\u0026", with: "&").replacingOccurrences(of: "\\", with: "").replacingOccurrences(of: "%3B", with: ";") + "}"
  186.  
  187. let data = link.data(using: .utf8)!
  188.  
  189. let theLinks = try JSONDecoder().decode(okruArray.self, from: data)
  190.  
  191. for x in theLinks.videos {
  192.  
  193. let dict = ["Quality": x.name, "link": x.url]
  194. linksDict.append(dict)
  195.  
  196. }
  197.  
  198. print(linksDict)
  199. completion(linksDict,"Yes")
  200. } catch {
  201.  
  202. print("Error")
  203.  
  204. }
  205. } else {
  206. print("error need bypass")
  207. completion([[String : String]](),"No")
  208. print(response.response?.statusCode as Any)
  209.  
  210. } // If status code is different 200
  211. } // First If
  212. } // Alamofire
  213. } // Func
  214. }
  215.  
  216.  
  217. struct seeds {
  218. let encodedSingnature : String
  219. let seed1 : String
  220. let seed2 : String
  221. }
  222.  
  223. struct openload {
  224.  
  225. static func seedsAnalizer(link: String, completion: @escaping (seeds)->()) {
  226. var fixedLink = link
  227. if link.contains("oload.tv") {
  228. fixedLink = fixedLink.replacingOccurrences(of: "https://oload.tv/embed/", with: "https://openload.co/embed/")
  229. }
  230. print(fixedLink)
  231. Alamofire.request(fixedLink).responseString { response in
  232. print(response.response?.statusCode)
  233. if let content: String = response.result.value {
  234. if response.response?.statusCode == 200 {
  235. do {
  236.  
  237. let doc: Document = try SwiftSoup.parse(content)
  238. if !content.contains("It maybe got deleted by the owner or was removed due a copyright violation") {
  239. let encodedSingnature = try doc.select("p").after("<div class=\"\" style=\"display:none;\">").text().replacingOccurrences(of: " 640K ought to be enough for anybody", with: "")
  240. let seed1 = content.components(separatedBy: "_0x30725e,")[1].components(separatedBy: "),_1x4bfb36)")[0]
  241. let seed2 = content.components(separatedBy: "_1x4bfb36=")[1].components(separatedBy: ";")[0]
  242. completion(seeds(encodedSingnature: encodedSingnature, seed1: seed1, seed2: seed2))
  243. }
  244.  
  245. } catch {
  246.  
  247. print("error")
  248. }
  249.  
  250. } else {
  251.  
  252. print("error need bypass")
  253. print(response.response?.statusCode as Any)
  254.  
  255. } // If status code is different 200
  256. } // First If
  257. } // Alamofire
  258. } // Func
  259.  
  260. static func generateLinks(seeds: seeds, completion: @escaping (mp4Links)->()) {
  261.  
  262. print(seeds)
  263.  
  264. let encodeSingatureStart = seeds.encodedSingnature.prefix(72)
  265. let encodeSingatureEnds = seeds.encodedSingnature.replacingOccurrences(of: encodeSingatureStart, with: "")
  266.  
  267. var ivArray = [Int]()
  268. var i = 0
  269. var signature = ""
  270.  
  271. while i < encodeSingatureStart.count {
  272. let startIndex = i
  273. let endIndex = i + 8
  274. let start = String.Index(utf16Offset: startIndex, in: encodeSingatureStart)
  275. let end = String.Index(utf16Offset: endIndex, in: encodeSingatureStart)
  276. let iv = String(encodeSingatureStart[start..<end]) // This could be wrong
  277. ivArray.append(Int(iv, radix: 16) ?? 0)
  278.  
  279. i = i + 8
  280. }
  281.  
  282. var iv_index = 0
  283. var x = 0
  284.  
  285. while x < encodeSingatureEnds.count {
  286.  
  287. var unknown_2 = 0
  288. var unknown_3 = 0
  289. var unknown_4 = 0
  290.  
  291. repeat {
  292.  
  293. let startIndex = x
  294. let endIndex = x + 2
  295. let start = String.Index(utf16Offset: startIndex, in: encodeSingatureEnds)
  296. let end = String.Index(utf16Offset: endIndex, in: encodeSingatureEnds)
  297.  
  298. let unknown_5 = String(encodeSingatureEnds[start..<end]) // This could be wrong
  299.  
  300. unknown_4 = Int(unknown_5, radix: 16) ?? 0
  301.  
  302. let unknown_6 = unknown_4 & 63
  303.  
  304. if unknown_3 < 30 {
  305. unknown_2 = unknown_2 + unknown_6 << unknown_3
  306. } else {
  307. unknown_2 = unknown_2 + unknown_6 * Int(pow(Double(2), Double(unknown_3)))
  308. print(unknown_2)
  309. }
  310.  
  311. unknown_3 = unknown_3 + 6
  312.  
  313. x = x + 2
  314.  
  315. } while unknown_4 >= 64
  316.  
  317. var IV = unknown_2 ^ ivArray[iv_index % 9]
  318. IV = (IV ^ Int(seeds.seed2)!) ^ Int(seeds.seed1)!
  319.  
  320. var unknown_8 = 255
  321. var j = 0
  322.  
  323. while j < 4 {
  324.  
  325. let charcode = ((IV & unknown_8) >> (8 * j)) - 1
  326. let character = String(UnicodeScalar(UInt8(charcode))) // Could be wrong
  327.  
  328. if character != "$" {
  329. signature = signature + character
  330. print(signature)
  331. }
  332.  
  333. unknown_8 = unknown_8 << 8
  334. j = j + 1
  335. }
  336.  
  337. iv_index = iv_index + 1
  338. }
  339. print("https://openload.co/stream/" + signature)
  340.  
  341. completion(mp4Links(link: "https://openload.co/stream/" + signature))
  342.  
  343. } // Func
  344. }
  345.  
  346. struct gogodefaultArray : Decodable {
  347. let sources : [gogoQuality]
  348. }
  349.  
  350. struct gogoQuality: Decodable {
  351. let file : String
  352. let label : String
  353. }
  354.  
  355. struct GogoDefault {
  356.  
  357. static func aviableLinks(link: String, completion: @escaping ([qualityLinks])->()) {
  358.  
  359. Alamofire.request(link).responseString { response in
  360. if let content: String = response.result.value {
  361. if response.response?.statusCode == 200 {
  362.  
  363. do {
  364. var links = [qualityLinks]()
  365. let doc: Document = try SwiftSoup.parse(content)
  366. let scriptTags = try! doc.select("script")
  367. var json = ""
  368. for tag: Element in scriptTags {
  369. for node : DataNode in tag.dataNodes() {
  370. let myText = node.getWholeData()
  371. if myText.contains("playerInstance.setup") {
  372. let j1 = myText.components(separatedBy: "playerInstance.setup({")[1]
  373. let j2 = j1.components(separatedBy: "}],")[0]
  374. let j3 = j2.replacingOccurrences(of: "sources", with: "{\"sources\"").replacingOccurrences(of: "file", with: "\"file\"").replacingOccurrences(of: "'", with: "\"").replacingOccurrences(of: "label", with: "\"label\"") + "}]}"
  375. json = j3
  376. print(j3)
  377. }
  378. }
  379. }
  380.  
  381. let data = json.data(using: .utf8)!
  382. let theLinks = try JSONDecoder().decode(gogodefaultArray.self, from: data)
  383. for x in theLinks.sources{
  384. let category = qualityLinks(link: x.file, quality: x.label.replacingOccurrences(of: " P", with: "" ))
  385. links.append(category)
  386. print(x.file,x.label)
  387. }
  388. completion(links)
  389. } catch {
  390.  
  391. print("Error")
  392.  
  393. }
  394. } else {
  395. print("error need bypass")
  396.  
  397. print(response.response?.statusCode as Any)
  398.  
  399. } // If status code is different 200
  400. } // First If
  401. } // Alamofire
  402. } // Func
  403. }
  404.  
  405. struct mp4UploadScript {
  406.  
  407. static func scriptGetter(link: String, completion: @escaping (String)->()) {
  408.  
  409. if !link.contains(".php?s=mp4upload") {
  410. Alamofire.request(link).responseString { response in
  411. if let content: String = response.result.value {
  412. if response.response?.statusCode == 200 {
  413.  
  414. do {
  415. let doc: Document = try SwiftSoup.parse(content)
  416. let scriptTags = try! doc.select("script")
  417. for tag: Element in scriptTags {
  418. for node : DataNode in tag.dataNodes() {
  419. let text = node.getWholeData()
  420. if text.contains("var check = 0;") {
  421. animeFlvScript(data: text, completion: { (link) in
  422.  
  423. })
  424. } else if text.contains("eval(function(p,a,c,k,e,d)") {
  425. let script = text.replacingOccurrences(of: "eval", with: "")
  426. completion(script ?? "")
  427. } else {
  428.  
  429. }
  430. }
  431. }
  432.  
  433.  
  434. } catch {
  435.  
  436. print("Error")
  437.  
  438. }
  439. } else {
  440. print("error need bypass")
  441.  
  442. print(response.response?.statusCode as Any)
  443.  
  444. } // If status code is different 200
  445. } // First If
  446. } // Alamofire
  447. }
  448.  
  449. } // Func
  450.  
  451. static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
  452. print(data)
  453. let j1 = data.components(separatedBy: ".src(\"")
  454. if j1.count > 0 {
  455. let j2 = j1[1].components(separatedBy: "\");player")[0]
  456. completion(mp4Links(link: j2))
  457. }
  458.  
  459.  
  460.  
  461.  
  462.  
  463. } // Func
  464.  
  465. static func animeFlvScript(data: String, completion: @escaping (String)->()) {
  466.  
  467. let fixedLink = "https://s1.animeflv.net/" + data.components(separatedBy: "var check_url = '")[1].components(separatedBy: "';")[0]
  468.  
  469. Alamofire.request( fixedLink).responseString { response in
  470. if let content: String = response.result.value {
  471. if response.response?.statusCode == 200 {
  472.  
  473. do {
  474. let doc: Document = try SwiftSoup.parse(content)
  475.  
  476. } catch {
  477.  
  478. print("Error")
  479.  
  480. }
  481. } else {
  482. print("error need bypass")
  483.  
  484. print(response.response?.statusCode as Any)
  485.  
  486. } // If status code is different 200
  487. } // First If
  488. } // Alamofire
  489.  
  490. } // Func
  491. }
  492.  
  493.  
  494. struct YourUploadResolver {
  495.  
  496.  
  497. static func mp4Link(link: String, completion: @escaping (mp4Links,String)->()) {
  498.  
  499. Alamofire.request(link).responseString { response in
  500. if let content: String = response.result.value {
  501. if response.response?.statusCode == 200 {
  502.  
  503. do {
  504. let defaultURL = URL(string: "")
  505. let doc: Document = try SwiftSoup.parse(content)
  506. let scriptTags = try! doc.select("script")
  507. for tag: Element in scriptTags {
  508. for node : DataNode in tag.dataNodes() {
  509. let myText = node.getWholeData()
  510. if myText.contains("var jwplayerOptions") {
  511. let j1 = myText.components(separatedBy: "file: '")[1]
  512. let j2 = j1.components(separatedBy: "',")[0]
  513. completion(mp4Links(link: j2), response.response?.url?.absoluteString ?? "")
  514. }
  515. }
  516. }
  517.  
  518. } catch {
  519.  
  520. print("Error")
  521.  
  522. }
  523. } else {
  524. print("error need bypass")
  525.  
  526. print(response.response?.statusCode as Any)
  527.  
  528. } // If status code is different 200
  529. } // First If
  530. } // Alamofire
  531. } // Func
  532. }
  533.  
  534.  
  535.  
  536. struct StreaMangoResolver {
  537.  
  538. static func resolver(data: String, completion: @escaping (mp4Links)->()) {
  539. do {
  540. let doc: Document = try SwiftSoup.parse(data)
  541. let link = try doc.select("video").attr("src").description
  542. completion(mp4Links(link:"https:" + link))
  543. } catch {
  544.  
  545. }
  546.  
  547.  
  548. } // Func
  549.  
  550. }
  551.  
  552.  
  553. struct jkmediaResolver {
  554.  
  555. static func mp4Link(link: String, completion: @escaping (mp4Links)->()) {
  556.  
  557. Alamofire.request(link).responseString { response in
  558. if let content: String = response.result.value {
  559. if response.response?.statusCode == 200 {
  560.  
  561. do {
  562. let doc: Document = try SwiftSoup.parse(content)
  563. let vide = try doc.select("source").attr("src").description
  564. completion(mp4Links(link: vide))
  565.  
  566. } catch {
  567.  
  568. print("Error")
  569.  
  570. }
  571. } else {
  572. print("error need bypass")
  573.  
  574. print(response.response?.statusCode as Any)
  575.  
  576. } // If status code is different 200
  577. } // First If
  578. } // Alamofire
  579. } // Func
  580. }
  581.  
  582. struct defaultResolver {
  583.  
  584. static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
  585. do {
  586. let doc: Document = try SwiftSoup.parse(data)
  587. let source = try doc.select("source").attr("src").description
  588. completion(mp4Links(link: source))
  589. } catch {
  590.  
  591. }
  592.  
  593. } // Func
  594. }
  595.  
  596. struct veryStreamResolver {
  597.  
  598. static func mp4Link(link: String, completion: @escaping (mp4Links)->()) {
  599.  
  600. Alamofire.request(link).responseString { response in
  601. if let content: String = response.result.value {
  602. if response.response?.statusCode == 200 {
  603.  
  604. do {
  605. let doc: Document = try SwiftSoup.parse(content)
  606. let vide = try doc.getElementById("videolink")?.text() ?? ""
  607. completion(mp4Links(link: "https://verystream.com/gettoken/" + vide))
  608. print(vide)
  609. } catch {
  610.  
  611. print("Error")
  612.  
  613. }
  614. } else {
  615. print("error need bypass")
  616.  
  617. print(response.response?.statusCode as Any)
  618.  
  619. } // If status code is different 200
  620. } // First If
  621. } // Alamofire
  622. } // Func
  623. }
  624.  
  625. struct streamCherryResolver {
  626.  
  627. static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
  628. do {
  629. let doc: Document = try SwiftSoup.parse(data)
  630. let source = try doc.select("video").attr("src").description
  631. completion(mp4Links(link:"https:" + source))
  632. } catch {
  633.  
  634. }
  635.  
  636. } // Func
  637. }
  638.  
  639. struct uqloadResolver {
  640.  
  641. static func mp4Link(link: String, completion: @escaping (mp4Links)->()) {
  642.  
  643. Alamofire.request(link).responseString { response in
  644. if let content: String = response.result.value {
  645. if response.response?.statusCode == 200 {
  646.  
  647. do {
  648. let doc: Document = try SwiftSoup.parse(content)
  649. let scriptTags = try! doc.select("script")
  650. for tag: Element in scriptTags {
  651. for node : DataNode in tag.dataNodes() {
  652. let myText = node.getWholeData()
  653. if myText.contains("Clappr.Player({") {
  654. let j1 = myText.components(separatedBy: "sources: [\"")[1]
  655. let j2 = j1.components(separatedBy: "\"],")[0]
  656. print(j2)
  657. completion(mp4Links(link:j2))
  658. }
  659. }
  660. }
  661. } catch {
  662.  
  663. print("Error")
  664.  
  665. }
  666. } else {
  667. print("error need bypass")
  668.  
  669. print(response.response?.statusCode as Any)
  670.  
  671. } // If status code is different 200
  672. } // First If
  673. } // Alamofire
  674. } // Func
  675. }
  676.  
  677. struct clipwatchingEval {
  678.  
  679. static func mp4Link(link: String, completion: @escaping (String)->()) {
  680.  
  681. Alamofire.request(link).responseString { response in
  682. if let content: String = response.result.value {
  683. if response.response?.statusCode == 200 {
  684.  
  685. do {
  686. let doc: Document = try SwiftSoup.parse(content)
  687. let scriptTags = try! doc.select("script")
  688. for tag: Element in scriptTags {
  689. for node : DataNode in tag.dataNodes() {
  690. let myText = node.getWholeData()
  691. if myText.contains("eval(function(p,a,c,k,e,d)") {
  692. let j1 = myText.replacingOccurrences(of: "eval", with: "")
  693. completion(j1)
  694. }
  695. }
  696. }
  697. } catch {
  698.  
  699. print("Error")
  700.  
  701. }
  702. } else {
  703. print("error need bypass")
  704.  
  705. print(response.response?.statusCode as Any)
  706.  
  707. } // If status code is different 200
  708. } // First If
  709. } // Alamofire
  710. } // Func
  711. }
  712.  
  713. struct clipWatchingResolver {
  714.  
  715. static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
  716. do {
  717. let source = data.components(separatedBy: "file:\"")[1].components(separatedBy: "\",label")[0]
  718. completion(mp4Links(link:source))
  719. } catch {
  720.  
  721. }
  722.  
  723. } // Func
  724. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement