Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // videoResolvers.swift
- // AnimeIOS2
- //
- // Created by Luis Gracia Tejero on 06/08/2019.
- // Copyright © 2019 Luis Gracia Tejero. All rights reserved.
- //
- import Foundation
- import Alamofire
- import SwiftSoup
- import Darwin
- struct mp4Links {
- let link : String
- }
- struct qualityLinks {
- let link : String
- let quality : String
- }
- struct fembedData : Decodable {
- let data : [fembedLinks]
- }
- struct fembedLinks: Decodable {
- let file : String
- let label : String
- }
- struct fembed {
- static func aviableLinks(link: String, completion: @escaping ([qualityLinks])->()) {
- let fixedLink = link.replacingOccurrences(of: "/v/", with: "/api/source/")
- Alamofire.request(fixedLink, method:.post).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- var diccionarioLink = [qualityLinks]()
- let data = content.data(using: .utf8)!
- let theLinks = try JSONDecoder().decode(fembedData.self, from: data)
- for x in theLinks.data{
- let codes = qualityLinks(link: x.file, quality: x.label)
- diccionarioLink.append(codes)
- }
- completion(diccionarioLink)
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- completion([qualityLinks]())
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct rapidVideo {
- static func aviableLinks(link: String, completion: @escaping ([qualityLinks])->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- var diccionarioLink = [qualityLinks]()
- let doc: Document = try SwiftSoup.parse(content)
- let sourceTags = try! doc.select("source")
- for tag: Element in sourceTags {
- let link : String = try tag.attr("src").description
- let label : String = try tag.attr("label").description
- let dict = qualityLinks(link: link, quality: label)
- diccionarioLink.append(dict)
- }
- completion(diccionarioLink)
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- completion([qualityLinks]())
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct natsukiLink: Decodable {
- let file : String
- }
- struct natsuki {
- static func aviableLinks(link: String, completion: @escaping (mp4Links)->()) {
- let cf_clearance = UserDefaults.standard.string(forKey: "cf_clearance") ?? ""
- 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"
- let headers = ["device":"computer","cf_clearance":cf_clearance,"User-Agent":agent]
- let fixedLink = link.replacingOccurrences(of: "embed", with: "check")
- Alamofire.request(fixedLink, headers: headers as? HTTPHeaders ).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let data = content.data(using: .utf8)!
- let theLinks = try JSONDecoder().decode(natsukiLink.self, from: data)
- let link = mp4Links(link: theLinks.file)
- completion(link)
- } catch {
- }
- } else {
- print("error need bypass")
- completion(mp4Links(link: "lol"))
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct okruArray : Decodable {
- let videos : [okruQuality]
- }
- struct okruQuality: Decodable {
- let name : String
- let url : String
- }
- struct okru {
- static func aviableLinks(link: String, completion: @escaping ([[String : String]],String)->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- var linksDict = [[String : String]]()
- let doc: Document = try SwiftSoup.parse(content)
- let scriptTags : Elements = try doc.select("[data-module=\"OKVideo\"]")
- var link : String = try scriptTags.attr("data-options").description
- let J1 = link.components(separatedBy: "\\\"videos")
- let J2 = J1[1].components(separatedBy: ",\\\"metadataEmbedded")
- link = "{\"videos" + J2[0].replacingOccurrences(of: "\\"", with: "\"").replacingOccurrences(of: "\\u0026", with: "&").replacingOccurrences(of: "\\", with: "").replacingOccurrences(of: "%3B", with: ";") + "}"
- let data = link.data(using: .utf8)!
- let theLinks = try JSONDecoder().decode(okruArray.self, from: data)
- for x in theLinks.videos {
- let dict = ["Quality": x.name, "link": x.url]
- linksDict.append(dict)
- }
- print(linksDict)
- completion(linksDict,"Yes")
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- completion([[String : String]](),"No")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct seeds {
- let encodedSingnature : String
- let seed1 : String
- let seed2 : String
- }
- struct openload {
- static func seedsAnalizer(link: String, completion: @escaping (seeds)->()) {
- var fixedLink = link
- if link.contains("oload.tv") {
- fixedLink = fixedLink.replacingOccurrences(of: "https://oload.tv/embed/", with: "https://openload.co/embed/")
- }
- print(fixedLink)
- Alamofire.request(fixedLink).responseString { response in
- print(response.response?.statusCode)
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- if !content.contains("It maybe got deleted by the owner or was removed due a copyright violation") {
- let encodedSingnature = try doc.select("p").after("<div class=\"\" style=\"display:none;\">").text().replacingOccurrences(of: " 640K ought to be enough for anybody", with: "")
- let seed1 = content.components(separatedBy: "_0x30725e,")[1].components(separatedBy: "),_1x4bfb36)")[0]
- let seed2 = content.components(separatedBy: "_1x4bfb36=")[1].components(separatedBy: ";")[0]
- completion(seeds(encodedSingnature: encodedSingnature, seed1: seed1, seed2: seed2))
- }
- } catch {
- print("error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- static func generateLinks(seeds: seeds, completion: @escaping (mp4Links)->()) {
- print(seeds)
- let encodeSingatureStart = seeds.encodedSingnature.prefix(72)
- let encodeSingatureEnds = seeds.encodedSingnature.replacingOccurrences(of: encodeSingatureStart, with: "")
- var ivArray = [Int]()
- var i = 0
- var signature = ""
- while i < encodeSingatureStart.count {
- let startIndex = i
- let endIndex = i + 8
- let start = String.Index(utf16Offset: startIndex, in: encodeSingatureStart)
- let end = String.Index(utf16Offset: endIndex, in: encodeSingatureStart)
- let iv = String(encodeSingatureStart[start..<end]) // This could be wrong
- ivArray.append(Int(iv, radix: 16) ?? 0)
- i = i + 8
- }
- var iv_index = 0
- var x = 0
- while x < encodeSingatureEnds.count {
- var unknown_2 = 0
- var unknown_3 = 0
- var unknown_4 = 0
- repeat {
- let startIndex = x
- let endIndex = x + 2
- let start = String.Index(utf16Offset: startIndex, in: encodeSingatureEnds)
- let end = String.Index(utf16Offset: endIndex, in: encodeSingatureEnds)
- let unknown_5 = String(encodeSingatureEnds[start..<end]) // This could be wrong
- unknown_4 = Int(unknown_5, radix: 16) ?? 0
- let unknown_6 = unknown_4 & 63
- if unknown_3 < 30 {
- unknown_2 = unknown_2 + unknown_6 << unknown_3
- } else {
- unknown_2 = unknown_2 + unknown_6 * Int(pow(Double(2), Double(unknown_3)))
- print(unknown_2)
- }
- unknown_3 = unknown_3 + 6
- x = x + 2
- } while unknown_4 >= 64
- var IV = unknown_2 ^ ivArray[iv_index % 9]
- IV = (IV ^ Int(seeds.seed2)!) ^ Int(seeds.seed1)!
- var unknown_8 = 255
- var j = 0
- while j < 4 {
- let charcode = ((IV & unknown_8) >> (8 * j)) - 1
- let character = String(UnicodeScalar(UInt8(charcode))) // Could be wrong
- if character != "$" {
- signature = signature + character
- print(signature)
- }
- unknown_8 = unknown_8 << 8
- j = j + 1
- }
- iv_index = iv_index + 1
- }
- print("https://openload.co/stream/" + signature)
- completion(mp4Links(link: "https://openload.co/stream/" + signature))
- } // Func
- }
- struct gogodefaultArray : Decodable {
- let sources : [gogoQuality]
- }
- struct gogoQuality: Decodable {
- let file : String
- let label : String
- }
- struct GogoDefault {
- static func aviableLinks(link: String, completion: @escaping ([qualityLinks])->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- var links = [qualityLinks]()
- let doc: Document = try SwiftSoup.parse(content)
- let scriptTags = try! doc.select("script")
- var json = ""
- for tag: Element in scriptTags {
- for node : DataNode in tag.dataNodes() {
- let myText = node.getWholeData()
- if myText.contains("playerInstance.setup") {
- let j1 = myText.components(separatedBy: "playerInstance.setup({")[1]
- let j2 = j1.components(separatedBy: "}],")[0]
- let j3 = j2.replacingOccurrences(of: "sources", with: "{\"sources\"").replacingOccurrences(of: "file", with: "\"file\"").replacingOccurrences(of: "'", with: "\"").replacingOccurrences(of: "label", with: "\"label\"") + "}]}"
- json = j3
- print(j3)
- }
- }
- }
- let data = json.data(using: .utf8)!
- let theLinks = try JSONDecoder().decode(gogodefaultArray.self, from: data)
- for x in theLinks.sources{
- let category = qualityLinks(link: x.file, quality: x.label.replacingOccurrences(of: " P", with: "" ))
- links.append(category)
- print(x.file,x.label)
- }
- completion(links)
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct mp4UploadScript {
- static func scriptGetter(link: String, completion: @escaping (String)->()) {
- if !link.contains(".php?s=mp4upload") {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- let scriptTags = try! doc.select("script")
- for tag: Element in scriptTags {
- for node : DataNode in tag.dataNodes() {
- let text = node.getWholeData()
- if text.contains("var check = 0;") {
- animeFlvScript(data: text, completion: { (link) in
- })
- } else if text.contains("eval(function(p,a,c,k,e,d)") {
- let script = text.replacingOccurrences(of: "eval", with: "")
- completion(script ?? "")
- } else {
- }
- }
- }
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- }
- } // Func
- static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
- print(data)
- let j1 = data.components(separatedBy: ".src(\"")
- if j1.count > 0 {
- let j2 = j1[1].components(separatedBy: "\");player")[0]
- completion(mp4Links(link: j2))
- }
- } // Func
- static func animeFlvScript(data: String, completion: @escaping (String)->()) {
- let fixedLink = "https://s1.animeflv.net/" + data.components(separatedBy: "var check_url = '")[1].components(separatedBy: "';")[0]
- Alamofire.request( fixedLink).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct YourUploadResolver {
- static func mp4Link(link: String, completion: @escaping (mp4Links,String)->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let defaultURL = URL(string: "")
- let doc: Document = try SwiftSoup.parse(content)
- let scriptTags = try! doc.select("script")
- for tag: Element in scriptTags {
- for node : DataNode in tag.dataNodes() {
- let myText = node.getWholeData()
- if myText.contains("var jwplayerOptions") {
- let j1 = myText.components(separatedBy: "file: '")[1]
- let j2 = j1.components(separatedBy: "',")[0]
- completion(mp4Links(link: j2), response.response?.url?.absoluteString ?? "")
- }
- }
- }
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct StreaMangoResolver {
- static func resolver(data: String, completion: @escaping (mp4Links)->()) {
- do {
- let doc: Document = try SwiftSoup.parse(data)
- let link = try doc.select("video").attr("src").description
- completion(mp4Links(link:"https:" + link))
- } catch {
- }
- } // Func
- }
- struct jkmediaResolver {
- static func mp4Link(link: String, completion: @escaping (mp4Links)->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- let vide = try doc.select("source").attr("src").description
- completion(mp4Links(link: vide))
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct defaultResolver {
- static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
- do {
- let doc: Document = try SwiftSoup.parse(data)
- let source = try doc.select("source").attr("src").description
- completion(mp4Links(link: source))
- } catch {
- }
- } // Func
- }
- struct veryStreamResolver {
- static func mp4Link(link: String, completion: @escaping (mp4Links)->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- let vide = try doc.getElementById("videolink")?.text() ?? ""
- completion(mp4Links(link: "https://verystream.com/gettoken/" + vide))
- print(vide)
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct streamCherryResolver {
- static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
- do {
- let doc: Document = try SwiftSoup.parse(data)
- let source = try doc.select("video").attr("src").description
- completion(mp4Links(link:"https:" + source))
- } catch {
- }
- } // Func
- }
- struct uqloadResolver {
- static func mp4Link(link: String, completion: @escaping (mp4Links)->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- let scriptTags = try! doc.select("script")
- for tag: Element in scriptTags {
- for node : DataNode in tag.dataNodes() {
- let myText = node.getWholeData()
- if myText.contains("Clappr.Player({") {
- let j1 = myText.components(separatedBy: "sources: [\"")[1]
- let j2 = j1.components(separatedBy: "\"],")[0]
- print(j2)
- completion(mp4Links(link:j2))
- }
- }
- }
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct clipwatchingEval {
- static func mp4Link(link: String, completion: @escaping (String)->()) {
- Alamofire.request(link).responseString { response in
- if let content: String = response.result.value {
- if response.response?.statusCode == 200 {
- do {
- let doc: Document = try SwiftSoup.parse(content)
- let scriptTags = try! doc.select("script")
- for tag: Element in scriptTags {
- for node : DataNode in tag.dataNodes() {
- let myText = node.getWholeData()
- if myText.contains("eval(function(p,a,c,k,e,d)") {
- let j1 = myText.replacingOccurrences(of: "eval", with: "")
- completion(j1)
- }
- }
- }
- } catch {
- print("Error")
- }
- } else {
- print("error need bypass")
- print(response.response?.statusCode as Any)
- } // If status code is different 200
- } // First If
- } // Alamofire
- } // Func
- }
- struct clipWatchingResolver {
- static func mp4Link(data: String, completion: @escaping (mp4Links)->()) {
- do {
- let source = data.components(separatedBy: "file:\"")[1].components(separatedBy: "\",label")[0]
- completion(mp4Links(link:source))
- } catch {
- }
- } // Func
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement