make it look nicer

This commit is contained in:
Jens Timmerman 2020-10-05 00:03:56 +02:00
parent 64a4bb214c
commit bee0c8f1ad
21 changed files with 62 additions and 68 deletions

View File

@ -9,7 +9,6 @@
/* Begin PBXBuildFile section */
B408F0DD251F6D180043E3A4 /* AsyncImage.swift in Sources */ = {isa = PBXBuildFile; fileRef = B408F0DC251F6D180043E3A4 /* AsyncImage.swift */; };
B408F0E5251F7AC50043E3A4 /* Just.swift in Sources */ = {isa = PBXBuildFile; fileRef = B408F0E4251F7AC50043E3A4 /* Just.swift */; };
B408F0ED251F9D2C0043E3A4 /* loading.jpg in Resources */ = {isa = PBXBuildFile; fileRef = B408F0EC251F9D2C0043E3A4 /* loading.jpg */; };
B4F0CC7B251BE62B00E9EA74 /* vrtnuApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F0CC7A251BE62B00E9EA74 /* vrtnuApp.swift */; };
B4F0CC7D251BE62B00E9EA74 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = B4F0CC7C251BE62B00E9EA74 /* ContentView.swift */; };
B4F0CC7F251BE62F00E9EA74 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B4F0CC7E251BE62F00E9EA74 /* Assets.xcassets */; };
@ -40,7 +39,6 @@
/* Begin PBXFileReference section */
B408F0DC251F6D180043E3A4 /* AsyncImage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AsyncImage.swift; sourceTree = "<group>"; };
B408F0E4251F7AC50043E3A4 /* Just.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Just.swift; sourceTree = "<group>"; };
B408F0EC251F9D2C0043E3A4 /* loading.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = loading.jpg; sourceTree = "<group>"; };
B4F0CC77251BE62B00E9EA74 /* vrtnu.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = vrtnu.app; sourceTree = BUILT_PRODUCTS_DIR; };
B4F0CC7A251BE62B00E9EA74 /* vrtnuApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = vrtnuApp.swift; sourceTree = "<group>"; };
B4F0CC7C251BE62B00E9EA74 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = "<group>"; };
@ -94,7 +92,6 @@
B4F0CC6E251BE62B00E9EA74 = {
isa = PBXGroup;
children = (
B408F0EC251F9D2C0043E3A4 /* loading.jpg */,
B4F0CC79251BE62B00E9EA74 /* vrtnu */,
B4F0CC8B251BE62F00E9EA74 /* vrtnuTests */,
B4F0CC96251BE62F00E9EA74 /* vrtnuUITests */,
@ -256,7 +253,6 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
B408F0ED251F9D2C0043E3A4 /* loading.jpg in Resources */,
B4F0CC82251BE62F00E9EA74 /* Preview Assets.xcassets in Resources */,
B4F0CC7F251BE62F00E9EA74 /* Assets.xcassets in Resources */,
);

View File

@ -1,6 +1,7 @@
{
"images" : [
{
"filename" : "shopiconback.png",
"idiom" : "tv"
}
],

View File

@ -1,6 +1,7 @@
{
"images" : [
{
"filename" : "shopiconfront.png",
"idiom" : "tv"
}
],

View File

@ -1,6 +1,7 @@
{
"images" : [
{
"filename" : "shopiconmiddle.png",
"idiom" : "tv"
}
],

View File

@ -5,6 +5,7 @@
"scale" : "1x"
},
{
"filename" : "iconback@2x.png",
"idiom" : "tv",
"scale" : "2x"
}

View File

@ -5,6 +5,7 @@
"scale" : "1x"
},
{
"filename" : "icontop@2x.png",
"idiom" : "tv",
"scale" : "2x"
}

View File

@ -5,6 +5,7 @@
"scale" : "1x"
},
{
"filename" : "iconmiddle@2x.png",
"idiom" : "tv",
"scale" : "2x"
}

View File

@ -1,18 +1,22 @@
{
"images" : [
{
"filename" : "topshelft@1x.png",
"idiom" : "tv",
"scale" : "1x"
},
{
"filename" : "topshelft@2x.png",
"idiom" : "tv",
"scale" : "2x"
},
{
"filename" : "topshelft@1x-1.png",
"idiom" : "tv-marketing",
"scale" : "1x"
},
{
"filename" : "topshelft@2x-1.png",
"idiom" : "tv-marketing",
"scale" : "2x"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 53 KiB

View File

@ -53,20 +53,27 @@ struct LoginView: View{
}
struct VRTNuView: View{
var vrtNu: VRTNu
var body: some View {
w var body: some View {
NavigationView(){
List(vrtNu.getShows(), id: \.self){ show in
List(vrtNu.getShows(), id: \.title){ show in
NavigationLink(destination: ShowView(show: show)){
HStack{
AsyncImage(url: show.imageURL,placeholder: {
//Image(name: "loading")
Text("Loading...")
}, image:{Image(uiImage:$0).resizable()}).frame(width: 300, height:300)
Text(show.title)
}, image:{
Image(uiImage:$0)
.resizable()
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
VStack(alignment: .leading){
Text(show.title)
.padding()
Text(show.showURL.absoluteString)
}
}
}
}
}
}.navigationTitle("Browse VRT Nu")//.listStyle(DefaultListStyle())
}
}
struct ShowView: View {
@ -82,8 +89,12 @@ struct ShowView: View {
AsyncImage(url: episode.imageURL,placeholder: {
//Image(name: "loading")
Text("Loading...")
},image:{Image(uiImage:$0).resizable()}).frame(width: 300, height: 300)
Text(episode.name)
},image:{Image(uiImage:$0).resizable()
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
VStack(alignment: .leading){
Text(episode.title).padding()
Text(episode.episodeurl)
}
}
}
}
@ -106,6 +117,7 @@ struct VisibleShowView: View {
}
}
//not used at the moment, we have an integrated view of seasons in the episode list
struct SeasonView: View {
var season: Season
var body: some View {
@ -116,7 +128,8 @@ struct SeasonView: View {
AsyncImage(url: episode.imageURL,placeholder: {
//Image(name: "loading")
Text("Loading...")
},image:{Image(uiImage:$0).resizable()}).frame(width: 300, height: 300)
},image:{Image(uiImage:$0).resizable()
}).aspectRatio(contentMode: .fit).frame(width: 480, height:300)
Text(episode.name)
}
@ -145,52 +158,8 @@ struct VideoView: View {
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
SeasonView(season: VRTNu().getShows()[0].getSeasons()[0])
//ContentView()
//ShowView(show: VRTNu().getShows()[0])
ContentView()
}
}
/*struct OldContentView: View {
var body: some View {
NavigationView(){
VStack(alignment: .leading) {
ForEach(VRTNu().shows, id: \.self){ show in
VStack{
Text(show.title)
HStack{
ForEach(show.seasons, id:\.self){ season in
List(season.episodes, id:\.self){ episode in
NavigationLink(destination: VideoView(url: episode.video.hlsUrl)){
VStack{
Text(season.seasonName)
Text(episode.name)
AsyncImage(url: episode.imageurl,placeholder: {
//Image(name: "loading")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
Text("Loading...")
},image:{Image(uiImage:$0).resizable()})
}}
}
}
}
}
}
}
}
}
}*/

View File

@ -17,13 +17,16 @@ let just = JustOf<HTTP>()
struct Episode: Hashable, Comparable{
static func < (lhs: Episode, rhs: Episode) -> Bool {
return lhs.name < rhs.name
return lhs.name.localizedStandardCompare(rhs.name) == .orderedAscending
}
let name: String
let title: String
let season: Season
let imageURL: URL
let metadataurl: URL
let episodeurl: String
func authenticated() -> Bool{
//check if current token is valid
@ -58,11 +61,13 @@ struct Episode: Hashable, Comparable{
return video
}()
init(season: Season, episodeName: String, imageURL: URL){
init(season: Season, episodeName: String, title: String, imageURL: URL){
self.name = episodeName
self.season = season
self.imageURL = imageURL
self.metadataurl = URL(string: "https://www.vrt.be/vrtnu/a-z/" + season.show.showName + "/" + season.seasonName + "/" + episodeName + ".mssecurevideo.json")!
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
}
func getVideo() -> Video{
@ -104,7 +109,8 @@ func parseData(data: String, regexPattern: String) -> [String]{
struct Season: Hashable, Comparable{
static func < (lhs: Season, rhs: Season) -> Bool {
return lhs.seasonName < rhs.seasonName
//return lhs.seasonName < rhs.seasonName
return lhs.seasonName.localizedStandardCompare(rhs.seasonName) == .orderedAscending
}
static func == (lhs: Season, rhs: Season) -> Bool {
@ -121,19 +127,25 @@ struct Season: Hashable, Comparable{
let regexPattern = "vrtnu/a-z/" + show.showName + "/" + seasonName + "/([^\"]*)/"
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 = Array(Set(parseData(data: data, regexPattern: regexPattern)))
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 ..< output.count{
episode = output[i].replacingOccurrences(of: "vrtnu/a-z/" + show.showName + "/" + seasonName + "/", with: "").replacingOccurrences(of: "/", with: "")
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:"))!
myepisodes.append(Episode(season: self, episodeName: episode, imageURL: image))
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()
@ -159,8 +171,10 @@ struct Season: Hashable, Comparable{
}
struct Show: Hashable, Comparable{
static func < (lhs: Show, rhs: Show) -> Bool {
return lhs.showName < rhs.showName
//return lhs.showName < rhs.showName
return lhs.showName.localizedStandardCompare(rhs.showName) == .orderedAscending
}
static func == (lhs: Show, rhs: Show) -> Bool {
@ -227,20 +241,25 @@ struct VRTNu: Hashable {
lazy var shows: [Show] = {
let regexPattern = "a href=\"/vrtnu/a-z/(.*).relevant"
let imageregexPattern = "data-responsive-image=\".*(jpg|png)"
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:")
myshows.append(Show(vrtNu: self, showName: show, title: show, imageURL: URL(string: image)!))
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