fixes for removeal of mssecurevideo.json file
This commit is contained in:
parent
ecca86df08
commit
24a495625e
|
@ -24,7 +24,6 @@ struct Episode: Hashable, Comparable{
|
||||||
let title: String
|
let title: String
|
||||||
let season: Season
|
let season: Season
|
||||||
let imageURL: URL
|
let imageURL: URL
|
||||||
let metadataurl: URL
|
|
||||||
let episodeurl: String
|
let episodeurl: String
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +65,6 @@ struct Episode: Hashable, Comparable{
|
||||||
self.season = season
|
self.season = season
|
||||||
self.imageURL = imageURL
|
self.imageURL = imageURL
|
||||||
self.episodeurl = "https://www.vrt.be/vrtnu/a-z/" + season.show.showName + "/" + season.seasonName + "/" + episodeName
|
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
|
self.title = title
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,16 +74,18 @@ struct Episode: Hashable, Comparable{
|
||||||
}
|
}
|
||||||
|
|
||||||
func getVideoJson() -> NSDictionary{
|
func getVideoJson() -> NSDictionary{
|
||||||
//`requests.get('https://www.vrt.be/vrtnu/a-z/%s/%s/%s.mssecurevideo.json' % (show, season, episode)).json()`
|
let episodedata = just.get(episodeurl).text!
|
||||||
|
let videoid = parseData(data:episodedata, regexPattern: "vid-[a-z0-9-]*")
|
||||||
let msecjson = just.get(metadataurl).json!
|
print(videoid)
|
||||||
let mssecdict = msecjson as! NSDictionary
|
let pubid = parseData(data:episodedata, regexPattern: "pbs-pub-[a-z0-9-]*")
|
||||||
print(msecjson)
|
print(pubid)
|
||||||
let intmssecdict = mssecdict.allValues[0] as! NSDictionary
|
let videoidd = pubid[0] + "$" + videoid[0]
|
||||||
let videoid = intmssecdict.value(forKey: "videoid") as! String
|
print(videoidd)
|
||||||
let clientid = intmssecdict.value(forKey: "clientid") as! String
|
//<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="{"date":"2020-05-18T18:34:00.000+02:00","whatson":"866106147527","program_whatson":"857086980527","episode":"#ikluisterbelgisch live - 18/05 #ikluisterbelgisch live 2","program":"#ikluisterbelgisch live","cimIdentifier":".cA63ye4ZyIIPzz71Hl5Bqe1rmDIl1s5ggCFAoZ9PvL.I7","onTime":"2020-05-18T16:00:00.000+02:00","playlist":"//www.vrt.be/vrtnu/a-z/-ikluisterbelgisch-live/2020/-ikluisterbelgisch-live--ikluisterbelgisch-live-2","sourceType":"vid.tvi.ep.vod.free","type_clip":"asset","parts":"1","station":"stubru","publication_date":"2020-05-18T18:37:10.993Z","category":"Muziek"}" 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 + "?vrtPlayerToken="
|
||||||
mediaurl = mediaurl + self.season.show.vrtNu.getToken() + "&client="
|
mediaurl = mediaurl + self.season.show.vrtNu.getToken() + "&client="
|
||||||
mediaurl = mediaurl + clientid + "@PROD"
|
mediaurl = mediaurl + clientid + "@PROD"
|
||||||
|
@ -135,6 +135,7 @@ struct Season: Hashable, Comparable{
|
||||||
func getEpisodes() -> [Episode]{
|
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))`
|
//`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 regexPattern = "vrtnu/a-z/" + show.showName + "/" + seasonName + "/([^\"]*)/"
|
||||||
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
|
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
|
||||||
let titleregexPattern = "\">(.*)(</a>|<br />)"
|
let titleregexPattern = "\">(.*)(</a>|<br />)"
|
||||||
|
@ -182,7 +183,7 @@ struct Show: Hashable, Comparable{
|
||||||
let vrtNu: VRTNu
|
let vrtNu: VRTNu
|
||||||
|
|
||||||
init(vrtNu: VRTNu, showName: String, title: String, imageURL: URL) {
|
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.showName = showName
|
||||||
self.title = title
|
self.title = title
|
||||||
//TODO: get image urls for shows
|
//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]{
|
func getSeasons() -> [Season]{
|
||||||
//`re.findall('value="#parsys_container_banner_%s_(.*)">' % show, requests.get('https://www.vrt.be/vrtnu/a-z/%s/' % show).text)`
|
//`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)
|
let output = parseData(data: Just.get(showURL).text!, regexPattern: regexPattern)
|
||||||
|
|
||||||
var season: String
|
var season: String
|
||||||
var myseasons: [Season]
|
var myseasons: [Season]
|
||||||
myseasons = []
|
myseasons = []
|
||||||
for i in 0 ..< output.count{
|
for i in 0 ..< output.count{
|
||||||
season = output[i].replacingOccurrences(of: "value=\"#parsys_container_banner_"
|
print(output[i])
|
||||||
+ showName + "_", with: "").replacingOccurrences(of: "\">", with: "")
|
season = output[i].replacingOccurrences(of: "value=\"#parsys_container_banner_", with: "")
|
||||||
|
.replacingOccurrences(of: showName + "_", with: "").replacingOccurrences(of: "\">", with: "")
|
||||||
print(season)
|
print(season)
|
||||||
print(showName)
|
print(showName)
|
||||||
myseasons.append(Season(show: self, seasonName: season, title: season))
|
myseasons.append(Season(show: self, seasonName: season, title: season))
|
||||||
|
@ -283,6 +323,8 @@ struct VRTNu: Hashable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getShows() -> [Show]{
|
func getShows() -> [Show]{
|
||||||
|
print("getting shows")
|
||||||
|
|
||||||
let data = Just.get("https://www.vrt.be/vrtnu/a-z/").text!
|
let data = Just.get("https://www.vrt.be/vrtnu/a-z/").text!
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue