Skip to content

Commit

Permalink
fixing #25
Browse files Browse the repository at this point in the history
  • Loading branch information
Aayush9029 committed Apr 18, 2022
1 parent b112594 commit 2d32e7b
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 9 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key>NativeTwitch.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>1</integer>
</dict>
<key>Playground (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>2</integer>
</dict>
<key>Playground (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>3</integer>
</dict>
<key>Playground (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
8 changes: 5 additions & 3 deletions NativeTwitch/Model/Stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ struct Stream: Hashable {
var game_name: String
var title: String
var user_logo: String?
var user_login: String // using this instead of username (fixes Chinise character issue)

func getStreamURL() -> URL {
if let url = URL(string: "https://www.twitch.tv/\(user_name)") {
if let url = URL(string: "https://www.twitch.tv/\(user_login)") {
return url
}
return URL(string: "https://www.twitch.tv")!
}

func getChatURL() -> URL {
if let url = URL(string: "https://www.twitch.tv/popout/\(user_name)/chat") {
if let url = URL(string: "https://www.twitch.tv/popout/\(user_login)/chat") {
return url
}
return getStreamURL()
Expand All @@ -37,6 +38,7 @@ struct Stream: Hashable {
type: "live",
game_name: "Grand Theft Auto V",
title: "[Nopixel] RIDEALONG PIERRE PP PAUL RIDS LOS SANTOS OF ALL THE CRIMINAL SCUM",
user_logo: "https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png"
user_logo: "https://cdn.pixabay.com/photo/2015/10/05/22/37/blank-profile-picture-973460_960_720.png",
user_login: "xqcow"
)
}
2 changes: 1 addition & 1 deletion NativeTwitch/View Model/TwitchDataViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class TwitchDataViewModel: ObservableObject {
for (_, subJson):(String, JSON) in json["data"] {
let d = subJson

self.streams.append(Stream(user_name: d["user_name"].string!, user_id: d["user_id"].string!, viewer_count: d["viewer_count"].int!, type: d["type"].string!, game_name: d["game_name"].string!, title: d["title"].string!))
self.streams.append(Stream(user_name: d["user_name"].string!, user_id: d["user_id"].string!, viewer_count: d["viewer_count"].int!, type: d["type"].string!, game_name: d["game_name"].string!, title: d["title"].string!, user_login: d["user_login"].string ?? "Unknown"))

}
self.status = .streamLoaded
Expand Down
10 changes: 5 additions & 5 deletions NativeTwitch/View/StreamsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,22 @@ struct StreamsView: View {
StreamRowView(stream: stream, const: Constants(twitchClientID: twitchClientID, oauthToken: oauthToken, streamlinkLocation: streamlinkLocation, streamlinkConfig: streamlinkConfig))
.environmentObject(twitchData)
.onTapGesture(count: 2, perform: {
twitchData.watchStream(stream.user_name)
twitchData.watchStream(stream.user_login)
})
.contextMenu(ContextMenu(menuItems: {
VStack {
Button("Play \(twitchData.iinaEnabled ? "using iina" : "")") {
twitchData.watchStream(stream.user_name)
twitchData.watchStream(stream.user_login)
}
if twitchData.experimental {
Button("Play (low latency)") {
twitchData.watchLowLatencyWithVLC(stream.user_name)
twitchData.watchLowLatencyWithVLC(stream.user_login)
}

Divider()

Button("Open chat in Native Chat") {
openURL(URL(string: "nativechat://\(stream.user_name)")!) { accepted in
openURL(URL(string: "nativechat://\(stream.user_login)")!) { accepted in
DispatchQueue.main.sync {
twitchData.isShowingNativeChatAlert = !accepted
}
Expand All @@ -57,7 +57,7 @@ struct StreamsView: View {

Divider()

Button("Open twitch.tv/\(stream.user_name)") {
Button("Open twitch.tv/\(stream.user_login)") {
NSWorkspace.shared.open(stream.getStreamURL())
}
}
Expand Down

0 comments on commit 2d32e7b

Please sign in to comment.