fixes for removeal of mssecurevideo.json file

This commit is contained in:
Jens Timmerman 2020-11-01 01:53:50 +01:00
parent ecca86df08
commit 24a495625e
1 changed files with 57 additions and 15 deletions

View File

@ -24,7 +24,6 @@ struct Episode: Hashable, Comparable{
let title: String
let season: Season
let imageURL: URL
let metadataurl: URL
let episodeurl: String
@ -66,7 +65,6 @@ struct Episode: Hashable, Comparable{
self.season = season
self.imageURL = imageURL
self.episodeurl = "https://www.vrt.be/vrtnu/a-z/" + season.show.showName + "/" + season.seasonName + "/" + episodeName
self.metadataurl = URL(string: episodeurl + ".mssecurevideo.json")!
self.title = title
}
@ -76,16 +74,18 @@ struct Episode: Hashable, Comparable{
}
func getVideoJson() -> NSDictionary{
//`requests.get('https://www.vrt.be/vrtnu/a-z/%s/%s/%s.mssecurevideo.json' % (show, season, episode)).json()`
let msecjson = just.get(metadataurl).json!
let mssecdict = msecjson as! NSDictionary
print(msecjson)
let intmssecdict = mssecdict.allValues[0] as! NSDictionary
let videoid = intmssecdict.value(forKey: "videoid") as! String
let clientid = intmssecdict.value(forKey: "clientid") as! String
let episodedata = just.get(episodeurl).text!
let videoid = parseData(data:episodedata, regexPattern: "vid-[a-z0-9-]*")
print(videoid)
let pubid = parseData(data:episodedata, regexPattern: "pbs-pub-[a-z0-9-]*")
print(pubid)
let videoidd = pubid[0] + "$" + videoid[0]
print(videoidd)
//<nui-media posterimage="https://images.vrt.be/orig/2020/05/18/9e5f3cf2-9926-11ea-aae0-02b7b76bf47f.jpg" mediaapiurl="https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1" videoid="vid-4a3a3cff-0bae-4884-9507-9590472c3bf7" publicationid="pbs-pub-b5ee97f5-f272-455f-ba9b-d3d7b179839d" analytics="{&quot;date&quot;:&quot;2020-05-18T18:34:00.000+02:00&quot;,&quot;whatson&quot;:&quot;866106147527&quot;,&quot;program_whatson&quot;:&quot;857086980527&quot;,&quot;episode&quot;:&quot;#ikluisterbelgisch live - 18/05 #ikluisterbelgisch live 2&quot;,&quot;program&quot;:&quot;#ikluisterbelgisch live&quot;,&quot;cimIdentifier&quot;:&quot;.cA63ye4ZyIIPzz71Hl5Bqe1rmDIl1s5ggCFAoZ9PvL.I7&quot;,&quot;onTime&quot;:&quot;2020-05-18T16:00:00.000+02:00&quot;,&quot;playlist&quot;:&quot;//www.vrt.be/vrtnu/a-z/-ikluisterbelgisch-live/2020/-ikluisterbelgisch-live--ikluisterbelgisch-live-2&quot;,&quot;sourceType&quot;:&quot;vid.tvi.ep.vod.free&quot;,&quot;type_clip&quot;:&quot;asset&quot;,&quot;parts&quot;:&quot;1&quot;,&quot;station&quot;:&quot;stubru&quot;,&quot;publication_date&quot;:&quot;2020-05-18T18:37:10.993Z&quot;,&quot;category&quot;:&quot;Muziek&quot;}" environment="prod" focalpoint="50.000% 50.000%" assetpath="/content/dam/vrt/2020/05/18/ikluisterbelgisch-live-2-compilatie-depot_AIM10816322" class="">
var mediaurl = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/" + videoid
let clientid = "vrtvideo"
var mediaurl = "https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/videos/" + videoidd
mediaurl = mediaurl + "?vrtPlayerToken="
mediaurl = mediaurl + self.season.show.vrtNu.getToken() + "&client="
mediaurl = mediaurl + clientid + "@PROD"
@ -135,6 +135,7 @@ struct Season: Hashable, Comparable{
func getEpisodes() -> [Episode]{
//`set(re.findall('vrtnu/a-z/%s/%s/([^"]*)/' %(show, season),requests.get('https://www.vrt.be/vrtnu/a-z/%s/%s.lists.all-episodes/' % (show, season)).text))`
print("getting episodes for " + show.showName + " " + seasonName)
let regexPattern = "vrtnu/a-z/" + show.showName + "/" + seasonName + "/([^\"]*)/"
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
let titleregexPattern = "\">(.*)(</a>|<br />)"
@ -182,7 +183,7 @@ struct Show: Hashable, Comparable{
let vrtNu: VRTNu
init(vrtNu: VRTNu, showName: String, title: String, imageURL: URL) {
self.showURL = URL(string: "https://www.vrt.be/vrtnu/a-z/" + showName)!
self.showURL = URL(string: "https://www.vrt.be/vrtnu/a-z/" + showName + "/")!
self.showName = showName
self.title = title
//TODO: get image urls for shows
@ -191,18 +192,57 @@ struct Show: Hashable, Comparable{
}
/* func getEpisodes()-> [Episode]{
# actually all episodes are already listed in the show's page, no need to get the individual episodes
print("getting episodes for" + showName)
let regexPattern = "link=\"/vrtnu/a-z/" + showName + "/(.*).html\">"
let seasondata = Just.get(showURL).text!
let output = parseData(data: seasondata, regexPattern: regexPattern)
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
let titleregexPattern = "\">(.*)(</a>|<br />)"
let data = Just.get("https://www.vrt.be/vrtnu/a-z/" + show.showName + "/" + seasonName + ".lists.all-episodes/").text!
let output = parseData(data: data, regexPattern: regexPattern)
let imageoutput = parseData(data: data, regexPattern: imageregexPattern)
let titleoutput = parseData(data: data, regexPattern: titleregexPattern)
print(data)
var episode: String
var myepisodes: [Episode]
myepisodes = []
for i in 0 ..< titleoutput.count{
// output always contains same url twice
episode = output[i * 2].replacingOccurrences(of: "vrtnu/a-z/" + show.showName + "/" + seasonName + "/", with: "").replacingOccurrences(of: "/", with: "")
print(episode)
print(seasonName)
let image = URL(string: imageoutput[i].replacingOccurrences(of: "https:", with: "").replacingOccurrences(of: "http:", with: "").replacingOccurrences(of: "data-responsive-image=\"", with: "https:"))!
let title = titleoutput[i].replacingOccurrences(of: "\">", with: "").replacingOccurrences(of: "<br />", with: "").replacingOccurrences(of: "</a>", with: "")
myepisodes.append(Episode(season: self, episodeName: episode, title: title, imageURL: image))
}
myepisodes.sort()
return myepisodes
}
}*/
func getSeasons() -> [Season]{
//`re.findall('value="#parsys_container_banner_%s_(.*)">' % show, requests.get('https://www.vrt.be/vrtnu/a-z/%s/' % show).text)`
let regexPattern = "value=\"#parsys_container_banner_(" + showName + "_)?(.*)\">"
print("getting seasons from " + showURL.absoluteString)
print("filtering with " + regexPattern)
let regexPattern = "value=\"#parsys_container_banner_" + showName + "_(.*)\">"
let output = parseData(data: Just.get(showURL).text!, regexPattern: regexPattern)
var season: String
var myseasons: [Season]
myseasons = []
for i in 0 ..< output.count{
season = output[i].replacingOccurrences(of: "value=\"#parsys_container_banner_"
+ showName + "_", with: "").replacingOccurrences(of: "\">", with: "")
print(output[i])
season = output[i].replacingOccurrences(of: "value=\"#parsys_container_banner_", with: "")
.replacingOccurrences(of: showName + "_", with: "").replacingOccurrences(of: "\">", with: "")
print(season)
print(showName)
myseasons.append(Season(show: self, seasonName: season, title: season))
@ -283,6 +323,8 @@ struct VRTNu: Hashable {
}
func getShows() -> [Show]{
print("getting shows")
let data = Just.get("https://www.vrt.be/vrtnu/a-z/").text!
print(data)