applied a lot of patches ngl

This commit is contained in:
cranci1 2025-01-01 11:27:59 +01:00
parent 66ca3cfa78
commit 457cfe9480
6 changed files with 42 additions and 14 deletions

View file

@ -548,7 +548,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.1.0;
MARKETING_VERSION = 0.1.1;
PRODUCT_BUNDLE_IDENTIFIER = me.cranci.Sora;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;
@ -581,7 +581,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 0.1.0;
MARKETING_VERSION = 0.1.1;
PRODUCT_BUNDLE_IDENTIFIER = me.cranci.Sora;
PRODUCT_NAME = "$(TARGET_NAME)";
SUPPORTS_MACCATALYST = YES;

View file

@ -121,10 +121,16 @@ struct HomeView: View {
let href = try element.select(module.module[0].featured.href).attr("href")
var imageURL = try element.select(module.module[0].featured.image.url).attr(module.module[0].featured.image.attribute)
if !imageURL.starts(with: "http") {
imageURL = "\(module.module[0].details.baseURL)\(imageURL)"
if imageURL.contains(",") {
imageURL = imageURL.split(separator: ",").map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.first ?? imageURL
}
if !imageURL.starts(with: "http") {
imageURL = "\(module.module[0].details.baseURL.hasSuffix("/") ? module.module[0].details.baseURL : "\(module.module[0].details.baseURL)/")\(imageURL.hasPrefix("/") ? String(imageURL.dropFirst()) : imageURL)"
}
imageURL = imageURL.replacingOccurrences(of: " ", with: "%20")
let result = ItemResult(name: title, imageUrl: imageURL, href: href)
results.append(result)
}

View file

@ -97,9 +97,7 @@ extension MediaView {
DispatchQueue.main.async {
self.playStream(urlString: patternURL?.absoluteString, fullURL: urlString)
}
}
else {
} else {
DispatchQueue.main.async {
self.playStream(urlString: streamURLs.first, fullURL: urlString)
}
@ -133,14 +131,32 @@ extension MediaView {
}
func extractPatternURL(from html: String) -> URL? {
let pattern = module.module[0].episodes.pattern
var pattern = module.module[0].episodes.pattern
if module.extractor == "pattern" {
if let data = Data(base64Encoded: pattern), let decodedPattern = String(data: data, encoding: .utf8) {
pattern = decodedPattern
} else {
print("Failed to decode base64 pattern")
Logger.shared.log("Failed to decode base64 pattern")
return nil
}
}
do {
let regex = try NSRegularExpression(pattern: pattern, options: [])
let matches = regex.matches(in: html, options: [], range: NSRange(html.startIndex..., in: html))
if let match = matches.first, let range = Range(match.range, in: html) {
var urlString = String(html[range])
let range = NSRange(html.startIndex..<html.endIndex, in: html)
if let match = regex.firstMatch(in: html, options: [], range: range),
let matchRange = Range(match.range, in: html) {
var urlString = String(html[matchRange])
urlString = urlString.replacingOccurrences(of: "amp;", with: "")
urlString = urlString.replacingOccurrences(of: "\"", with: "")
if let httpsRange = urlString.range(of: "https") {
urlString = String(urlString[httpsRange.lowerBound...])
}
return URL(string: urlString)
}
} catch {

View file

@ -192,10 +192,16 @@ struct SearchResultsView: View {
let href = try element.select(module.module[0].search.href).attr("href")
var imageURL = try element.select(module.module[0].search.image.url).attr(module.module[0].search.image.attribute)
if !imageURL.starts(with: "http") {
imageURL = "\(module.module[0].details.baseURL)\(imageURL)"
if imageURL.contains(",") {
imageURL = imageURL.split(separator: ",").map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.first ?? imageURL
}
if !imageURL.starts(with: "http") {
imageURL = "\(module.module[0].details.baseURL.hasSuffix("/") ? module.module[0].details.baseURL : "\(module.module[0].details.baseURL)/")\(imageURL.hasPrefix("/") ? String(imageURL.dropFirst()) : imageURL)"
}
imageURL = imageURL.replacingOccurrences(of: " ", with: "%20")
let result = ItemResult(name: title, imageUrl: imageURL, href: href)
results.append(result)
}

View file

@ -23,7 +23,7 @@ struct AboutView: View {
.font(.largeTitle)
.fontWeight(.bold)
Text("Public beta 1")
Text("Public beta 0.1.1")
.font(.subheadline)
.foregroundColor(.secondary)
}