Skip to content

Commit

Permalink
Innital release for v1.2
Browse files Browse the repository at this point in the history
may contains bugs
  • Loading branch information
cranci1 committed Feb 18, 2024
1 parent b37ccc7 commit 775696b
Show file tree
Hide file tree
Showing 14 changed files with 1,075 additions and 94 deletions.
26 changes: 24 additions & 2 deletions AnimeGen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
130A805F2B78C0300028985F /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 130A805D2B78C0300028985F /* LaunchScreen.storyboard */; };
138661232B81216D0062AC91 /* Hmtai.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138661222B81216D0062AC91 /* Hmtai.swift */; };
138661252B8136DC0062AC91 /* nekosapi.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138661242B8136DC0062AC91 /* nekosapi.swift */; };
13877B192B82001800251A60 /* SettingsPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13877B182B82001800251A60 /* SettingsPage.swift */; };
13877B1E2B82024A00251A60 /* AboutPage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13877B1D2B82024A00251A60 /* AboutPage.swift */; };
13877B222B8233B800251A60 /* LicensePage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13877B212B8233B800251A60 /* LicensePage.swift */; };
13910EBE2B80D380009BF17E /* ImageExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13910EBD2B80D380009BF17E /* ImageExtensions.swift */; };
13910EC02B80D396009BF17E /* UIExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13910EBF2B80D396009BF17E /* UIExtensions.swift */; };
13910EC52B80D5A6009BF17E /* pic-re.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13910EC42B80D5A6009BF17E /* pic-re.swift */; };
Expand All @@ -35,6 +38,9 @@
130A80602B78C0300028985F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
138661222B81216D0062AC91 /* Hmtai.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Hmtai.swift; sourceTree = "<group>"; };
138661242B8136DC0062AC91 /* nekosapi.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = nekosapi.swift; sourceTree = "<group>"; };
13877B182B82001800251A60 /* SettingsPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SettingsPage.swift; sourceTree = "<group>"; };
13877B1D2B82024A00251A60 /* AboutPage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AboutPage.swift; sourceTree = "<group>"; };
13877B212B8233B800251A60 /* LicensePage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LicensePage.swift; sourceTree = "<group>"; };
13910EBD2B80D380009BF17E /* ImageExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ImageExtensions.swift; sourceTree = "<group>"; };
13910EBF2B80D396009BF17E /* UIExtensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UIExtensions.swift; sourceTree = "<group>"; };
13910EC42B80D5A6009BF17E /* pic-re.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "pic-re.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -74,6 +80,7 @@
130A80512B78C02E0028985F /* AnimeGen */ = {
isa = PBXGroup;
children = (
13877B1A2B82017A00251A60 /* Settings */,
13910ECC2B80D61F009BF17E /* Extensions */,
13910EC32B80D595009BF17E /* APIs */,
130A80522B78C02E0028985F /* AppDelegate.swift */,
Expand All @@ -87,6 +94,16 @@
path = AnimeGen;
sourceTree = "<group>";
};
13877B1A2B82017A00251A60 /* Settings */ = {
isa = PBXGroup;
children = (
13877B182B82001800251A60 /* SettingsPage.swift */,
13877B1D2B82024A00251A60 /* AboutPage.swift */,
13877B212B8233B800251A60 /* LicensePage.swift */,
);
path = Settings;
sourceTree = "<group>";
};
13910EC32B80D595009BF17E /* APIs */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -187,11 +204,14 @@
buildActionMask = 2147483647;
files = (
13910EC72B80D5B9009BF17E /* waifu-im.swift in Sources */,
13877B192B82001800251A60 /* SettingsPage.swift in Sources */,
130A80572B78C02E0028985F /* ViewController.swift in Sources */,
130A80532B78C02E0028985F /* AppDelegate.swift in Sources */,
130A80552B78C02E0028985F /* SceneDelegate.swift in Sources */,
13910ECB2B80D5C8009BF17E /* waifu-pics.swift in Sources */,
138661232B81216D0062AC91 /* Hmtai.swift in Sources */,
13877B1E2B82024A00251A60 /* AboutPage.swift in Sources */,
13877B222B8233B800251A60 /* LicensePage.swift in Sources */,
13910EC52B80D5A6009BF17E /* pic-re.swift in Sources */,
13910EC02B80D396009BF17E /* UIExtensions.swift in Sources */,
138661252B8136DC0062AC91 /* nekosapi.swift in Sources */,
Expand Down Expand Up @@ -348,6 +368,7 @@
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "The gallery addition is needed to save images.";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
Expand All @@ -359,7 +380,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = me.cranci.AnimeGen;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
Expand All @@ -379,6 +400,7 @@
DEVELOPMENT_TEAM = 399LMK6Q2Y;
GENERATE_INFOPLIST_FILE = YES;
INFOPLIST_FILE = AnimeGen/Info.plist;
INFOPLIST_KEY_NSPhotoLibraryAddUsageDescription = "The gallery addition is needed to save images.";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIMainStoryboardFile = Main;
Expand All @@ -390,7 +412,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 1.0;
MARKETING_VERSION = 1.2;
PRODUCT_BUNDLE_IDENTIFIER = me.cranci.AnimeGen;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
Binary file not shown.
18 changes: 13 additions & 5 deletions AnimeGen/APIs/Hmtai.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ extension ViewController {
func loadImagesFromHmtai() {
startLoadingIndicator()

let categories3 = ["wave","wink","tea","bonk","punch","poke","bully","pat","kiss","kick","blush","feed","smug","hug","cuddle","cry","cringe","slap","five","glomp","happy","hold","nom","smile","throw","lick","bite","dance","boop","sleep","like","kill","tickle","nosebleed","threaten","depression","wolf_arts","jahy_arts","neko_arts","coffee_arts","wallpaper","mobileWallpaper"]
let categories3: [String]
let endpointPrefix: String

if UserDefaults.standard.bool(forKey: "enableExplictiCont") {
// If explicit content is enabled, include NSFW categories
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 {
categories3 = ["wave", "wink", "tea", "bonk", "punch", "poke", "bully", "pat", "kiss", "kick", "blush", "feed", "smug", "hug", "cuddle", "cry", "cringe", "slap", "five", "glomp", "happy", "hold", "nom", "smile", "throw", "lick", "bite", "dance", "boop", "sleep", "like", "kill", "tickle", "nosebleed", "threaten", "depression", "wolf_arts", "jahy_arts", "neko_arts", "coffee_arts", "wallpaper", "mobileWallpaper"]
endpointPrefix = "https://hmtai.hatsunia.cfd/sfw/"
}

let randomCategory3 = categories3.randomElement() ?? "pat"

let apiEndpoint = "https://hmtai.hatsunia.cfd/sfw/\(randomCategory3)"
let apiEndpoint = "\(endpointPrefix)\(randomCategory3)"

guard let url = URL(string: apiEndpoint) else {
print("Invalid URL")
Expand All @@ -41,15 +52,13 @@ extension ViewController {

if let imageData = try? Data(contentsOf: imageUrl) {
if imageUrlString.lowercased().hasSuffix(".gif") {

if let animatedImage = UIImage.animatedImage(with: UIImage.gifData(data: imageData) ?? [], duration: 2.0) {
self.imageView.image = animatedImage
self.animateImageChange(with: animatedImage)
} else {
print("Failed to create animated image from GIF data.")
}
} else {

if let newImage = UIImage(data: imageData) {
self.imageView.image = newImage
self.animateImageChange(with: newImage)
Expand Down Expand Up @@ -80,4 +89,3 @@ extension ViewController {
}

}

17 changes: 14 additions & 3 deletions AnimeGen/APIs/nekosapi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,21 @@ extension ViewController {
func loadImageAndTagsFromNekosapi() {
startLoadingIndicator()

let rating = ["safe", "suggestive"]
let randomrating = rating.randomElement() ?? "safe"
var ratings: [String] = ["safe"]

let apiEndpoint = "https://api.nekosapi.com/v3/images/random?limit=1&rating=\(randomrating)"
if UserDefaults.standard.bool(forKey: "enablesuggestiveCont") {
ratings.append("suggestive")
}
if UserDefaults.standard.bool(forKey: "enableBorderlineCont") {
ratings.append("borderline")
}
if UserDefaults.standard.bool(forKey: "enableExplictiCont") {
ratings.append("explicit")
}

let randomRating = ratings.randomElement() ?? "safe"

let apiEndpoint = "https://api.nekosapi.com/v3/images/random?limit=1&rating=\(randomRating)"

guard let url = URL(string: apiEndpoint) else {
print("Invalid URL")
Expand Down
142 changes: 75 additions & 67 deletions AnimeGen/APIs/waifu-im.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,72 +10,80 @@ import UIKit
extension ViewController {

func loadImageAndTagsFromWaifuIm() {
startLoadingIndicator()

let apiEndpoint = "https://api.waifu.im/search?"

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

var request = URLRequest(url: url)
request.httpMethod = "GET"

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

guard let httpResponse = response as? HTTPURLResponse else {
print("Invalid HTTP response")
self.stopLoadingIndicator()
return
}

guard httpResponse.statusCode == 200 else {
print("Invalid status code: \(httpResponse.statusCode)")
self.stopLoadingIndicator()
return
}

do {
if let jsonData = data,
let jsonResponse = try? JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any],
let images = jsonResponse["images"] as? [[String: Any]],
let firstImage = images.first,
let imageUrlString = firstImage["url"] as? String,
let imageUrl = URL(string: imageUrlString),
let tagsArray = firstImage["tags"] as? [[String: Any]] {

self.currentImageURL = imageUrlString

let tags = tagsArray.compactMap { $0["name"] as? String }

if let data = try? Data(contentsOf: imageUrl), let newImage = UIImage(data: data) {
self.imageView.image = newImage
self.animateImageChange(with: newImage)

self.updateUIWithTags(tags)

self.stopLoadingIndicator()
} else {
print("Failed to load image data.")
self.stopLoadingIndicator()
}
} else {
print("Failed to parse JSON response or missing necessary data.")
self.stopLoadingIndicator()
}
}
}
}

task.resume()
}
startLoadingIndicator()

let isNSFW = UserDefaults.standard.bool(forKey: "enableExplictiCont")

let apiEndpoint = "https://api.waifu.im/search"

var components = URLComponents(string: apiEndpoint)
components?.queryItems = [
URLQueryItem(name: "is_nsfw", value: isNSFW ? "true" : "false")
// Add more query parameters as needed
]

guard let url = components?.url else {
print("Invalid URL")
stopLoadingIndicator()
return
}

var request = URLRequest(url: url)
request.httpMethod = "GET"

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

guard let httpResponse = response as? HTTPURLResponse else {
print("Invalid HTTP response")
self.stopLoadingIndicator()
return
}

guard httpResponse.statusCode == 200 else {
print("Invalid status code: \(httpResponse.statusCode)")
self.stopLoadingIndicator()
return
}

do {
if let jsonData = data,
let jsonResponse = try? JSONSerialization.jsonObject(with: jsonData, options: []) as? [String: Any],
let images = jsonResponse["images"] as? [[String: Any]],
let firstImage = images.first,
let imageUrlString = firstImage["url"] as? String,
let imageUrl = URL(string: imageUrlString),
let tagsArray = firstImage["tags"] as? [[String: Any]] {

self.currentImageURL = imageUrlString

let tags = tagsArray.compactMap { $0["name"] as? String }

if let data = try? Data(contentsOf: imageUrl), let newImage = UIImage(data: data) {
self.imageView.image = newImage
self.animateImageChange(with: newImage)

self.updateUIWithTags(tags)

self.stopLoadingIndicator()
} else {
print("Failed to load image data.")
self.stopLoadingIndicator()
}
} else {
print("Failed to parse JSON response or missing necessary data.")
self.stopLoadingIndicator()
}
}
}
}

task.resume()
}

}
22 changes: 14 additions & 8 deletions AnimeGen/APIs/waifu-pics.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,20 @@ extension ViewController {
func loadImageFromWaifuPics() {
startLoadingIndicator()

let categories = ["waifu", "neko", "shinobu", "cuddle", "hug", "kiss", "lick", "pat", "bonk", "blush", "smile", "nom", "bite", "glomp", "slap", "kick", "happy", "poke", "dance"]
let randomCategory2 = categories.randomElement() ?? "waifu"
let categories: [String]
let endpointPrefix: String

let apiEndpoint = "https://api.waifu.pics/sfw/\(randomCategory2)"
if UserDefaults.standard.bool(forKey: "enableExplictiCont") {
categories = ["waifu", "neko", "trap", "blowjob"]
endpointPrefix = "https://api.waifu.pics/nsfw/"
} else {
categories = ["waifu", "neko", "shinobu", "cuddle", "hug", "kiss", "lick", "pat", "bonk", "blush", "smile", "nom", "bite", "glomp", "slap", "kick", "happy", "poke", "dance"]
endpointPrefix = "https://api.waifu.pics/sfw/"
}

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

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

guard let url = URL(string: apiEndpoint) else {
print("Invalid URL")
Expand All @@ -41,15 +51,13 @@ extension ViewController {

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)
} else {
print("Failed to create animated image from GIF data.")
}
} else {

if let newImage = UIImage(data: imageData) {
self.imageView.image = newImage
self.animateImageChange(with: newImage)
Expand All @@ -58,11 +66,9 @@ extension ViewController {
}
}

let category2 = randomCategory2

self.currentImageURL = imageUrlString

self.updateUIWithTags([category2])
self.updateUIWithTags([randomCategory])

self.stopLoadingIndicator()
} else {
Expand Down
4 changes: 4 additions & 0 deletions AnimeGen/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ class AppDelegate: UIResponder, UIApplicationDelegate {

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.

UserDefaults.standard.register(defaults: ["enableAnimations": true])
UserDefaults.standard.register(defaults: ["enableTags": true])

return true
}

Expand Down
Loading

0 comments on commit 775696b

Please sign in to comment.