This commit is contained in:
Trey t
2023-07-14 15:29:24 -05:00
parent d57afc1527
commit 593cc496cd
9 changed files with 150 additions and 2991 deletions

View File

@@ -25,52 +25,6 @@ struct ExerciseElement: Codable, Equatable {
}
}
extension ExerciseElement {
func videoURL(thotStyle: ThotStyle) -> URL? {
var urlString: String?
switch thotStyle {
case .always:
urlString = exercise.nsfwVideoURL
case .never:
urlString = exercise.videoURL
case .recovery:
if self.exercise.name.lowercased() == "recover" {
urlString = exercise.nsfwVideoURL
} else {
urlString = exercise.videoURL
}
case .random:
if Bool.random() {
urlString = exercise.nsfwVideoURL
} else {
urlString = exercise.videoURL
}
}
if let urlString = urlString,
let url = URL(string: BaseURLs.currentBaseURL + urlString) {
return url
}
return nil
}
func returnOtherVideoURL(currentURL: URL) -> URL? {
var urlString: String?
if currentURL.absoluteString.lowercased().contains(exercise.nsfwVideoURL.lowercased()) {
urlString = exercise.videoURL
} else {
urlString = exercise.nsfwVideoURL
}
if let urlString = urlString,
let url = URL(string: BaseURLs.currentBaseURL + urlString) {
return url
}
return nil
}
}
struct ExerciseExercise: Codable, Hashable, Identifiable {
static func == (lhs: ExerciseExercise, rhs: ExerciseExercise) -> Bool {
lhs.id == rhs.id
@@ -79,7 +33,7 @@ struct ExerciseExercise: Codable, Hashable, Identifiable {
let id: Int
let muscles: [ExerciseMuscle]
let equipment: [ExerciseEquipment]
let audioURL, videoURL, createdAt, updatedAt, nsfwVideoURL: String
let audioURL, videoURL, createdAt, updatedAt: String
let name, description, side: String
let isTwoDumbbells, isTrackableDistance, isAlternating, isWeight: Bool
let isDistance, isDuration, isReps: Bool
@@ -105,52 +59,5 @@ struct ExerciseExercise: Codable, Hashable, Identifiable {
case equipmentRequired = "equipment_required"
case muscleGroups = "muscle_groups"
case synonyms
case nsfwVideoURL = "nsfw_video_url"
}
}
extension ExerciseExercise {
func videoURL(thotStyle: ThotStyle) -> URL? {
var urlString: String?
switch thotStyle {
case .always:
urlString = nsfwVideoURL
case .never:
urlString = videoURL
case .recovery:
if self.name.lowercased() == "recovery" {
urlString = nsfwVideoURL
} else {
urlString = videoURL
}
case .random:
if Bool.random() {
urlString = nsfwVideoURL
} else {
urlString = videoURL
}
}
if let urlString = urlString,
let url = URL(string: BaseURLs.currentBaseURL + urlString) {
return url
}
return nil
}
func returnOtherVideoURL(currentURL: URL) -> URL? {
var urlString: String?
if currentURL.absoluteString.lowercased().contains(nsfwVideoURL.lowercased()) {
urlString = videoURL
} else {
urlString = nsfwVideoURL
}
if let urlString = urlString,
let url = URL(string: BaseURLs.currentBaseURL + urlString) {
return url
}
return nil
}
}

View File

@@ -20,10 +20,16 @@ struct Workout: Codable, Identifiable, Equatable {
let muscles: [String]?
let equipment: [String]?
let exercise_count: Int?
let maleVideos: [String]?
let femaleVideos: [String]?
let bothVideos: [String]?
enum CodingKeys: String, CodingKey {
case name, description, exercises, id, muscles, equipment, exercise_count
case registeredUser = "registered_user"
case maleVideos = "male_videos"
case femaleVideos = "female_videos"
case bothVideos = "both_videos"
}
init(from decoder: Decoder) throws {
@@ -41,6 +47,9 @@ struct Workout: Codable, Identifiable, Equatable {
self.muscles = try container.decodeIfPresent([String].self, forKey: .muscles)
self.equipment = try container.decodeIfPresent([String].self, forKey: .equipment)
self.exercise_count = try container.decodeIfPresent(Int.self, forKey: .exercise_count)
self.femaleVideos = try container.decodeIfPresent([String].self, forKey: .femaleVideos)
self.maleVideos = try container.decodeIfPresent([String].self, forKey: .maleVideos)
self.bothVideos = try container.decodeIfPresent([String].self, forKey: .bothVideos)
}
var exercisesSortedByCreated_at: [ExerciseElement] {