diff --git a/NativeYoutube.xcodeproj/project.pbxproj b/NativeYoutube.xcodeproj/project.pbxproj index 38e4400..bd55b53 100644 --- a/NativeYoutube.xcodeproj/project.pbxproj +++ b/NativeYoutube.xcodeproj/project.pbxproj @@ -16,11 +16,8 @@ 133DCE5227ADF16600AE6F1F /* GeneralPreferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133DCE5127ADF16600AE6F1F /* GeneralPreferenceView.swift */; }; 133DCE5627ADF29C00AE6F1F /* YoutubePreferenceView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 133DCE5527ADF29C00AE6F1F /* YoutubePreferenceView.swift */; }; 138F4D1427ACFCBC00DF099D /* NativeYoutubeApp.swift in Sources */ = {isa = PBXBuildFile; fileRef = 138F4D1327ACFCBC00DF099D /* NativeYoutubeApp.swift */; }; - 139EF52F27BAC7950031BF1D /* URL+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 139EF52E27BAC7950031BF1D /* URL+Extension.swift */; }; - 13E02D0C27ABD2FE00B4A648 /* String+Time.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13E02D0B27ABD2FE00B4A648 /* String+Time.swift */; }; 13FA3CF127AF820D005555C3 /* VideoRowView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13FA3CF027AF820C005555C3 /* VideoRowView.swift */; }; 13FA3CF327AF82B2005555C3 /* VideoListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13FA3CF227AF82B2005555C3 /* VideoListView.swift */; }; - 13FA3CF527AF8B6B005555C3 /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 13FA3CF427AF8B6B005555C3 /* Request.swift */; }; 70A3843C2955B35E000941F5 /* Enums.swift in Sources */ = {isa = PBXBuildFile; fileRef = 70A3843B2955B35E000941F5 /* Enums.swift */; }; 70A3843F2955D1A1000941F5 /* YouTubeKit in Frameworks */ = {isa = PBXBuildFile; productRef = 70A3843E2955D1A1000941F5 /* YouTubeKit */; }; 70A3844529561851000941F5 /* SDWebImageSwiftUI in Frameworks */ = {isa = PBXBuildFile; productRef = 70A3844429561851000941F5 /* SDWebImageSwiftUI */; }; @@ -29,7 +26,6 @@ C27DD350272C853E00B4DC16 /* ContentView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27DD34F272C853E00B4DC16 /* ContentView.swift */; }; C27DD352272C853F00B4DC16 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C27DD351272C853F00B4DC16 /* Assets.xcassets */; }; C27DD355272C853F00B4DC16 /* Preview Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C27DD354272C853F00B4DC16 /* Preview Assets.xcassets */; }; - C27DD373272C8A8900B4DC16 /* Collections+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27DD372272C8A8900B4DC16 /* Collections+Extension.swift */; }; C27DD37C272C8CCF00B4DC16 /* PlayListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27DD37B272C8CCF00B4DC16 /* PlayListView.swift */; }; C27DD384272C8D9D00B4DC16 /* YoutubePreferenceViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27DD383272C8D9D00B4DC16 /* YoutubePreferenceViewModel.swift */; }; C27DD386272C8DD100B4DC16 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = C27DD385272C8DD100B4DC16 /* Constants.swift */; }; @@ -62,7 +58,6 @@ 13E02D0B27ABD2FE00B4A648 /* String+Time.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Time.swift"; sourceTree = ""; }; 13FA3CF027AF820C005555C3 /* VideoRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRowView.swift; sourceTree = ""; }; 13FA3CF227AF82B2005555C3 /* VideoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoListView.swift; sourceTree = ""; }; - 13FA3CF427AF8B6B005555C3 /* Request.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = ""; }; 70A3843B2955B35E000941F5 /* Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Enums.swift; sourceTree = ""; }; 70A3845D295644A1000941F5 /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = System/Library/Frameworks/AVKit.framework; sourceTree = SDKROOT; }; C21B533C2956630500DDCAD8 /* ThinBackground.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ThinBackground.swift; sourceTree = ""; }; @@ -108,7 +103,6 @@ 131A386F27AF256D00B67A1B /* API */ = { isa = PBXGroup; children = ( - 13FA3CF427AF8B6B005555C3 /* Request.swift */, 131A387027AF258600B67A1B /* SearchRequest.swift */, 131A387227AF259000B67A1B /* PlaylistsRequest.swift */, ); @@ -356,7 +350,6 @@ C27DD39D272CA96700B4DC16 /* DateConverter.swift in Sources */, C27DD3AC272CBA5800B4DC16 /* NSViewRepresentable+Extension.swift in Sources */, 131A387127AF258600B67A1B /* SearchRequest.swift in Sources */, - 13FA3CF527AF8B6B005555C3 /* Request.swift in Sources */, 133DCE4D27ADED6300AE6F1F /* PreferencesView.swift in Sources */, 132F7F5D27AE244E00D0F607 /* KeyWindow.swift in Sources */, C27DD39B272CA54A00B4DC16 /* SearchViewModel.swift in Sources */, @@ -369,8 +362,6 @@ 13FA3CF327AF82B2005555C3 /* VideoListView.swift in Sources */, C27DD3B7272CE9DF00B4DC16 /* BottomBarView.swift in Sources */, C27DD350272C853E00B4DC16 /* ContentView.swift in Sources */, - C27DD373272C8A8900B4DC16 /* Collections+Extension.swift in Sources */, - 139EF52F27BAC7950031BF1D /* URL+Extension.swift in Sources */, C2A7FC29274D808D000D6D33 /* VideoContextMenuView.swift in Sources */, 138F4D1427ACFCBC00DF099D /* NativeYoutubeApp.swift in Sources */, C27DD386272C8DD100B4DC16 /* Constants.swift in Sources */, @@ -378,7 +369,6 @@ 131A387327AF259000B67A1B /* PlaylistsRequest.swift in Sources */, C27DD3B1272CBBD500B4DC16 /* LogPrefrenceView.swift in Sources */, C27DD384272C8D9D00B4DC16 /* YoutubePreferenceViewModel.swift in Sources */, - 13E02D0C27ABD2FE00B4A648 /* String+Time.swift in Sources */, 133DCE5627ADF29C00AE6F1F /* YoutubePreferenceView.swift in Sources */, 13FA3CF127AF820D005555C3 /* VideoRowView.swift in Sources */, 70A3843C2955B35E000941F5 /* Enums.swift in Sources */, diff --git a/NativeYoutube.xcodeproj/project.xcworkspace/xcuserdata/aayushpokharel.xcuserdatad/UserInterfaceState.xcuserstate b/NativeYoutube.xcodeproj/project.xcworkspace/xcuserdata/aayushpokharel.xcuserdatad/UserInterfaceState.xcuserstate index 2177a93..3ded283 100644 Binary files a/NativeYoutube.xcodeproj/project.xcworkspace/xcuserdata/aayushpokharel.xcuserdatad/UserInterfaceState.xcuserstate and b/NativeYoutube.xcodeproj/project.xcworkspace/xcuserdata/aayushpokharel.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/NativeYoutube/API/PlaylistsRequest.swift b/NativeYoutube/API/PlaylistsRequest.swift index b1ed134..2191b0d 100644 --- a/NativeYoutube/API/PlaylistsRequest.swift +++ b/NativeYoutube/API/PlaylistsRequest.swift @@ -8,7 +8,7 @@ import Foundation import SwiftyJSON -struct PlaylistsRequest: Request { +struct PlaylistsRequest { let apiKey: String let playListID: String let maxResults: String diff --git a/NativeYoutube/API/Request.swift b/NativeYoutube/API/Request.swift deleted file mode 100644 index 7894594..0000000 --- a/NativeYoutube/API/Request.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// Request.swift -// NativeYoutube -// -// Created by Erik Bautista on 2/5/22. -// - -import Foundation -import SwiftyJSON - -protocol Request { - associatedtype T - - func createURL() -> URL? - static func parseJSON(json: JSON) -> [T] -} diff --git a/NativeYoutube/API/SearchRequest.swift b/NativeYoutube/API/SearchRequest.swift index 860287a..63931ff 100644 --- a/NativeYoutube/API/SearchRequest.swift +++ b/NativeYoutube/API/SearchRequest.swift @@ -8,7 +8,7 @@ import Foundation import SwiftyJSON -struct SearchRequest: Request { +struct SearchRequest { let apiKey: String let query: String let maxResults: String diff --git a/NativeYoutube/Models/Constants.swift b/NativeYoutube/Models/Constants.swift index 8ef6da1..6bf034a 100644 --- a/NativeYoutube/Models/Constants.swift +++ b/NativeYoutube/Models/Constants.swift @@ -14,19 +14,6 @@ struct Constants { static let defaultPlaylistID: String = "PLFgquLnL59alKyN8i_z5Ofm_h0KthT072" } -enum StatusStates: String { - case starting = "Starting.." - case badOuath = "Incorrect Access Token" - case badClient = "Incorrect Client ID" - case badScopes = "BAD Scopes (Client ID / Access Token)" - case userValidating = "Validating User" - case userValidated = "User Validated" - case userLoading = "Loading User Data" - case userLoaded = "Got User Data" - case videoLoading = "Loading videos" - case videoLoaded = "View Has Been Loaded" -} - enum AppStorageStrings { static let apiKey = "Api Key" static let playListID = "Playlist ID for your goto playlist" diff --git a/NativeYoutube/Models/VideoModel.swift b/NativeYoutube/Models/VideoModel.swift index e99755a..6bda9a2 100644 --- a/NativeYoutube/Models/VideoModel.swift +++ b/NativeYoutube/Models/VideoModel.swift @@ -25,18 +25,6 @@ struct VideoModel { channelTitle: "OliviaRodrigoVEVO" ) - var cleanTitle: String { - var title = String(title.split(separator: "(")[0]) - - if title.split(separator: "-").count > 1 { - title = String(title.split(separator: "-")[1]) - } - if title.split(separator: ":").count > 1 { - title = String(title.split(separator: ":")[1]) - } - return title - } - enum VideoKind: String { case playlist = "youtube#playlistItem" case search = "youtube#searchResult" diff --git a/NativeYoutube/ViewModels/AppStateViewModel.swift b/NativeYoutube/ViewModels/AppStateViewModel.swift index 374acea..35a89e6 100644 --- a/NativeYoutube/ViewModels/AppStateViewModel.swift +++ b/NativeYoutube/ViewModels/AppStateViewModel.swift @@ -22,24 +22,6 @@ class AppStateViewModel: ObservableObject { @Published var isPlaying: Bool = false @Published var currentlyPlaying: String = "" - func changePlayListID(for playlistURL: String) -> Bool { - // Using regex would be 100% better (this is a quick and dirty method) - var changed = false - let splitted = playlistURL.split(separator: "&") - for splitted in splitted { - if splitted.contains("list") { - let id = splitted.split(separator: "=") - if let idCount = id.last?.count { - if idCount > 6 { - playListID = String(id.last!) - changed = true - } - } - } - } - return changed - } - func addToLogs(for page: Pages, message: String) { logs.append("Log at: \(Date()), from \(page.rawValue), message => \(message)") } @@ -64,7 +46,7 @@ class AppStateViewModel: ObservableObject { } func playVideoIINA(url: URL, title: String) { -// togglePlaying(title) + togglePlaying(title) Task { DispatchQueue.main.async { self.logs.append(self.shell("open -a iina '\(url)'")) diff --git a/NativeYoutube/Views/SearchView/SearchVideosView.swift b/NativeYoutube/Views/SearchView/SearchVideosView.swift index 969deaa..73df350 100644 --- a/NativeYoutube/Views/SearchView/SearchVideosView.swift +++ b/NativeYoutube/Views/SearchView/SearchVideosView.swift @@ -8,7 +8,6 @@ import SwiftUI struct SearchView: View { - @EnvironmentObject var appStateViewModel: AppStateViewModel @EnvironmentObject var searchViewModel: SearchViewModel var body: some View { @@ -38,6 +37,6 @@ struct SearchView: View { struct SearchView_Previews: PreviewProvider { static var previews: some View { SearchView() - .environmentObject(AppStateViewModel()) + .environmentObject(SearchViewModel()) } } diff --git a/NativeYoutube/Views/SharedViews/PopupPlayerView.swift b/NativeYoutube/Views/SharedViews/PopupPlayerView.swift index 63d4e31..ad616aa 100644 --- a/NativeYoutube/Views/SharedViews/PopupPlayerView.swift +++ b/NativeYoutube/Views/SharedViews/PopupPlayerView.swift @@ -8,10 +8,8 @@ import AVKit import SwiftUI import YouTubeKit -import YouTubePlayerKit struct PopupPlayerView: View { - // As view is displayed via a function, can't use EnvironnementObject -> Re-declaring useNativePlayer var in the view. @ObservedObject var appStateViewModel: AppStateViewModel let videoURL: URL @@ -47,7 +45,6 @@ struct PopupPlayerView: View { } } .task { - // We need to get the video's stream in async, so we set a task who runs when view appears to set the value of the player to the video stream. let video = YouTube(url: videoURL) do { let streams = try await video.streams diff --git a/NativeYoutube/Views/SharedViews/VideoListView.swift b/NativeYoutube/Views/SharedViews/VideoListView.swift index c07bfee..5621ffe 100644 --- a/NativeYoutube/Views/SharedViews/VideoListView.swift +++ b/NativeYoutube/Views/SharedViews/VideoListView.swift @@ -32,7 +32,6 @@ struct VideoListView: View { .contextMenu(ContextMenu(menuItems: { VideoContextMenuView(video: video) })) - // On double tap gesture, make the action according to user's preferences. .onTapGesture(count: 2) { switch appStateViewModel.vidClickBehaviour { case .nothing: @@ -47,8 +46,7 @@ struct VideoListView: View { } } } - .padding(.horizontal, 6) - .padding(.top, 6) + .padding(6) } } }