fixed login and better video url selection

This commit is contained in:
Jens Timmerman 2021-09-14 23:26:12 +02:00
parent 1a37e51dd4
commit e2ad6c0610
1 changed files with 23 additions and 15 deletions

View File

@ -51,7 +51,15 @@ struct Episode: Hashable, Comparable{
let duration = videojson.value(forKey: "duration") as! Double
let title = videojson.value(forKey: "title") as! String
let targetURLs = videojson.value(forKey: "targetUrls") as! [NSDictionary]
let videourl = targetURLs[0].value(forKey: "url") as! String
var videourl = targetURLs[0].value(forKey: "url") as! String
var temptargeturl: String
for targeturl in targetURLs{
temptargeturl = (targeturl["url"] as! String)
if temptargeturl.contains("aes"){
videourl = temptargeturl
}
}
print(videourl)
//session.get('https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/%s?vrtPlayerToken=%s&client=%s@PROD' %(video_id, token, clientid)).json()
var video = Video(hlsUrl: URL(string: videourl)!,
@ -305,13 +313,13 @@ struct VRTNu: Hashable {
func login(username: String, password:String) -> Bool {
let auth_data = [
"ApiKey": "3_0Z2HujMtiWq_pkAjgnS2Md2E11a1AwZjYiBETtwNE-EoEHDINgtnvcAOpNgmrVGy",
"ApiKey": "3_qhEcPa5JGFROVwu5SWKqJ4mVOIkwlFNMSKwzPDAh8QZOtHqu6L4nD5Q7lk0eXOOG",
"targetEnv": "jssdk",
"loginID": username,
"password": password,
"authMode": "cookie",
"sessionExpiration": "-2",
]
let auth_json = just.post("f", data: auth_data).json!
let auth_json = just.post("https://accounts.vrt.be/accounts.login", data: auth_data).json!
let auth_info = auth_json as! NSDictionary
print("auth_info")
print(auth_info)
@ -322,19 +330,19 @@ struct VRTNu: Hashable {
return false
}
}
// no token is returnd but necessary cookies are set
just.post("https://token.vrt.be", json:[
"uid": auth_info.value(forKey: "UID"),
"uidsig": auth_info.value(forKey: "UIDSignature"),
"ts": auth_info.value(forKey: "signatureTimestamp"),
// get csrf
// tokensession.get('https://token.vrt.be/vrtnuinitlogin?provider=site&destination=https://www.vrt.be/vrtnu/')
let csrf = just.get("https://token.vrt.be/vrtnuinitlogin?provider=site&destination=https://www.vrt.be/vrtnu/").cookies["OIDCXSRF"]
just.post("https://login.vrt.be/perform_login", data :[
"UID": auth_info.value(forKey: "UID")!,
"UIDSignature": auth_info.value(forKey: "UIDSignature")!,
"signatureTimestamp": auth_info.value(forKey: "signatureTimestamp")!,
"client_id": "vrtnu-site",
"_csrf": csrf!.value,
//"email": auth_info.value(forKey: "profile"['email'],
"email": username
],
headers: [
"Conetnt-Type": "application/json",
"Referer": "https://www.vrt.be/vrtnu/",
//"email": username
]
)
print("authenticated")
return true