Skip to content

Commit

Permalink
1.9 MUCH STUFFS
Browse files Browse the repository at this point in the history
  • Loading branch information
cranci1 committed May 21, 2024
1 parent 96e6e20 commit b0e877b
Show file tree
Hide file tree
Showing 20 changed files with 878 additions and 612 deletions.
8 changes: 6 additions & 2 deletions AnimeGen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
1393C3A92BEBC94300704137 /* AppPreff.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1393C3A62BEBC94300704137 /* AppPreff.swift */; };
1393C3AA2BEBC94300704137 /* Dev-History.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1393C3A72BEBC94300704137 /* Dev-History.swift */; };
1393C3AB2BEBC94300704137 /* moe-kyoko.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1393C3A82BEBC94300704137 /* moe-kyoko.swift */; };
139C35072BFCE1A9003A1CA1 /* Contentsss.swift in Sources */ = {isa = PBXBuildFile; fileRef = 139C35062BFCE1A9003A1CA1 /* Contentsss.swift */; };
13A8496B2BF479DA009A9442 /* n-sfw.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13A8496A2BF479DA009A9442 /* n-sfw.swift */; };
13A8496E2BF4F0E7009A9442 /* FrameWorksCredits.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13A8496D2BF4F0E7009A9442 /* FrameWorksCredits.swift */; };
13A849702BF4F118009A9442 /* Contributor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13A8496F2BF4F118009A9442 /* Contributor.swift */; };
Expand Down Expand Up @@ -76,6 +77,7 @@
1393C3A62BEBC94300704137 /* AppPreff.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppPreff.swift; sourceTree = "<group>"; };
1393C3A72BEBC94300704137 /* Dev-History.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Dev-History.swift"; sourceTree = "<group>"; };
1393C3A82BEBC94300704137 /* moe-kyoko.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "moe-kyoko.swift"; sourceTree = "<group>"; };
139C35062BFCE1A9003A1CA1 /* Contentsss.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contentsss.swift; sourceTree = "<group>"; };
13A8496A2BF479DA009A9442 /* n-sfw.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "n-sfw.swift"; sourceTree = "<group>"; };
13A8496D2BF4F0E7009A9442 /* FrameWorksCredits.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FrameWorksCredits.swift; sourceTree = "<group>"; };
13A8496F2BF4F118009A9442 /* Contributor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Contributor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -274,6 +276,7 @@
1393C3A62BEBC94300704137 /* AppPreff.swift */,
1393C3A72BEBC94300704137 /* Dev-History.swift */,
1393C3A82BEBC94300704137 /* moe-kyoko.swift */,
139C35062BFCE1A9003A1CA1 /* Contentsss.swift */,
);
path = NotificationCenter;
sourceTree = "<group>";
Expand Down Expand Up @@ -382,6 +385,7 @@
1393C3AA2BEBC94300704137 /* Dev-History.swift in Sources */,
13D4FC1C2BE770EC00BC3D1C /* purr.swift in Sources */,
13D4FC292BE7710500BC3D1C /* HmtaiReader.swift in Sources */,
139C35072BFCE1A9003A1CA1 /* Contentsss.swift in Sources */,
136BD7E82BE7E24100ED23AE /* Developer.swift in Sources */,
13D4FBF02BE76D4000BC3D1C /* popup-Banner.swift in Sources */,
13D4FC2A2BE7710500BC3D1C /* HmtaiSender.swift in Sources */,
Expand Down Expand Up @@ -529,7 +533,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 41;
CURRENT_PROJECT_VERSION = 52;
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
Expand Down Expand Up @@ -560,7 +564,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 41;
CURRENT_PROJECT_VERSION = 52;
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion AnimeGen/APIs Requests/Hmtai/HmtaiSender.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ extension ViewController {
let categories3: [String]
let endpointPrefix: String

if UserDefaults.standard.bool(forKey: "enableExplictiCont") {
if UserDefaults.standard.bool(forKey: "explicitContents") {
categories3 = ["ass", "anal", "bdsm", "classic", "cum", "creampie", "manga", "femdom", "hentai", "incest", "masturbation", "public", "ero", "orgy", "elves", "yuri", "pantsu", "pussy", "glasses", "cuckold", "blowjob", "boobjob", "handjob", "footjob", "boobs", "thighs", "ahegao", "uniform", "gangbang", "tentacles", "gif", "nsfwNeko", "nsfwMobileWallpaper", "zettaiRyouiki"]
endpointPrefix = "https://hmtai.hatsunia.cfd/nsfw/"
} else {
Expand Down
170 changes: 94 additions & 76 deletions AnimeGen/APIs Requests/kyoko.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,97 +6,115 @@
//

import UIKit
import SDWebImage

extension ViewController {

func loadImageFromKyoko() {
startLoadingIndicator()

let categories: [String]
let endpointPrefix: String

if UserDefaults.standard.bool(forKey: "enableExplictiCont") {
categories = ["waifu", "neko", "trap", "blowjob"]
endpointPrefix = "https://waifu.rei.my.id/nsfw/"
} else {
categories = ["waifu", "neko", "shinobu", "megumin", "bully", "cuddle", "cry", "hug", "awoo", "kiss", "lick", "pat", "smug", "bonk", "blush", "smile", "nom", "bite", "glomp", "slap", "kick", "happy", "poke", "dance"]
endpointPrefix = "https://waifu.rei.my.id/sfw/"
}

let randomCategory = categories.randomElement() ?? "waifu"

let apiEndpoint = "\(endpointPrefix)\(randomCategory)"

guard let url = URL(string: apiEndpoint) else {
print("Invalid URL")
stopLoadingIndicator()
return

let startTime = DispatchTime.now()

DispatchQueue.global().async { [weak self] in
guard let self = self else { return }

var endpointPrefix: String
var categories: [String]

if UserDefaults.standard.bool(forKey: "explicitContents") {
categories = ["waifu", "neko", "trap", "blowjob"]
endpointPrefix = "https://waifu.rei.my.id/nsfw/"
} else {
categories = ["waifu", "neko", "shinobu", "megumin", "bully", "cuddle", "cry", "hug", "awoo", "kiss", "lick", "pat", "smug", "bonk", "blush", "smile", "nom", "bite", "glomp", "slap", "kick", "happy", "poke", "dance"]
endpointPrefix = "https://waifu.rei.my.id/sfw/"
}

let randomIndex = Int(arc4random_uniform(UInt32(categories.count)))
let randomCategory = categories[randomIndex]

guard let url = URL(string: "\(endpointPrefix)\(randomCategory)") else {
print("Invalid URL")
DispatchQueue.main.async {
self.stopLoadingIndicator()
}
return
}

let request = URLRequest(url: url)

self.fetchImage(with: request, startTime: startTime, tag: randomCategory)
}

let task = URLSession.shared.dataTask(with: url) { (data, response, error) in
DispatchQueue.main.async {
if let error = error {
print("Error: \(error)")
}

private func fetchImage(with request: URLRequest, startTime: DispatchTime, tag: String) {
URLSession.shared.dataTask(with: request) { [weak self] (data, response, error) in
guard let self = self else { return }

if let error = error {
print("Error: \(error)")
DispatchQueue.main.async {
self.stopLoadingIndicator()
return
}

guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else {
print("Invalid HTTP response")
return
}

guard let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 200 else {
print("Invalid HTTP response")
DispatchQueue.main.async {
self.stopLoadingIndicator()
return
}

if let data = data {
do {
if let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
let requestResult = jsonResponse["RequestResult"] as? [String: Any],
let imageUrlString = requestResult["url"] as? String,
let imageUrl = URL(string: imageUrlString) {

if let imageData = try? Data(contentsOf: imageUrl) {
if imageUrlString.lowercased().hasSuffix(".gif") {
if let animatedImage = UIImage.animatedImage(with: UIImage.gifData(data: imageData) ?? [], duration: 1.0) {
self.imageView.image = animatedImage
self.animateImageChange(with: animatedImage)
self.addImageToHistory(image: animatedImage, tags: [randomCategory])
self.addToHistory(image: animatedImage)
} else {
print("Failed to create animated image from GIF data.")
}
} else {
if let newImage = UIImage(data: imageData) {
self.imageView.image = newImage
self.addImageToHistory(image: newImage, tags: [randomCategory])
self.addToHistory(image: newImage)
self.animateImageChange(with: newImage)
} else {
print("Failed to load image data.")
}
}

self.currentImageURL = imageUrlString
self.tagsLabel.isHidden = false
self.updateUIWithTags([randomCategory])
self.stopLoadingIndicator()
self.incrementCounter()
} else {
print("Failed to load image data.")
self.stopLoadingIndicator()
}
return
}

guard let data = data,
let jsonResponse = try? JSONSerialization.jsonObject(with: data, options: []) as? [String: Any],
let images = jsonResponse["RequestResult"] as? [[String: Any]],
let imageInfo = images.first,
let imageUrlString = imageInfo["url"] as? String else {
print("Invalid image data or missing response headers")
DispatchQueue.main.async {
self.stopLoadingIndicator()
}
return
}

DispatchQueue.main.async {
let isGif = imageUrlString.hasSuffix(".gif")

if isGif {
self.imageView.sd_setImage(with: URL(string: imageUrlString), placeholderImage: nil, options: .allowInvalidSSLCertificates, context: nil, progress: nil, completed: { (image, error, cacheType, url) in
if let error = error {
print("Error loading GIF image: \(error)")
} else {
print("Failed to parse JSON response or missing necessary data.")
self.stopLoadingIndicator()
self.handleImageLoadingCompletion(with: image ?? UIImage(), tags: [tag], imageUrlString: imageUrlString)
}
}
})
} else {
print("No data received from server.")
self.stopLoadingIndicator()
self.imageView.sd_setImage(with: URL(string: imageUrlString), placeholderImage: nil, options: [], context: nil, progress: nil, completed: { (image, error, cacheType, url) in
if let error = error {
print("Error loading image: \(error)")
} else {
self.handleImageLoadingCompletion(with: image ?? UIImage(), tags: [tag], imageUrlString: imageUrlString)
}
})
}

let endTime = DispatchTime.now()
let executionTime = endTime.uptimeNanoseconds - startTime.uptimeNanoseconds
print("Execution time: \(Double(executionTime) / 1_000_000_000) seconds")
}
}

task.resume()
}.resume()
}

private func handleImageLoadingCompletion(with newImage: UIImage, tags: [String], imageUrlString: String) {
addImageToHistory(image: newImage, tags: tags)
currentImageURL = imageUrlString
updateUIWithTags(tags)
addToHistory(image: newImage)
tagsLabel.isHidden = false
imageView.image = newImage
animateImageChange(with: newImage)
stopLoadingIndicator()
incrementCounter()
}
}
Loading

0 comments on commit b0e877b

Please sign in to comment.