Skip to content

Commit

Permalink
RED DIFF woo!
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush9029 committed Dec 23, 2022
1 parent 2d13fb3 commit 3816c07
Show file tree
Hide file tree
Showing 11 changed files with 5 additions and 80 deletions.
10 changes: 0 additions & 10 deletions NativeYoutube.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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 */; };
Expand All @@ -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 */; };
Expand Down Expand Up @@ -62,7 +58,6 @@
13E02D0B27ABD2FE00B4A648 /* String+Time.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "String+Time.swift"; sourceTree = "<group>"; };
13FA3CF027AF820C005555C3 /* VideoRowView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoRowView.swift; sourceTree = "<group>"; };
13FA3CF227AF82B2005555C3 /* VideoListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VideoListView.swift; sourceTree = "<group>"; };
13FA3CF427AF8B6B005555C3 /* Request.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = "<group>"; };
70A3843B2955B35E000941F5 /* Enums.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Enums.swift; sourceTree = "<group>"; };
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 = "<group>"; };
Expand Down Expand Up @@ -108,7 +103,6 @@
131A386F27AF256D00B67A1B /* API */ = {
isa = PBXGroup;
children = (
13FA3CF427AF8B6B005555C3 /* Request.swift */,
131A387027AF258600B67A1B /* SearchRequest.swift */,
131A387227AF259000B67A1B /* PlaylistsRequest.swift */,
);
Expand Down Expand Up @@ -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 */,
Expand All @@ -369,16 +362,13 @@
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 */,
C27DD3AA272CB9FD00B4DC16 /* View+Extension.swift in Sources */,
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 */,
Expand Down
Binary file not shown.
2 changes: 1 addition & 1 deletion NativeYoutube/API/PlaylistsRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import SwiftyJSON

struct PlaylistsRequest: Request {
struct PlaylistsRequest {
let apiKey: String
let playListID: String
let maxResults: String
Expand Down
16 changes: 0 additions & 16 deletions NativeYoutube/API/Request.swift

This file was deleted.

2 changes: 1 addition & 1 deletion NativeYoutube/API/SearchRequest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import SwiftyJSON

struct SearchRequest: Request {
struct SearchRequest {
let apiKey: String
let query: String
let maxResults: String
Expand Down
13 changes: 0 additions & 13 deletions NativeYoutube/Models/Constants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
12 changes: 0 additions & 12 deletions NativeYoutube/Models/VideoModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 1 addition & 19 deletions NativeYoutube/ViewModels/AppStateViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)")
}
Expand All @@ -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)'"))
Expand Down
3 changes: 1 addition & 2 deletions NativeYoutube/Views/SearchView/SearchVideosView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import SwiftUI

struct SearchView: View {
@EnvironmentObject var appStateViewModel: AppStateViewModel
@EnvironmentObject var searchViewModel: SearchViewModel

var body: some View {
Expand Down Expand Up @@ -38,6 +37,6 @@ struct SearchView: View {
struct SearchView_Previews: PreviewProvider {
static var previews: some View {
SearchView()
.environmentObject(AppStateViewModel())
.environmentObject(SearchViewModel())
}
}
3 changes: 0 additions & 3 deletions NativeYoutube/Views/SharedViews/PopupPlayerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions NativeYoutube/Views/SharedViews/VideoListView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -47,8 +46,7 @@ struct VideoListView: View {
}
}
}
.padding(.horizontal, 6)
.padding(.top, 6)
.padding(6)
}
}
}
Expand Down

0 comments on commit 3816c07

Please sign in to comment.