diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..968a759 --- /dev/null +++ b/.gitignore @@ -0,0 +1,41 @@ +# Created by https://www.toptal.com/developers/gitignore/api/xcode +# Edit at https://www.toptal.com/developers/gitignore?templates=xcode + +### Xcode ### +# Xcode +# +# gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore + +## User settings +xcuserdata/ + +## compatibility with Xcode 8 and earlier (ignoring not required starting Xcode 9) +*.xcscmblueprint +*.xccheckout + +## compatibility with Xcode 3 and earlier (ignoring not required starting Xcode 4) +build/ +DerivedData/ +*.moved-aside +*.pbxuser +!default.pbxuser +*.mode1v3 +!default.mode1v3 +*.mode2v3 +!default.mode2v3 +*.perspectivev3 +!default.perspectivev3 + +## Gcc Patch +/*.gcno + +### Xcode Patch ### +*.xcodeproj/* +!*.xcodeproj/project.pbxproj +!*.xcodeproj/xcshareddata/ +!*.xcworkspace/contents.xcworkspacedata +**/xcshareddata/WorkspaceSettings.xcsettings + +# End of https://www.toptal.com/developers/gitignore/api/xcode + +*.DS_STORE diff --git a/Ferrite.xcodeproj/project.pbxproj b/Ferrite.xcodeproj/project.pbxproj new file mode 100644 index 0000000..d55086b --- /dev/null +++ b/Ferrite.xcodeproj/project.pbxproj @@ -0,0 +1,514 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 55; + objects = { + +/* Begin PBXBuildFile section */ + 0C64A4B4288903680079976D /* Base32 in Frameworks */ = {isa = PBXBuildFile; productRef = 0C64A4B3288903680079976D /* Base32 */; }; + 0C64A4B7288903880079976D /* KeychainSwift in Frameworks */ = {isa = PBXBuildFile; productRef = 0C64A4B6288903880079976D /* KeychainSwift */; }; + 0C90E32C2888E5D000C0BC89 /* ActivityView in Frameworks */ = {isa = PBXBuildFile; productRef = 0C90E32B2888E5D000C0BC89 /* ActivityView */; }; + 0CA148D6288903F000DE2211 /* SettingsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148BB288903F000DE2211 /* SettingsView.swift */; }; + 0CA148D7288903F000DE2211 /* LoginWebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148BC288903F000DE2211 /* LoginWebView.swift */; }; + 0CA148D8288903F000DE2211 /* MagnetChoiceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148BD288903F000DE2211 /* MagnetChoiceView.swift */; }; + 0CA148D9288903F000DE2211 /* CardView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148BE288903F000DE2211 /* CardView.swift */; }; + 0CA148DB288903F000DE2211 /* NavView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148C1288903F000DE2211 /* NavView.swift */; }; + 0CA148DC288903F000DE2211 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0CA148C2288903F000DE2211 /* Assets.xcassets */; }; + 0CA148DD288903F000DE2211 /* ScrapingViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148C3288903F000DE2211 /* ScrapingViewModel.swift */; }; + 0CA148DE288903F000DE2211 /* RealDebridModels.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148C4288903F000DE2211 /* RealDebridModels.swift */; }; + 0CA148DF288903F000DE2211 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0CA148C6288903F000DE2211 /* Preview Assets.xcassets */; }; + 0CA148E0288903F000DE2211 /* FerriteApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148C7288903F000DE2211 /* FerriteApp.swift */; }; + 0CA148E1288903F000DE2211 /* Collection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148C9288903F000DE2211 /* Collection.swift */; }; + 0CA148E2288903F000DE2211 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148CA288903F000DE2211 /* Data.swift */; }; + 0CA148E3288903F000DE2211 /* Task.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148CB288903F000DE2211 /* Task.swift */; }; + 0CA148E4288903F000DE2211 /* Keychain.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148CC288903F000DE2211 /* Keychain.swift */; }; + 0CA148E5288903F000DE2211 /* DebridManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148CD288903F000DE2211 /* DebridManager.swift */; }; + 0CA148E6288903F000DE2211 /* WebView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148CE288903F000DE2211 /* WebView.swift */; }; + 0CA148E7288903F000DE2211 /* ToastViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148CF288903F000DE2211 /* ToastViewModel.swift */; }; + 0CA148E8288903F000DE2211 /* RealDebridWrapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D0288903F000DE2211 /* RealDebridWrapper.swift */; }; + 0CA148E9288903F000DE2211 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D1288903F000DE2211 /* MainView.swift */; }; + 0CA148EA288903F000DE2211 /* URLSharingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D2288903F000DE2211 /* URLSharingView.swift */; }; + 0CA148EB288903F000DE2211 /* SearchResultsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D3288903F000DE2211 /* SearchResultsView.swift */; }; + 0CA148EC288903F000DE2211 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D4288903F000DE2211 /* ContentView.swift */; }; + 0CA148ED288903F000DE2211 /* SearchingView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CA148D5288903F000DE2211 /* SearchingView.swift */; }; + 0CAF1C7B286F5C8600296F86 /* SwiftSoup in Frameworks */ = {isa = PBXBuildFile; productRef = 0CAF1C7A286F5C8600296F86 /* SwiftSoup */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 0CA148BB288903F000DE2211 /* SettingsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsView.swift; sourceTree = ""; }; + 0CA148BC288903F000DE2211 /* LoginWebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginWebView.swift; sourceTree = ""; }; + 0CA148BD288903F000DE2211 /* MagnetChoiceView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MagnetChoiceView.swift; sourceTree = ""; }; + 0CA148BE288903F000DE2211 /* CardView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CardView.swift; sourceTree = ""; }; + 0CA148C1288903F000DE2211 /* NavView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavView.swift; sourceTree = ""; }; + 0CA148C2288903F000DE2211 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 0CA148C3288903F000DE2211 /* ScrapingViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrapingViewModel.swift; sourceTree = ""; }; + 0CA148C4288903F000DE2211 /* RealDebridModels.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealDebridModels.swift; sourceTree = ""; }; + 0CA148C6288903F000DE2211 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; + 0CA148C7288903F000DE2211 /* FerriteApp.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FerriteApp.swift; sourceTree = ""; }; + 0CA148C9288903F000DE2211 /* Collection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Collection.swift; sourceTree = ""; }; + 0CA148CA288903F000DE2211 /* Data.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Data.swift; sourceTree = ""; }; + 0CA148CB288903F000DE2211 /* Task.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Task.swift; sourceTree = ""; }; + 0CA148CC288903F000DE2211 /* Keychain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Keychain.swift; sourceTree = ""; }; + 0CA148CD288903F000DE2211 /* DebridManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DebridManager.swift; sourceTree = ""; }; + 0CA148CE288903F000DE2211 /* WebView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WebView.swift; sourceTree = ""; }; + 0CA148CF288903F000DE2211 /* ToastViewModel.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ToastViewModel.swift; sourceTree = ""; }; + 0CA148D0288903F000DE2211 /* RealDebridWrapper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RealDebridWrapper.swift; sourceTree = ""; }; + 0CA148D1288903F000DE2211 /* MainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = ""; }; + 0CA148D2288903F000DE2211 /* URLSharingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = URLSharingView.swift; sourceTree = ""; }; + 0CA148D3288903F000DE2211 /* SearchResultsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchResultsView.swift; sourceTree = ""; }; + 0CA148D4288903F000DE2211 /* ContentView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; + 0CA148D5288903F000DE2211 /* SearchingView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchingView.swift; sourceTree = ""; }; + 0CAF1C68286F5C0E00296F86 /* Ferrite.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Ferrite.app; sourceTree = BUILT_PRODUCTS_DIR; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 0CAF1C65286F5C0E00296F86 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 0C90E32C2888E5D000C0BC89 /* ActivityView in Frameworks */, + 0C64A4B4288903680079976D /* Base32 in Frameworks */, + 0C64A4B7288903880079976D /* KeychainSwift in Frameworks */, + 0CAF1C7B286F5C8600296F86 /* SwiftSoup in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 0CA148BA288903F000DE2211 /* Ferrite */ = { + isa = PBXGroup; + children = ( + 0CA148BB288903F000DE2211 /* SettingsView.swift */, + 0CA148BC288903F000DE2211 /* LoginWebView.swift */, + 0CA148BD288903F000DE2211 /* MagnetChoiceView.swift */, + 0CA148BE288903F000DE2211 /* CardView.swift */, + 0CA148C0288903F000DE2211 /* CommonViews */, + 0CA148C2288903F000DE2211 /* Assets.xcassets */, + 0CA148C3288903F000DE2211 /* ScrapingViewModel.swift */, + 0CA148C4288903F000DE2211 /* RealDebridModels.swift */, + 0CA148C5288903F000DE2211 /* Preview Content */, + 0CA148C7288903F000DE2211 /* FerriteApp.swift */, + 0CA148C8288903F000DE2211 /* Extensions */, + 0CA148CC288903F000DE2211 /* Keychain.swift */, + 0CA148CD288903F000DE2211 /* DebridManager.swift */, + 0CA148CE288903F000DE2211 /* WebView.swift */, + 0CA148CF288903F000DE2211 /* ToastViewModel.swift */, + 0CA148D0288903F000DE2211 /* RealDebridWrapper.swift */, + 0CA148D1288903F000DE2211 /* MainView.swift */, + 0CA148D2288903F000DE2211 /* URLSharingView.swift */, + 0CA148D3288903F000DE2211 /* SearchResultsView.swift */, + 0CA148D4288903F000DE2211 /* ContentView.swift */, + 0CA148D5288903F000DE2211 /* SearchingView.swift */, + ); + path = Ferrite; + sourceTree = ""; + }; + 0CA148C0288903F000DE2211 /* CommonViews */ = { + isa = PBXGroup; + children = ( + 0CA148C1288903F000DE2211 /* NavView.swift */, + ); + path = CommonViews; + sourceTree = ""; + }; + 0CA148C5288903F000DE2211 /* Preview Content */ = { + isa = PBXGroup; + children = ( + 0CA148C6288903F000DE2211 /* Preview Assets.xcassets */, + ); + path = "Preview Content"; + sourceTree = ""; + }; + 0CA148C8288903F000DE2211 /* Extensions */ = { + isa = PBXGroup; + children = ( + 0CA148C9288903F000DE2211 /* Collection.swift */, + 0CA148CA288903F000DE2211 /* Data.swift */, + 0CA148CB288903F000DE2211 /* Task.swift */, + ); + path = Extensions; + sourceTree = ""; + }; + 0CAF1C5F286F5C0D00296F86 = { + isa = PBXGroup; + children = ( + 0CA148BA288903F000DE2211 /* Ferrite */, + 0CAF1C69286F5C0E00296F86 /* Products */, + ); + sourceTree = ""; + }; + 0CAF1C69286F5C0E00296F86 /* Products */ = { + isa = PBXGroup; + children = ( + 0CAF1C68286F5C0E00296F86 /* Ferrite.app */, + ); + name = Products; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 0CAF1C67286F5C0E00296F86 /* Ferrite */ = { + isa = PBXNativeTarget; + buildConfigurationList = 0CAF1C76286F5C0E00296F86 /* Build configuration list for PBXNativeTarget "Ferrite" */; + buildPhases = ( + 0CAF1C64286F5C0E00296F86 /* Sources */, + 0CAF1C65286F5C0E00296F86 /* Frameworks */, + 0CAF1C66286F5C0E00296F86 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = Ferrite; + packageProductDependencies = ( + 0CAF1C7A286F5C8600296F86 /* SwiftSoup */, + 0C90E32B2888E5D000C0BC89 /* ActivityView */, + 0C64A4B3288903680079976D /* Base32 */, + 0C64A4B6288903880079976D /* KeychainSwift */, + ); + productName = Torrenter; + productReference = 0CAF1C68286F5C0E00296F86 /* Ferrite.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 0CAF1C60286F5C0D00296F86 /* Project object */ = { + isa = PBXProject; + attributes = { + BuildIndependentTargetsInParallel = 1; + LastSwiftUpdateCheck = 1400; + LastUpgradeCheck = 1400; + TargetAttributes = { + 0CAF1C67286F5C0E00296F86 = { + CreatedOnToolsVersion = 14.0; + }; + }; + }; + buildConfigurationList = 0CAF1C63286F5C0D00296F86 /* Build configuration list for PBXProject "Ferrite" */; + compatibilityVersion = "Xcode 13.0"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 0CAF1C5F286F5C0D00296F86; + packageReferences = ( + 0CAF1C79286F5C8600296F86 /* XCRemoteSwiftPackageReference "SwiftSoup" */, + 0C90E32A2888E5D000C0BC89 /* XCRemoteSwiftPackageReference "ActivityView" */, + 0C64A4B2288903680079976D /* XCRemoteSwiftPackageReference "Base32" */, + 0C64A4B5288903880079976D /* XCRemoteSwiftPackageReference "keychain-swift" */, + ); + productRefGroup = 0CAF1C69286F5C0E00296F86 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 0CAF1C67286F5C0E00296F86 /* Ferrite */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 0CAF1C66286F5C0E00296F86 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0CA148DF288903F000DE2211 /* Preview Assets.xcassets in Resources */, + 0CA148DC288903F000DE2211 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 0CAF1C64286F5C0E00296F86 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 0CA148DB288903F000DE2211 /* NavView.swift in Sources */, + 0CA148E9288903F000DE2211 /* MainView.swift in Sources */, + 0CA148EC288903F000DE2211 /* ContentView.swift in Sources */, + 0CA148ED288903F000DE2211 /* SearchingView.swift in Sources */, + 0CA148E1288903F000DE2211 /* Collection.swift in Sources */, + 0CA148E4288903F000DE2211 /* Keychain.swift in Sources */, + 0CA148DD288903F000DE2211 /* ScrapingViewModel.swift in Sources */, + 0CA148D8288903F000DE2211 /* MagnetChoiceView.swift in Sources */, + 0CA148E3288903F000DE2211 /* Task.swift in Sources */, + 0CA148E7288903F000DE2211 /* ToastViewModel.swift in Sources */, + 0CA148E6288903F000DE2211 /* WebView.swift in Sources */, + 0CA148E2288903F000DE2211 /* Data.swift in Sources */, + 0CA148DE288903F000DE2211 /* RealDebridModels.swift in Sources */, + 0CA148E8288903F000DE2211 /* RealDebridWrapper.swift in Sources */, + 0CA148D6288903F000DE2211 /* SettingsView.swift in Sources */, + 0CA148E5288903F000DE2211 /* DebridManager.swift in Sources */, + 0CA148D9288903F000DE2211 /* CardView.swift in Sources */, + 0CA148EA288903F000DE2211 /* URLSharingView.swift in Sources */, + 0CA148EB288903F000DE2211 /* SearchResultsView.swift in Sources */, + 0CA148D7288903F000DE2211 /* LoginWebView.swift in Sources */, + 0CA148E0288903F000DE2211 /* FerriteApp.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin XCBuildConfiguration section */ + 0CAF1C74286F5C0E00296F86 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 0CAF1C75286F5C0E00296F86 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = YES; + CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; + CLANG_WARN_BOOL_CONVERSION = YES; + CLANG_WARN_COMMA = YES; + CLANG_WARN_CONSTANT_CONVERSION = YES; + CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; + CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; + CLANG_WARN_DOCUMENTATION_COMMENTS = YES; + CLANG_WARN_EMPTY_BODY = YES; + CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; + CLANG_WARN_INT_CONVERSION = YES; + CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; + CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; + CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; + CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 15.0; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 0CAF1C77286F5C0E00296F86 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Ferrite/Preview Content\""; + DEVELOPMENT_TEAM = 8A74DBQ6S3; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = me.kingbri.Ferrite; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 0CAF1C78286F5C0E00296F86 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + CURRENT_PROJECT_VERSION = 1; + DEVELOPMENT_ASSET_PATHS = "\"Ferrite/Preview Content\""; + DEVELOPMENT_TEAM = 8A74DBQ6S3; + ENABLE_PREVIEWS = YES; + GENERATE_INFOPLIST_FILE = YES; + INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; + INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; + INFOPLIST_KEY_UILaunchScreen_Generation = YES; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + MARKETING_VERSION = 1.0; + PRODUCT_BUNDLE_IDENTIFIER = me.kingbri.Ferrite; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_EMIT_LOC_STRINGS = YES; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 0CAF1C63286F5C0D00296F86 /* Build configuration list for PBXProject "Ferrite" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0CAF1C74286F5C0E00296F86 /* Debug */, + 0CAF1C75286F5C0E00296F86 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 0CAF1C76286F5C0E00296F86 /* Build configuration list for PBXNativeTarget "Ferrite" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 0CAF1C77286F5C0E00296F86 /* Debug */, + 0CAF1C78286F5C0E00296F86 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCRemoteSwiftPackageReference section */ + 0C64A4B2288903680079976D /* XCRemoteSwiftPackageReference "Base32" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/norio-nomura/Base32"; + requirement = { + branch = master; + kind = branch; + }; + }; + 0C64A4B5288903880079976D /* XCRemoteSwiftPackageReference "keychain-swift" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/evgenyneu/keychain-swift.git"; + requirement = { + branch = master; + kind = branch; + }; + }; + 0C90E32A2888E5D000C0BC89 /* XCRemoteSwiftPackageReference "ActivityView" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/SwiftUI-Plus/ActivityView.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 1.0.0; + }; + }; + 0CAF1C79286F5C8600296F86 /* XCRemoteSwiftPackageReference "SwiftSoup" */ = { + isa = XCRemoteSwiftPackageReference; + repositoryURL = "https://github.com/scinfu/SwiftSoup.git"; + requirement = { + kind = upToNextMajorVersion; + minimumVersion = 2.0.0; + }; + }; +/* End XCRemoteSwiftPackageReference section */ + +/* Begin XCSwiftPackageProductDependency section */ + 0C64A4B3288903680079976D /* Base32 */ = { + isa = XCSwiftPackageProductDependency; + package = 0C64A4B2288903680079976D /* XCRemoteSwiftPackageReference "Base32" */; + productName = Base32; + }; + 0C64A4B6288903880079976D /* KeychainSwift */ = { + isa = XCSwiftPackageProductDependency; + package = 0C64A4B5288903880079976D /* XCRemoteSwiftPackageReference "keychain-swift" */; + productName = KeychainSwift; + }; + 0C90E32B2888E5D000C0BC89 /* ActivityView */ = { + isa = XCSwiftPackageProductDependency; + package = 0C90E32A2888E5D000C0BC89 /* XCRemoteSwiftPackageReference "ActivityView" */; + productName = ActivityView; + }; + 0CAF1C7A286F5C8600296F86 /* SwiftSoup */ = { + isa = XCSwiftPackageProductDependency; + package = 0CAF1C79286F5C8600296F86 /* XCRemoteSwiftPackageReference "SwiftSoup" */; + productName = SwiftSoup; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 0CAF1C60286F5C0D00296F86 /* Project object */; +} diff --git a/Ferrite.xcodeproj/xcshareddata/xcschemes/Ferrite.xcscheme b/Ferrite.xcodeproj/xcshareddata/xcschemes/Ferrite.xcscheme new file mode 100644 index 0000000..454bc7f --- /dev/null +++ b/Ferrite.xcodeproj/xcshareddata/xcschemes/Ferrite.xcscheme @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Ferrite/API/Keychain.swift b/Ferrite/API/Keychain.swift new file mode 100644 index 0000000..b36d22f --- /dev/null +++ b/Ferrite/API/Keychain.swift @@ -0,0 +1,13 @@ +// +// Keychain.swift +// Ferrite +// +// Created by Brian Dashore on 7/20/22. +// + +import Foundation +import KeychainSwift + +public class Keychain { + static let shared = KeychainSwift() +} diff --git a/Ferrite/API/RealDebridModels.swift b/Ferrite/API/RealDebridModels.swift new file mode 100644 index 0000000..c5a8bf2 --- /dev/null +++ b/Ferrite/API/RealDebridModels.swift @@ -0,0 +1,113 @@ +// +// RealDebridModels.swift +// Ferrite +// +// Created by Brian Dashore on 7/5/22. +// +// Structures generated from Quicktype + +import Foundation + +// MARK: - device code endpoint +public struct DeviceCodeResponse: Codable { + let deviceCode, userCode: String + let interval, expiresIn: Int + let verificationURL, directVerificationURL: String + + enum CodingKeys: String, CodingKey { + case deviceCode = "device_code" + case userCode = "user_code" + case interval + case expiresIn = "expires_in" + case verificationURL = "verification_url" + case directVerificationURL = "direct_verification_url" + } +} + +// MARK: - device credentials endpoint +public struct DeviceCredentialsResponse: Codable { + let clientID, clientSecret: String? + + enum CodingKeys: String, CodingKey { + case clientID = "client_id" + case clientSecret = "client_secret" + } +} + +// MARK: - token endpoint +public struct TokenResponse: Codable { + let accessToken: String + let expiresIn: Int + let refreshToken, tokenType: String + + enum CodingKeys: String, CodingKey { + case accessToken = "access_token" + case expiresIn = "expires_in" + case refreshToken = "refresh_token" + case tokenType = "token_type" + } +} + +// MARK: - instantAvailability endpoint: Currently not used due to JSON complexity +/* +public struct InstantAvailabilityValue: Decodable { + let rd: [[String: InstantAvailabilityFile]] +} + +struct InstantAvailabilityFile: Codable { + let filename: String + let filesize: Int +} + +public typealias InstantAvailabilityResponse = [String: InstantAvailabilityValue] + */ + +// MARK: - addMagnet endpoint +public struct AddMagnetResponse: Codable { + let id: String + let uri: String +} + +// MARK: - torrentInfo endpoint +struct TorrentInfoResponse: Codable { + let id, filename, originalFilename, hash: String + let bytes, originalBytes: Int + let host: String + let split, progress: Int + let status, added: String + let files: [TorrentInfoFile] + let links: [String] + let ended: String + + enum CodingKeys: String, CodingKey { + case id, filename + case originalFilename = "original_filename" + case hash, bytes + case originalBytes = "original_bytes" + case host, split, progress, status, added, files, links, ended + } +} + +struct TorrentInfoFile: Codable { + let id: Int + let path: String + let bytes, selected: Int +} + +// MARK: - unrestrictLink endpoint +struct UnrestrictLinkResponse: Codable { + let id, filename, mimeType: String + let filesize: Int + let link: String + let host: String + let hostIcon: String + let chunks, crc: Int + let download: String + let streamable: Int + + enum CodingKeys: String, CodingKey { + case id, filename, mimeType, filesize, link, host + case hostIcon = "host_icon" + case chunks, crc, download, streamable + } +} diff --git a/Ferrite/API/RealDebridWrapper.swift b/Ferrite/API/RealDebridWrapper.swift new file mode 100644 index 0000000..fd547b2 --- /dev/null +++ b/Ferrite/API/RealDebridWrapper.swift @@ -0,0 +1,355 @@ +// +// RealDebridWrapper.swift +// Ferrite +// +// Created by Brian Dashore on 7/7/22. +// + +import Foundation +import SwiftUI + +public enum RealDebridError: Error { + case InvalidUrl + case InvalidPostBody + case InvalidResponse + case InvalidToken + case EmptyData + case AuthQuery(description: String) + case InstantAvailabilityQuery(description: String) + case AddMagnetQuery(description: String) + case SelectFilesQuery(description: String) + case TorrentInfoQuery(description: String) + case UnrestrictLinkQuery(description: String) +} + +public class RealDebrid: ObservableObject { + var parentManager: DebridManager? = nil + + let jsonDecoder = JSONDecoder() + let keychain = Keychain() + + let baseAuthUrl = "https://api.real-debrid.com/oauth/v2" + let baseApiUrl = "https://api.real-debrid.com/rest/1.0" + let openSourceClientId = "X245A4XAIBGVM" + + var authTask: Task? + + // Fetches the device code from RD + public func getVerificationInfo() async throws -> String { + var urlComponents = URLComponents(string: "\(baseAuthUrl)/device/code")! + urlComponents.queryItems = [ + URLQueryItem(name: "client_id", value: openSourceClientId), + URLQueryItem(name: "new_credentials", value: "yes") + ] + + guard let url = urlComponents.url else { + throw RealDebridError.InvalidUrl + } + + let request = URLRequest(url: url) + do { + let (data, _) = try await URLSession.shared.data(for: request) + + let rawResponse = try jsonDecoder.decode(DeviceCodeResponse.self, from: data) + + // Spawn a separate process to get the device code + Task { + do { + try await getDeviceCredentials(deviceCode: rawResponse.deviceCode) + } catch { + print("Authentication error: \(error)") + authTask?.cancel() + + Task { @MainActor in + parentManager?.toastModel?.toastDescription = "Authentication error: \(error)" + } + } + } + + return rawResponse.directVerificationURL + } catch { + print("Couldn't get the new client creds!") + throw RealDebridError.AuthQuery(description: error.localizedDescription) + } + } + + // Fetches the user's client ID and secret + public func getDeviceCredentials(deviceCode: String) async throws { + var urlComponents = URLComponents(string: "\(baseAuthUrl)/device/credentials")! + urlComponents.queryItems = [ + URLQueryItem(name: "client_id", value: openSourceClientId), + URLQueryItem(name: "code", value: deviceCode) + ] + + guard let url = urlComponents.url else { + throw RealDebridError.InvalidUrl + } + + let request = URLRequest(url: url) + try await getDeviceCredentialsInternal(urlRequest: request, deviceCode: deviceCode) + } + + // Timer to poll RD api for credentials + func getDeviceCredentialsInternal(urlRequest: URLRequest, deviceCode: String) async throws { + authTask = Task { + var count = 0 + + while count < 20 { + let (data, _) = try await URLSession.shared.data(for: urlRequest) + + // We don't care if this fails + let rawResponse = try? self.jsonDecoder.decode(DeviceCredentialsResponse.self, from: data) + + if let clientId = rawResponse?.clientID, let clientSecret = rawResponse?.clientSecret { + UserDefaults.standard.set(clientId, forKey: "RealDebrid.ClientId") + Keychain.shared.set(clientSecret, forKey: "RealDebrid.ClientSecret") + + try await getTokens(deviceCode: deviceCode) + + break + } else { + try await Task.sleep(seconds: 5) + count += 1 + } + } + } + + if case let .failure(error) = await authTask?.result { + print(error) + throw error + } + } + + // Fetch all tokens for the user and store in keychain + public func getTokens(deviceCode: String) async throws { + guard let clientId = UserDefaults.standard.string(forKey: "RealDebrid.ClientId") else { + throw RealDebridError.EmptyData + } + + guard let clientSecret = Keychain.shared.get("RealDebrid.ClientSecret") else { + throw RealDebridError.EmptyData + } + + var request = URLRequest(url: URL(string: "\(baseAuthUrl)/token")!) + request.httpMethod = "POST" + request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") + + var bodyComponents = URLComponents() + bodyComponents.queryItems = [ + URLQueryItem(name: "client_id", value: clientId), + URLQueryItem(name: "client_secret", value: clientSecret), + URLQueryItem(name: "code", value: deviceCode), + URLQueryItem(name: "grant_type", value: "http://oauth.net/grant_type/device/1.0") + ] + + request.httpBody = bodyComponents.query?.data(using: .utf8) + + let (data, _) = try await URLSession.shared.data(for: request) + + let rawResponse = try jsonDecoder.decode(TokenResponse.self, from: data) + + Keychain.shared.set(rawResponse.accessToken, forKey: "RealDebrid.AccessToken") + Keychain.shared.set(rawResponse.refreshToken, forKey: "RealDebrid.RefreshToken") + + let accessTimestamp = Date().timeIntervalSince1970 + Double(rawResponse.expiresIn) + UserDefaults.standard.set(accessTimestamp, forKey: "RealDebrid.AccessTokenStamp") + + // Set AppStorage variable + Task { @MainActor in + parentManager?.realDebridEnabled = true + } + } + + public func fetchToken() async -> String? { + let accessTokenStamp = UserDefaults.standard.double(forKey: "RealDebrid.AccessTokenStamp") + + if Date().timeIntervalSince1970 > accessTokenStamp { + do { + if let refreshToken = Keychain.shared.get("RealDebrid.RefreshToken") { + print("Refresh token found") + try await getTokens(deviceCode: refreshToken) + } + } catch { + print(error) + return nil + } + } + + return Keychain.shared.get("RealDebrid.AccessToken") + } + + public func deleteTokens() async throws { + Keychain.shared.delete("RealDebrid.RefreshToken") + Keychain.shared.delete("RealDebrid.ClientSecret") + UserDefaults.standard.removeObject(forKey: "RealDebrid.ClientId") + UserDefaults.standard.removeObject(forKey: "RealDebrid.AccessTokenStamp") + + // Run the request, doesn't matter if it fails + if let token = Keychain.shared.get("RealDebrid.AccessToken") { + var request = URLRequest(url: URL(string: "\(baseApiUrl)/disable_access_token")!) + request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + let _ = try? await URLSession.shared.data(for: request) + + Keychain.shared.delete("RealDebrid.AccessToken") + } + + Task { @MainActor in + parentManager?.realDebridEnabled = false + } + } + + // Checks if the magnet is streamable on RD + // Currently does not work for batch links + public func instantAvailability(magnetHashes: [String]) async -> [String]? { + var availableHashes: [String] = [] + + var request = URLRequest(url: URL(string: "\(baseApiUrl)/torrents/instantAvailability/\(magnetHashes.joined(separator: "/"))")!) + + guard let token = await fetchToken() else { + return nil + } + + request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + + do { + // Assume that RealDebrid can be called here + let (data, response) = try await URLSession.shared.data(for: request) + + // Unauthorized, auto-logout of RD, wrap this into a request function + if let httpResponse = response as? HTTPURLResponse, httpResponse.statusCode == 401 { + try await deleteTokens() + } + + // Does not account for torrent packs at the moment + if let rawResponse = try JSONSerialization.jsonObject(with: data) as? [String: Any] { + for (key, value) in rawResponse { + if value as? [String: Any] != nil { + availableHashes.append(key) + } + } + } + } catch { + // Assume that RealDebrid cannot be used here + print("RealDebrid request error: \(error)") + + Task { @MainActor in + parentManager?.toastModel?.toastDescription = "RealDebrid InstantAvailability error: \(error)" + } + + return nil + } + + return availableHashes + } + + // Adds a magnet link to the user's RD account + public func addMagnet(magnetLink: String) async throws -> String { + var request = URLRequest(url: URL(string: "\(baseApiUrl)/torrents/addMagnet")!) + + guard let token = await fetchToken() else { + throw RealDebridError.InvalidToken + } + + request.httpMethod = "POST" + request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + + request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") + + var bodyComponents = URLComponents() + bodyComponents.queryItems = [URLQueryItem(name: "magnet", value: magnetLink)] + + request.httpBody = bodyComponents.query?.data(using: .utf8) + + do { + let (data, _) = try await URLSession.shared.data(for: request) + let rawResponse = try jsonDecoder.decode(AddMagnetResponse.self, from: data) + + return rawResponse.id + } catch { + print("Magnet link query error! \(error)") + throw RealDebridError.AddMagnetQuery(description: error.localizedDescription) + } + } + + // Queues the magnet link for downloading + public func selectFiles(debridID: String) async throws -> HTTPURLResponse? { + var request = URLRequest(url: URL(string: "\(baseApiUrl)/torrents/selectFiles/\(debridID)")!) + + guard let token = await fetchToken() else { + throw RealDebridError.InvalidToken + } + + request.httpMethod = "POST" + request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + + request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") + + var bodyComponents = URLComponents() + bodyComponents.queryItems = [URLQueryItem(name: "files", value: "all")] + + request.httpBody = bodyComponents.query?.data(using: .utf8) + + do { + let (_, response) = try await URLSession.shared.data(for: request) + + return response as? HTTPURLResponse + } catch { + print("Magnet file query error! \(error)") + throw RealDebridError.SelectFilesQuery(description: error.localizedDescription) + } + } + + // Fetches the info of a torrent + public func torrentInfo(debridID: String) async throws -> String { + var request = URLRequest(url: URL(string: "\(baseApiUrl)/torrents/info/\(debridID)")!) + + guard let token = await fetchToken() else { + throw RealDebridError.InvalidToken + } + + request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + + do { + let (data, _) = try await URLSession.shared.data(for: request) + let rawResponse = try jsonDecoder.decode(TorrentInfoResponse.self, from: data) + + if let torrentLink = rawResponse.links[safe: 0] { + return torrentLink + } else { + throw RealDebridError.EmptyData + } + } catch { + print("Torrent info query error: \(error)") + throw RealDebridError.TorrentInfoQuery(description: error.localizedDescription) + } + } + + // Downloads link from selectFiles for playback + public func unrestrictLink(debridDownloadLink: String) async throws -> String { + var request = URLRequest(url: URL(string: "\(baseApiUrl)/unrestrict/link")!) + + guard let token = await fetchToken() else { + throw RealDebridError.InvalidToken + } + + request.httpMethod = "POST" + request.setValue("Bearer \(token)", forHTTPHeaderField: "Authorization") + + request.setValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type") + + var bodyComponents = URLComponents() + bodyComponents.queryItems = [URLQueryItem(name: "link", value: debridDownloadLink)] + + request.httpBody = bodyComponents.query?.data(using: .utf8) + + do { + let (data, _) = try await URLSession.shared.data(for: request) + let rawResponse = try jsonDecoder.decode(UnrestrictLinkResponse.self, from: data) + + return rawResponse.download + } catch { + print("Unrestrict link error: \(error)") + throw RealDebridError.UnrestrictLinkQuery(description: error.localizedDescription) + } + } +} diff --git a/Torrenter/Assets.xcassets/AccentColor.colorset/Contents.json b/Ferrite/Assets.xcassets/AccentColor.colorset/Contents.json similarity index 100% rename from Torrenter/Assets.xcassets/AccentColor.colorset/Contents.json rename to Ferrite/Assets.xcassets/AccentColor.colorset/Contents.json diff --git a/Torrenter/Assets.xcassets/AppIcon.appiconset/Contents.json b/Ferrite/Assets.xcassets/AppIcon.appiconset/Contents.json similarity index 100% rename from Torrenter/Assets.xcassets/AppIcon.appiconset/Contents.json rename to Ferrite/Assets.xcassets/AppIcon.appiconset/Contents.json diff --git a/Torrenter/Assets.xcassets/Contents.json b/Ferrite/Assets.xcassets/Contents.json similarity index 100% rename from Torrenter/Assets.xcassets/Contents.json rename to Ferrite/Assets.xcassets/Contents.json diff --git a/Ferrite/Extensions/Collection.swift b/Ferrite/Extensions/Collection.swift new file mode 100644 index 0000000..d334f81 --- /dev/null +++ b/Ferrite/Extensions/Collection.swift @@ -0,0 +1,15 @@ +// +// Collection.swift +// Ferrite +// +// Created by Brian Dashore on 7/4/22. +// + +import Foundation + +extension Collection { + // From https://stackoverflow.com/questions/25329186/safe-bounds-checked-array-lookup-in-swift-through-optional-bindings + subscript(safe index: Index) -> Element? { + indices.contains(index) ? self[index] : nil + } +} diff --git a/Ferrite/Extensions/Data.swift b/Ferrite/Extensions/Data.swift new file mode 100644 index 0000000..508c6e0 --- /dev/null +++ b/Ferrite/Extensions/Data.swift @@ -0,0 +1,14 @@ +// +// Data.swift +// Ferrite +// +// Created by Brian Dashore on 7/4/22. +// + +import Foundation + +extension Data { + func hexEncodedString() -> String { + return map { String(format: "%02hhx", $0) }.joined() + } +} diff --git a/Ferrite/Extensions/Task.swift b/Ferrite/Extensions/Task.swift new file mode 100644 index 0000000..8270e0e --- /dev/null +++ b/Ferrite/Extensions/Task.swift @@ -0,0 +1,15 @@ +// +// Task.swift +// Ferrite +// +// Created by Brian Dashore on 7/18/22. +// + +import Foundation + +extension Task where Success == Never, Failure == Never { + static func sleep(seconds: Double) async throws { + let duration = UInt64(seconds * 1000000000) + try await Task.sleep(nanoseconds: duration) + } +} diff --git a/Ferrite/FerriteApp.swift b/Ferrite/FerriteApp.swift new file mode 100644 index 0000000..3bdeaa9 --- /dev/null +++ b/Ferrite/FerriteApp.swift @@ -0,0 +1,28 @@ +// +// FerriteApp.swift +// Ferrite +// +// Created by Brian Dashore on 7/1/22. +// + +import SwiftUI + +@main +struct FerriteApp: App { + @StateObject var scrapingModel: ScrapingViewModel = .init() + @StateObject var toastModel: ToastViewModel = .init() + @StateObject var debridManager: DebridManager = .init() + + var body: some Scene { + WindowGroup { + MainView() + .onAppear { + scrapingModel.toastModel = toastModel + debridManager.toastModel = toastModel + } + .environmentObject(debridManager) + .environmentObject(scrapingModel) + .environmentObject(toastModel) + } + } +} diff --git a/Ferrite/Models/DebridManager.swift b/Ferrite/Models/DebridManager.swift new file mode 100644 index 0000000..00f2296 --- /dev/null +++ b/Ferrite/Models/DebridManager.swift @@ -0,0 +1,88 @@ +// +// DebridManager.swift +// Ferrite +// +// Created by Brian Dashore on 7/20/22. +// + +import Foundation +import SwiftUI + +public class DebridManager: ObservableObject { + // UI Variables + var toastModel: ToastViewModel? = nil + @Published var showWebView: Bool = false + + // RealDebrid variables + let realDebrid: RealDebrid = RealDebrid() + + @AppStorage("RealDebrid.Enabled") var realDebridEnabled = false + + @Published var realDebridHashes: [String] = [] + @Published var realDebridAuthUrl: String = "" + @Published var realDebridDownloadUrl: String = "" + + init() { + realDebrid.parentManager = self + } + + public func populateDebridHashes(_ searchResults: [SearchResult]) async { + var hashes: [String] = [] + + for result in searchResults { + if let hash = result.magnetHash { + hashes.append(hash) + } + } + + guard let debridHashes = await realDebrid.instantAvailability(magnetHashes: hashes) else { + return + } + + Task { @MainActor in + realDebridHashes = debridHashes + } + } + + public func authenticateRd() async { + do { + let url = try await realDebrid.getVerificationInfo() + + Task { @MainActor in + realDebridAuthUrl = url + showWebView.toggle() + } + } catch { + Task { @MainActor in + toastModel?.toastDescription = "RealDebrid Authentication error: \(error)" + } + + print(error) + } + } + + public func fetchRdDownload(searchResult: SearchResult) async { + do { + let realDebridId = try await realDebrid.addMagnet(magnetLink: searchResult.magnetLink) + let httpResponse = try await realDebrid.selectFiles(debridID: realDebridId) + + if httpResponse?.statusCode != 204 { + // Throw error here + return + } + + let torrentLink = try await realDebrid.torrentInfo(debridID: realDebridId) + let downloadLink = try await realDebrid.unrestrictLink(debridDownloadLink: torrentLink) + + Task { @MainActor in + realDebridDownloadUrl = downloadLink + } + } catch { + Task { @MainActor in + toastModel?.toastDescription = "RealDebrid download error: \(error)" + } + + print(error) + } + } +} diff --git a/Ferrite/Models/ScrapingViewModel.swift b/Ferrite/Models/ScrapingViewModel.swift new file mode 100644 index 0000000..a0abab1 --- /dev/null +++ b/Ferrite/Models/ScrapingViewModel.swift @@ -0,0 +1,145 @@ +// +// ScrapingViewModel.swift +// Ferrite +// +// Created by Brian Dashore on 7/4/22. +// + +import Base32 +import SwiftUI +import SwiftSoup + +public struct SearchResult: Hashable, Codable { + let title: String + let magnetLink: String + let magnetHash: String? +} + +public struct TorrentSource: Hashable, Codable { + let name: String + let url: String + let rowQuery: String + let linkQuery: String + let titleQuery: String +} + +class ScrapingViewModel: ObservableObject { + @AppStorage("RealDebrid.Enabled") var realDebridEnabled = false + + // Link the toast view model for single-directional communication + var toastModel: ToastViewModel? = nil + + // Decopule this in the future + let sources = [ + //TorrentSource( + //name: "Nyaa", + //url: "https://nyaa.si", + //rowQuery: ".torrent-list tbody tr", + //linkQuery: "td:nth-child(3) > a:nth-child(2))", + //titleQuery: "td:nth-child(2) > a:last-child" + //), + TorrentSource( + name: "AnimeTosho", + url: "https://mirror.animetosho.org/search?q=", + rowQuery: "#content .home_list_entry", + linkQuery: ".links > a:nth-child(4)", + titleQuery: ".link" + ) + ] + + @Published var searchResults: [SearchResult] = [] + @Published var debridHashes: [String] = [] + @Published var searchText: String = "" + + @Published var realDebridAuthUrl: String = "" + @Published var showWebView: Bool = false + + // Fetches the HTML body for the source website + public func fetchWebsiteHtml(source: TorrentSource) async -> String? { + guard let encodedQuery = searchText.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) else { + print("Could not process search query, invalid characters") + return nil + } + + guard let url = URL(string: source.url + encodedQuery) else { + print("Source doesn't contain a valid URL") + return nil + } + + do { + let (data, _) = try await URLSession.shared.data(from: url) + let html = String(data: data, encoding: .ascii) + return html + } catch { + print("Error in fetching HTML \(error)") + return nil + } + } + + // Returns results to UI + // Results must have a link and title, but other parameters aren't required + @MainActor + public func scrapeWebsite(source: TorrentSource, html: String) async { + var tempResults: [SearchResult] = [] + var hashes: [String] = [] + + do { + let document = try SwiftSoup.parse(html) + + let rows = try document.select(source.rowQuery) + + for row in rows { + guard let link = try row.select(source.linkQuery).first() else { + continue + } + + let href = try link.attr("href") + + if !href.starts(with: "magnet:") { + continue + } + + let magnetHash = fetchMagnetHash(magnetLink: href) + + let title = try row.select(source.titleQuery).first() + let text = try title?.text() + + let result = SearchResult( + title: text ?? "No title provided", + magnetLink: href, + magnetHash: magnetHash + ) + + // Change to bulk request to speed up UI + if let hash = magnetHash { + hashes.append(hash) + } + + tempResults.append(result) + } + + searchResults = tempResults + } catch { + print("Error while scraping: \(error)") + } + } + + // Fetches and possibly converts the magnet hash value to sha1 + public func fetchMagnetHash(magnetLink: String) -> String? { + guard let firstSplit = magnetLink.split(separator: ":")[safe: 3] else { + return nil + } + + guard let magnetHash = firstSplit.split(separator: "&")[safe: 0] else { + return nil + } + + // Is this a Base32hex hash? + if magnetHash.count == 32 { + let decryptedMagnetHash = base32DecodeToData(String(magnetHash)) + return decryptedMagnetHash?.hexEncodedString() + } else { + return String(magnetHash) + } + } +} diff --git a/Ferrite/Models/ToastViewModel.swift b/Ferrite/Models/ToastViewModel.swift new file mode 100644 index 0000000..a4cde3f --- /dev/null +++ b/Ferrite/Models/ToastViewModel.swift @@ -0,0 +1,40 @@ +// +// ErrorViewModel.swift +// Ferrite +// +// Created by Brian Dashore on 7/19/22. +// + +import SwiftUI + +@MainActor +class ToastViewModel: ObservableObject { + enum ToastType: Identifiable { + var id: Int { + hashValue + } + + case info + case error + } + + // Toast variables + @Published var toastDescription: String? = nil { + didSet { + Task { + try? await Task.sleep(seconds: 0.1) + showToast = true + + try await Task.sleep(seconds: 5) + + showToast = false + toastType = .error + } + } + } + + @Published var showToast: Bool = false + + // Default the toast type to error since the majority of toasts are errors + @Published var toastType: ToastType = .error +} diff --git a/Torrenter/Preview Content/Preview Assets.xcassets/Contents.json b/Ferrite/Preview Content/Preview Assets.xcassets/Contents.json similarity index 100% rename from Torrenter/Preview Content/Preview Assets.xcassets/Contents.json rename to Ferrite/Preview Content/Preview Assets.xcassets/Contents.json diff --git a/Ferrite/Views/CardView.swift b/Ferrite/Views/CardView.swift new file mode 100644 index 0000000..6582596 --- /dev/null +++ b/Ferrite/Views/CardView.swift @@ -0,0 +1,24 @@ +// +// CardView.swift +// Ferrite +// +// Created by Brian Dashore on 7/4/22. +// + +import SwiftUI + +struct CardView: View { + @Binding var result: SearchResult + + var body: some View { + Text(/*@START_MENU_TOKEN@*/"Hello, World!"/*@END_MENU_TOKEN@*/) + } +} + +/* + struct CardView_Previews: PreviewProvider { + static var previews: some View { + CardView() + } + } + */ diff --git a/Ferrite/Views/CommonViews/NavView.swift b/Ferrite/Views/CommonViews/NavView.swift new file mode 100644 index 0000000..cd8ffd4 --- /dev/null +++ b/Ferrite/Views/CommonViews/NavView.swift @@ -0,0 +1,28 @@ +// +// NavView.swift +// Ferrite +// +// Created by Brian Dashore on 7/4/22. +// + +import SwiftUI + +struct NavView: View { + let content: () -> Content + init(@ViewBuilder _ content: @escaping () -> Content) { + self.content = content + } + + var body: some View { + if #available(iOS 16, *) { + NavigationStack { + content() + } + } else { + NavigationView { + content() + } + .navigationViewStyle(.stack) + } + } +} diff --git a/Ferrite/Views/ContentView.swift b/Ferrite/Views/ContentView.swift new file mode 100644 index 0000000..32edbe7 --- /dev/null +++ b/Ferrite/Views/ContentView.swift @@ -0,0 +1,41 @@ +// +// ContentView.swift +// Ferrite +// +// Created by Brian Dashore on 7/1/22. +// + +import SwiftUI + +struct ContentView: View { + @EnvironmentObject var scrapingModel: ScrapingViewModel + @EnvironmentObject var debridManager: DebridManager + + var body: some View { + NavView { + VStack { + SearchResultsView() + } + .searchable(text: $scrapingModel.searchText) + .onSubmit(of: .search) { + Task { + for source in scrapingModel.sources { + guard let html = await scrapingModel.fetchWebsiteHtml(source: source) else { + continue + } + + await scrapingModel.scrapeWebsite(source: source, html: html) + await debridManager.populateDebridHashes(scrapingModel.searchResults) + } + } + } + .navigationTitle("Search") + } + } +} + +struct ContentView_Previews: PreviewProvider { + static var previews: some View { + ContentView() + } +} diff --git a/Ferrite/Views/LoginWebView.swift b/Ferrite/Views/LoginWebView.swift new file mode 100644 index 0000000..a65a683 --- /dev/null +++ b/Ferrite/Views/LoginWebView.swift @@ -0,0 +1,33 @@ +// +// LoginWebView.swift +// Ferrite +// +// Created by Brian Dashore on 7/20/22. +// + +import SwiftUI + +struct LoginWebView: View { + @Environment(\.dismiss) var dismiss + var url: URL + var body: some View { + NavView { + WebView(url: url) + .navigationTitle("Sign in") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button("Done") { + dismiss() + } + } + } + } + } +} + +struct LoginWebView_Previews: PreviewProvider { + static var previews: some View { + LoginWebView(url: URL(string: "https://google.com")!) + } +} diff --git a/Ferrite/Views/MagnetChoiceView.swift b/Ferrite/Views/MagnetChoiceView.swift new file mode 100644 index 0000000..fccd564 --- /dev/null +++ b/Ferrite/Views/MagnetChoiceView.swift @@ -0,0 +1,98 @@ +// +// MagnetChoiceView.swift +// Ferrite +// +// Created by Brian Dashore on 7/20/22. +// + +import SwiftUI +import ActivityView + +struct MagnetChoiceView: View { + @Environment(\.dismiss) var dismiss + + @EnvironmentObject var debridManager: DebridManager + + @AppStorage("RealDebrid.Enabled") var realDebridEnabled = false + + @Binding var selectedResult: SearchResult? + + @State private var showActivityView = false + @State private var activityItem: ActivityItem? + + var body: some View { + NavView { + Form { + if realDebridEnabled { + Section("Real Debrid options") { + Button("Play on Outplayer") { + guard let downloadUrl = URL(string: "outplayer://\(debridManager.realDebridDownloadUrl)") else { + return + } + + UIApplication.shared.open(downloadUrl) + } + + Button("Play on VLC") { + guard let downloadUrl = URL(string: "vlc://\(debridManager.realDebridDownloadUrl)") else { + return + } + + UIApplication.shared.open(downloadUrl) + } + + Button("Play on Infuse") { + guard let downloadUrl = URL(string: "infuse://x-callback-url/play?url=\(debridManager.realDebridDownloadUrl)") else { + return + } + + UIApplication.shared.open(downloadUrl) + } + + Button("Copy download URL") { + UIPasteboard.general.string = debridManager.realDebridDownloadUrl + } + + Button("Share download URL") { + guard let url = URL(string: debridManager.realDebridDownloadUrl) else { + return + } + + activityItem = ActivityItem(items: url) + showActivityView.toggle() + } + } + } + + Section("Magnet options") { + Button("Copy magnet") { + UIPasteboard.general.string = selectedResult?.magnetLink + } + + Button("Share magnet") { + if let result = selectedResult, let url = URL(string: result.magnetLink) { + activityItem = ActivityItem(items: url) + showActivityView.toggle() + } + } + } + } + .activitySheet($activityItem) + .navigationTitle("Link actions") + .navigationBarTitleDisplayMode(.inline) + .toolbar { + ToolbarItem(placement: .navigationBarTrailing) { + Button("Done") { + dismiss() + } + } + } + } + } +} + +struct MagnetChoiceView_Previews: PreviewProvider { + static var previews: some View { + MagnetChoiceView(selectedResult: .constant(SearchResult(title: "", magnetLink: "", magnetHash: nil))) + } +} diff --git a/Ferrite/Views/MainView.swift b/Ferrite/Views/MainView.swift new file mode 100644 index 0000000..c5637ab --- /dev/null +++ b/Ferrite/Views/MainView.swift @@ -0,0 +1,58 @@ +// +// MainView.swift +// Ferrite +// +// Created by Brian Dashore on 7/11/22. +// + +import SwiftUI + +enum Tab { + case search + case settings +} + +struct MainView: View { + @EnvironmentObject var toastModel: ToastViewModel + + @State private var tabSelection: Tab = .search + + var body: some View { + TabView(selection: $tabSelection) { + ContentView() + .tabItem { + Label("Search", systemImage: "magnifyingglass") + } + .tag(Tab.search) + SettingsView() + .tabItem { + Label("Settings", systemImage: "gear") + } + .tag(Tab.settings) + } + .overlay { + VStack { + Spacer() + if toastModel.showToast { + GroupBox { + switch toastModel.toastType { + case .info: + Text(toastModel.toastDescription ?? "This shouldn't be showing up... Contact the dev!") + case .error: + Text("Error: \(toastModel.toastDescription ?? "This shouldn't be showing up... Contact the dev!")") + } + } + } + } + .transition(AnyTransition.move(edge: .bottom)) + .animation(.easeInOut(duration: 0.3), value: true) + .padding() + } + } +} + +struct MainView_Previews: PreviewProvider { + static var previews: some View { + MainView() + } +} diff --git a/Ferrite/Views/RepresentableViews/WebView.swift b/Ferrite/Views/RepresentableViews/WebView.swift new file mode 100644 index 0000000..50666cf --- /dev/null +++ b/Ferrite/Views/RepresentableViews/WebView.swift @@ -0,0 +1,28 @@ +// +// WebView.swift +// Ferrite +// +// Created by Brian Dashore on 7/17/22. +// + +import SwiftUI +import WebKit + +struct WebView: UIViewRepresentable { + var url: URL + + func makeUIView(context: Context) -> WKWebView { + let webView = WKWebView() + webView.load(URLRequest(url: url)) + return webView + } + + func updateUIView(_ uiView: WKWebView, context: Context) { + } +} + +struct WebView_Previews: PreviewProvider { + static var previews: some View { + WebView(url: URL(string: "https://google.com")!) + } +} diff --git a/Ferrite/Views/SearchResultsView.swift b/Ferrite/Views/SearchResultsView.swift new file mode 100644 index 0000000..06003ad --- /dev/null +++ b/Ferrite/Views/SearchResultsView.swift @@ -0,0 +1,69 @@ +// +// SearchResultsView.swift +// Ferrite +// +// Created by Brian Dashore on 7/11/22. +// + +import SwiftUI + +struct SearchResultsView: View { + @Environment(\.isSearching) var isSearching + @Environment(\.colorScheme) var colorScheme + + @EnvironmentObject var scrapingModel: ScrapingViewModel + @EnvironmentObject var debridManager: DebridManager + + @AppStorage("RealDebrid.Enabled") var realDebridEnabled = false + + @State var selectedResult: SearchResult? + + @State private var showExternalSheet = false + + var body: some View { + List { + ForEach(scrapingModel.searchResults, id: \.self) { result in + VStack(alignment: .leading) { + Button(result.title) { + selectedResult = result + + if debridManager.realDebridHashes.contains(result.magnetHash ?? ""), realDebridEnabled { + Task { + await debridManager.fetchRdDownload(searchResult: result) + showExternalSheet.toggle() + } + } else { + showExternalSheet.toggle() + } + } + .sheet(isPresented: $showExternalSheet) { + MagnetChoiceView(selectedResult: $selectedResult) + } + .tint(colorScheme == .light ? .black : .white) + .font(.callout) + .padding(.bottom, 5) + + HStack { + if realDebridEnabled { + Text("Real Debrid available: \(debridManager.realDebridHashes.contains(result.magnetHash ?? "") ? "Yes" : "No")") + } + + Spacer() + } + .font(.caption) + } + } + } + .onChange(of: isSearching) { changed in + if !changed { + scrapingModel.searchResults = [] + } + } + } +} + +struct SearchResultsView_Previews: PreviewProvider { + static var previews: some View { + SearchResultsView() + } +} diff --git a/Ferrite/Views/SettingsView.swift b/Ferrite/Views/SettingsView.swift new file mode 100644 index 0000000..62524d2 --- /dev/null +++ b/Ferrite/Views/SettingsView.swift @@ -0,0 +1,52 @@ +// +// SettingsView.swift +// Ferrite +// +// Created by Brian Dashore on 7/11/22. +// + +import SwiftUI + +struct SettingsView: View { + @EnvironmentObject var debridManager: DebridManager + + @AppStorage("RealDebrid.Enabled") var realDebridEnabled = false + + @State private var isProcessing = false + + var body: some View { + NavView { + Form { + Section("Debrid services") { + HStack { + Text("Real Debrid") + Spacer() + Button { + Task { + if realDebridEnabled { + try? await debridManager.realDebrid.deleteTokens() + } else if !isProcessing { + await debridManager.authenticateRd() + isProcessing = true + } + } + } label: { + Text(realDebridEnabled ? "Logout" : (isProcessing ? "Processing" : "Login")) + .foregroundColor(realDebridEnabled ? .red : .blue) + } + } + } + } + .sheet(isPresented: $debridManager.showWebView) { + LoginWebView(url: URL(string: debridManager.realDebridAuthUrl)!) + } + .navigationTitle("Settings") + } + } +} + +struct SettingsView_Previews: PreviewProvider { + static var previews: some View { + SettingsView() + } +} diff --git a/Torrenter.xcodeproj/project.pbxproj b/Torrenter.xcodeproj/project.pbxproj deleted file mode 100644 index ba26c52..0000000 --- a/Torrenter.xcodeproj/project.pbxproj +++ /dev/null @@ -1,344 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 56; - objects = { - -/* Begin PBXBuildFile section */ - 0CAF1C6C286F5C0E00296F86 /* TorrenterApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAF1C6B286F5C0E00296F86 /* TorrenterApp.swift */; }; - 0CAF1C6E286F5C0E00296F86 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0CAF1C6D286F5C0E00296F86 /* ContentView.swift */; }; - 0CAF1C70286F5C0E00296F86 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0CAF1C6F286F5C0E00296F86 /* Assets.xcassets */; }; - 0CAF1C73286F5C0E00296F86 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0CAF1C72286F5C0E00296F86 /* Preview Assets.xcassets */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - 0CAF1C68286F5C0E00296F86 /* Torrenter.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Torrenter.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 0CAF1C6B286F5C0E00296F86 /* TorrenterApp.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TorrenterApp.swift; sourceTree = ""; }; - 0CAF1C6D286F5C0E00296F86 /* ContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentView.swift; sourceTree = ""; }; - 0CAF1C6F286F5C0E00296F86 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; - 0CAF1C72286F5C0E00296F86 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 0CAF1C65286F5C0E00296F86 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 0CAF1C5F286F5C0D00296F86 = { - isa = PBXGroup; - children = ( - 0CAF1C6A286F5C0E00296F86 /* Torrenter */, - 0CAF1C69286F5C0E00296F86 /* Products */, - ); - sourceTree = ""; - }; - 0CAF1C69286F5C0E00296F86 /* Products */ = { - isa = PBXGroup; - children = ( - 0CAF1C68286F5C0E00296F86 /* Torrenter.app */, - ); - name = Products; - sourceTree = ""; - }; - 0CAF1C6A286F5C0E00296F86 /* Torrenter */ = { - isa = PBXGroup; - children = ( - 0CAF1C6B286F5C0E00296F86 /* TorrenterApp.swift */, - 0CAF1C6D286F5C0E00296F86 /* ContentView.swift */, - 0CAF1C6F286F5C0E00296F86 /* Assets.xcassets */, - 0CAF1C71286F5C0E00296F86 /* Preview Content */, - ); - path = Torrenter; - sourceTree = ""; - }; - 0CAF1C71286F5C0E00296F86 /* Preview Content */ = { - isa = PBXGroup; - children = ( - 0CAF1C72286F5C0E00296F86 /* Preview Assets.xcassets */, - ); - path = "Preview Content"; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 0CAF1C67286F5C0E00296F86 /* Torrenter */ = { - isa = PBXNativeTarget; - buildConfigurationList = 0CAF1C76286F5C0E00296F86 /* Build configuration list for PBXNativeTarget "Torrenter" */; - buildPhases = ( - 0CAF1C64286F5C0E00296F86 /* Sources */, - 0CAF1C65286F5C0E00296F86 /* Frameworks */, - 0CAF1C66286F5C0E00296F86 /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = Torrenter; - productName = Torrenter; - productReference = 0CAF1C68286F5C0E00296F86 /* Torrenter.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 0CAF1C60286F5C0D00296F86 /* Project object */ = { - isa = PBXProject; - attributes = { - BuildIndependentTargetsInParallel = 1; - LastSwiftUpdateCheck = 1400; - LastUpgradeCheck = 1400; - TargetAttributes = { - 0CAF1C67286F5C0E00296F86 = { - CreatedOnToolsVersion = 14.0; - }; - }; - }; - buildConfigurationList = 0CAF1C63286F5C0D00296F86 /* Build configuration list for PBXProject "Torrenter" */; - compatibilityVersion = "Xcode 14.0"; - developmentRegion = en; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 0CAF1C5F286F5C0D00296F86; - productRefGroup = 0CAF1C69286F5C0E00296F86 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 0CAF1C67286F5C0E00296F86 /* Torrenter */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXResourcesBuildPhase section */ - 0CAF1C66286F5C0E00296F86 /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 0CAF1C73286F5C0E00296F86 /* Preview Assets.xcassets in Resources */, - 0CAF1C70286F5C0E00296F86 /* Assets.xcassets in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 0CAF1C64286F5C0E00296F86 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 0CAF1C6E286F5C0E00296F86 /* ContentView.swift in Sources */, - 0CAF1C6C286F5C0E00296F86 /* TorrenterApp.swift in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 0CAF1C74286F5C0E00296F86 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = dwarf; - ENABLE_STRICT_OBJC_MSGSEND = YES; - ENABLE_TESTABILITY = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_DYNAMIC_NO_PIC = NO; - GCC_NO_COMMON_BLOCKS = YES; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; - MTL_FAST_MATH = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - }; - name = Debug; - }; - 0CAF1C75286F5C0E00296F86 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_ANALYZER_NONNULL = YES; - CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++17"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_ENABLE_OBJC_WEAK = YES; - CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_COMMA = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_DOCUMENTATION_COMMENTS = YES; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INFINITE_RECURSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; - CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; - CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; - CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; - CLANG_WARN_STRICT_PROTOTYPES = YES; - CLANG_WARN_SUSPICIOUS_MOVE = YES; - CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu11; - GCC_NO_COMMON_BLOCKS = YES; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 16.0; - MTL_ENABLE_DEBUG_INFO = NO; - MTL_FAST_MATH = YES; - SDKROOT = iphoneos; - SWIFT_COMPILATION_MODE = wholemodule; - SWIFT_OPTIMIZATION_LEVEL = "-O"; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 0CAF1C77286F5C0E00296F86 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"Torrenter/Preview Content\""; - DEVELOPMENT_TEAM = 8A74DBQ6S3; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; - INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; - INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = me.kingbri.Torrenter; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Debug; - }; - 0CAF1C78286F5C0E00296F86 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; - CODE_SIGN_STYLE = Automatic; - CURRENT_PROJECT_VERSION = 1; - DEVELOPMENT_ASSET_PATHS = "\"Torrenter/Preview Content\""; - DEVELOPMENT_TEAM = 8A74DBQ6S3; - ENABLE_PREVIEWS = YES; - GENERATE_INFOPLIST_FILE = YES; - INFOPLIST_KEY_UIApplicationSceneManifest_Generation = YES; - INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; - INFOPLIST_KEY_UILaunchScreen_Generation = YES; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; - LD_RUNPATH_SEARCH_PATHS = ( - "$(inherited)", - "@executable_path/Frameworks", - ); - MARKETING_VERSION = 1.0; - PRODUCT_BUNDLE_IDENTIFIER = me.kingbri.Torrenter; - PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_EMIT_LOC_STRINGS = YES; - SWIFT_VERSION = 5.0; - TARGETED_DEVICE_FAMILY = "1,2"; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 0CAF1C63286F5C0D00296F86 /* Build configuration list for PBXProject "Torrenter" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 0CAF1C74286F5C0E00296F86 /* Debug */, - 0CAF1C75286F5C0E00296F86 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 0CAF1C76286F5C0E00296F86 /* Build configuration list for PBXNativeTarget "Torrenter" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 0CAF1C77286F5C0E00296F86 /* Debug */, - 0CAF1C78286F5C0E00296F86 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 0CAF1C60286F5C0D00296F86 /* Project object */; -} diff --git a/Torrenter.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/Torrenter.xcodeproj/project.xcworkspace/contents.xcworkspacedata deleted file mode 100644 index 919434a..0000000 --- a/Torrenter.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ /dev/null @@ -1,7 +0,0 @@ - - - - - diff --git a/Torrenter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Torrenter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist deleted file mode 100644 index 18d9810..0000000 --- a/Torrenter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +++ /dev/null @@ -1,8 +0,0 @@ - - - - - IDEDidComputeMac32BitWarning - - - diff --git a/Torrenter.xcodeproj/xcuserdata/kingbri.xcuserdatad/xcschemes/xcschememanagement.plist b/Torrenter.xcodeproj/xcuserdata/kingbri.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index e3f06c6..0000000 --- a/Torrenter.xcodeproj/xcuserdata/kingbri.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,14 +0,0 @@ - - - - - SchemeUserState - - Torrenter.xcscheme_^#shared#^_ - - orderHint - 0 - - - - diff --git a/Torrenter/ContentView.swift b/Torrenter/ContentView.swift deleted file mode 100644 index be62f75..0000000 --- a/Torrenter/ContentView.swift +++ /dev/null @@ -1,25 +0,0 @@ -// -// ContentView.swift -// Torrenter -// -// Created by Brian Dashore on 7/1/22. -// - -import SwiftUI - -struct ContentView: View { - var body: some View { - VStack { - Image(systemName: "globe") - .imageScale(.large) - .foregroundColor(.accentColor) - Text("Hello, world!") - } - } -} - -struct ContentView_Previews: PreviewProvider { - static var previews: some View { - ContentView() - } -} diff --git a/Torrenter/TorrenterApp.swift b/Torrenter/TorrenterApp.swift deleted file mode 100644 index ccbb136..0000000 --- a/Torrenter/TorrenterApp.swift +++ /dev/null @@ -1,17 +0,0 @@ -// -// TorrenterApp.swift -// Torrenter -// -// Created by Brian Dashore on 7/1/22. -// - -import SwiftUI - -@main -struct TorrenterApp: App { - var body: some Scene { - WindowGroup { - ContentView() - } - } -}