less cashing, fixes #2
This commit is contained in:
parent
794ccb01c3
commit
d19f310e0c
|
@ -65,7 +65,7 @@ struct Episode: Hashable, Comparable{
|
||||||
self.name = episodeName
|
self.name = episodeName
|
||||||
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.metadataurl = URL(string: episodeurl + ".mssecurevideo.json")!
|
||||||
self.title = title
|
self.title = title
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,17 @@ struct Season: Hashable, Comparable{
|
||||||
let seasonURL: URL
|
let seasonURL: URL
|
||||||
let seasonName: String
|
let seasonName: String
|
||||||
|
|
||||||
lazy var episodes: [Episode] = {
|
|
||||||
|
init(show: Show, seasonName: String, title: String){
|
||||||
|
self.show = show
|
||||||
|
self.title = title
|
||||||
|
self.seasonName = seasonName
|
||||||
|
print(seasonName)
|
||||||
|
print(show.showName)
|
||||||
|
self.seasonURL = URL(string: "https://www.vrt.be/vrtnu/a-z/" + show.showName + "/" + seasonName)!
|
||||||
|
}
|
||||||
|
|
||||||
|
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))`
|
||||||
|
|
||||||
let regexPattern = "vrtnu/a-z/" + show.showName + "/" + seasonName + "/([^\"]*)/"
|
let regexPattern = "vrtnu/a-z/" + show.showName + "/" + seasonName + "/([^\"]*)/"
|
||||||
|
@ -150,22 +160,6 @@ struct Season: Hashable, Comparable{
|
||||||
|
|
||||||
myepisodes.sort()
|
myepisodes.sort()
|
||||||
return myepisodes
|
return myepisodes
|
||||||
|
|
||||||
|
|
||||||
}()
|
|
||||||
|
|
||||||
init(show: Show, seasonName: String, title: String){
|
|
||||||
self.show = show
|
|
||||||
self.title = title
|
|
||||||
self.seasonName = seasonName
|
|
||||||
print(seasonName)
|
|
||||||
print(show.showName)
|
|
||||||
self.seasonURL = URL(string: "https://www.vrt.be/vrtnu/a-z/" + show.showName + "/" + seasonName)!
|
|
||||||
}
|
|
||||||
|
|
||||||
func getEpisodes() -> [Episode]{
|
|
||||||
var mutableself = self
|
|
||||||
return mutableself.episodes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -187,7 +181,17 @@ struct Show: Hashable, Comparable{
|
||||||
let imageURL: URL
|
let imageURL: URL
|
||||||
let vrtNu: VRTNu
|
let vrtNu: VRTNu
|
||||||
|
|
||||||
lazy var seasons: [Season] = {
|
init(vrtNu: VRTNu, showName: String, title: String, imageURL: URL) {
|
||||||
|
self.showURL = URL(string: "https://www.vrt.be/vrtnu/a-z/" + showName)!
|
||||||
|
self.showName = showName
|
||||||
|
self.title = title
|
||||||
|
//TODO: get image urls for shows
|
||||||
|
self.imageURL = imageURL
|
||||||
|
self.vrtNu = vrtNu
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 + "_(.*)\">"
|
let regexPattern = "value=\"#parsys_container_banner_" + showName + "_(.*)\">"
|
||||||
|
@ -205,22 +209,6 @@ struct Show: Hashable, Comparable{
|
||||||
}
|
}
|
||||||
myseasons.sort()
|
myseasons.sort()
|
||||||
return myseasons
|
return myseasons
|
||||||
}()
|
|
||||||
|
|
||||||
|
|
||||||
init(vrtNu: VRTNu, showName: String, title: String, imageURL: URL) {
|
|
||||||
self.showURL = URL(string: "https://www.vrt.be/vrtnu/a-z/" + showName)!
|
|
||||||
self.showName = showName
|
|
||||||
self.title = title
|
|
||||||
//TODO: get image urls for shows
|
|
||||||
self.imageURL = imageURL
|
|
||||||
self.vrtNu = vrtNu
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSeasons() -> [Season]{
|
|
||||||
var mutableself = self
|
|
||||||
return mutableself.seasons
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -238,32 +226,9 @@ extension NSTextCheckingResult {
|
||||||
|
|
||||||
struct VRTNu: Hashable {
|
struct VRTNu: Hashable {
|
||||||
|
|
||||||
lazy var shows: [Show] = {
|
let regexPattern = "a href=\"/vrtnu/a-z/(.*).relevant"
|
||||||
let regexPattern = "a href=\"/vrtnu/a-z/(.*).relevant"
|
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
|
||||||
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
|
let titleregexPattern = ".relevant/\">(.*)</a>"
|
||||||
let titleregexPattern = ".relevant/\">(.*)</a>"
|
|
||||||
|
|
||||||
let data = Just.get("https://www.vrt.be/vrtnu/a-z/").text!
|
|
||||||
print(data)
|
|
||||||
|
|
||||||
let output = parseData(data: data, regexPattern: regexPattern)
|
|
||||||
let imageoutput = parseData(data: data, regexPattern: imageregexPattern)
|
|
||||||
let titleoutput = parseData(data: data, regexPattern: titleregexPattern)
|
|
||||||
|
|
||||||
var show: String
|
|
||||||
var title: String
|
|
||||||
var image: String
|
|
||||||
var myshows: [Show]
|
|
||||||
myshows = []
|
|
||||||
for i in 0 ..< output.count{
|
|
||||||
show = output[i].replacingOccurrences(of: ".relevant", with: "").replacingOccurrences(of: "a href=\"/vrtnu/a-z/", with: "")
|
|
||||||
image = imageoutput[i].replacingOccurrences(of: "https:", with: "").replacingOccurrences(of: "http:", with: "").replacingOccurrences(of: "data-responsive-image=\"", with: "https:")
|
|
||||||
title = titleoutput[i].replacingOccurrences(of: ".relevant/\">", with: "").replacingOccurrences(of: "</a>", with: "")
|
|
||||||
myshows.append(Show(vrtNu: self, showName: show, title: title, imageURL: URL(string: image)!))
|
|
||||||
}
|
|
||||||
myshows.sort()
|
|
||||||
return myshows
|
|
||||||
}()
|
|
||||||
|
|
||||||
func getToken() -> String {
|
func getToken() -> String {
|
||||||
///token = session.post('https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/tokens', headers={'Content-Type': 'application/json'}, data=b'').json()['vrtPlayerToken']
|
///token = session.post('https://media-services-public.vrt.be/vualto-video-aggregator-web/rest/external/v1/tokens', headers={'Content-Type': 'application/json'}, data=b'').json()['vrtPlayerToken']
|
||||||
|
@ -318,7 +283,25 @@ struct VRTNu: Hashable {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getShows() -> [Show]{
|
func getShows() -> [Show]{
|
||||||
var mutableself = self
|
let data = Just.get("https://www.vrt.be/vrtnu/a-z/").text!
|
||||||
return mutableself.shows
|
print(data)
|
||||||
|
|
||||||
|
let output = parseData(data: data, regexPattern: regexPattern)
|
||||||
|
let imageoutput = parseData(data: data, regexPattern: imageregexPattern)
|
||||||
|
let titleoutput = parseData(data: data, regexPattern: titleregexPattern)
|
||||||
|
|
||||||
|
var show: String
|
||||||
|
var title: String
|
||||||
|
var image: String
|
||||||
|
var myshows: [Show]
|
||||||
|
myshows = []
|
||||||
|
for i in 0 ..< output.count{
|
||||||
|
show = output[i].replacingOccurrences(of: ".relevant", with: "").replacingOccurrences(of: "a href=\"/vrtnu/a-z/", with: "")
|
||||||
|
image = imageoutput[i].replacingOccurrences(of: "https:", with: "").replacingOccurrences(of: "http:", with: "").replacingOccurrences(of: "data-responsive-image=\"", with: "https:")
|
||||||
|
title = titleoutput[i].replacingOccurrences(of: ".relevant/\">", with: "").replacingOccurrences(of: "</a>", with: "")
|
||||||
|
myshows.append(Show(vrtNu: self, showName: show, title: title, imageURL: URL(string: image)!))
|
||||||
|
}
|
||||||
|
myshows.sort()
|
||||||
|
return myshows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue