Rename API
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
/* Begin PBXBuildFile section */
|
||||
3F49E946216B86150047B0FE /* Match.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F49E945216B86150047B0FE /* Match.swift */; };
|
||||
3F49E948216B862B0047B0FE /* StatusBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F49E947216B862B0047B0FE /* StatusBarController.swift */; };
|
||||
3F49E94A216BE87B0047B0FE /* MatchesAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F49E949216BE87B0047B0FE /* MatchesAPI.swift */; };
|
||||
3F49E94A216BE87B0047B0FE /* LiquipediaMatchesAPI.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F49E949216BE87B0047B0FE /* LiquipediaMatchesAPI.swift */; };
|
||||
3F50154321DBD37200AC9639 /* LiquipediaMenuTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F50154221DBD37200AC9639 /* LiquipediaMenuTests.swift */; };
|
||||
3F50154B21DBD43E00AC9639 /* MatchesAPITests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F50154A21DBD43E00AC9639 /* MatchesAPITests.swift */; };
|
||||
3F563E07216E640D00AA3C06 /* MatchView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3F563E06216E640D00AA3C06 /* MatchView.swift */; };
|
||||
@@ -35,7 +35,7 @@
|
||||
37CBB27C5544ABC18BCC3124 /* Pods_LiquipediaMenu.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_LiquipediaMenu.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3F49E945216B86150047B0FE /* Match.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Match.swift; sourceTree = "<group>"; };
|
||||
3F49E947216B862B0047B0FE /* StatusBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusBarController.swift; sourceTree = "<group>"; };
|
||||
3F49E949216BE87B0047B0FE /* MatchesAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatchesAPI.swift; sourceTree = "<group>"; };
|
||||
3F49E949216BE87B0047B0FE /* LiquipediaMatchesAPI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiquipediaMatchesAPI.swift; sourceTree = "<group>"; };
|
||||
3F50154021DBD37100AC9639 /* LiquipediaMenuTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = LiquipediaMenuTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
3F50154221DBD37200AC9639 /* LiquipediaMenuTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LiquipediaMenuTests.swift; sourceTree = "<group>"; };
|
||||
3F50154421DBD37200AC9639 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
@@ -113,7 +113,7 @@
|
||||
children = (
|
||||
3FB6BB47216B8594000BF5AA /* AppDelegate.swift */,
|
||||
3F49E947216B862B0047B0FE /* StatusBarController.swift */,
|
||||
3F49E949216BE87B0047B0FE /* MatchesAPI.swift */,
|
||||
3F49E949216BE87B0047B0FE /* LiquipediaMatchesAPI.swift */,
|
||||
3F49E945216B86150047B0FE /* Match.swift */,
|
||||
3FF66CDE21DE80BA005A93D0 /* MatchMenuItem.swift */,
|
||||
3F563E06216E640D00AA3C06 /* MatchView.swift */,
|
||||
@@ -293,7 +293,7 @@
|
||||
3F563E07216E640D00AA3C06 /* MatchView.swift in Sources */,
|
||||
3F49E948216B862B0047B0FE /* StatusBarController.swift in Sources */,
|
||||
3FF66CDF21DE80BA005A93D0 /* MatchMenuItem.swift in Sources */,
|
||||
3F49E94A216BE87B0047B0FE /* MatchesAPI.swift in Sources */,
|
||||
3F49E94A216BE87B0047B0FE /* LiquipediaMatchesAPI.swift in Sources */,
|
||||
3F49E946216B86150047B0FE /* Match.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import Foundation
|
||||
import SwiftSoup
|
||||
|
||||
class MatchesAPI {
|
||||
class LiquipediaMatchesAPI {
|
||||
|
||||
func fetchMatches(for game: String) -> [Match]? {
|
||||
let games = ["dota2", "starcraft", "starcraft2", "heroes", "counterstrike", "rocketleague", "rainbowsix", "overwatch"]
|
||||
@@ -47,8 +47,13 @@ class MatchesAPI {
|
||||
|
||||
let newMatch = Match()
|
||||
newMatch.ongoing = true
|
||||
// TODO: Handle what happens when there is no twitch page. Currently it just opens Twicht main page.
|
||||
newMatch.streamLink = try "https://twitch.tv/" + match.getElementsByClass("timer-object").attr("data-stream-twitch")
|
||||
|
||||
// Tries to extract the stream link. If there is none, the string streamLink will be empty.
|
||||
// TODO: data-stream-twitch doesn't always contain the twitch user, so it can't always be used to go to the twitch site.
|
||||
print(try match.getAllElements().toString())
|
||||
print(try match.getElementsByClass("timer-object-countdown"))
|
||||
newMatch.streamLink = try match.getElementsByClass("timer-object-countdown").select("span").attr("href")
|
||||
|
||||
newMatch.league = try match.select("tr > td > div > div > a").text()
|
||||
newMatch.team1name = try match.getElementsByClass("team-left").text()
|
||||
newMatch.team1score = leftscore
|
||||
@@ -16,7 +16,7 @@ class StatusBarController: NSObject, NSMenuItemValidation {
|
||||
|
||||
let statusBar = NSMenu()
|
||||
let statusBarItem = NSStatusBar.system.statusItem(withLength: NSStatusItem.variableLength)
|
||||
let matchesAPI = MatchesAPI()
|
||||
let matchesAPI = LiquipediaMatchesAPI()
|
||||
var matches = [Match]()
|
||||
|
||||
override func awakeFromNib() {
|
||||
@@ -54,7 +54,7 @@ class StatusBarController: NSObject, NSMenuItemValidation {
|
||||
}
|
||||
}
|
||||
|
||||
if let matches = self.matchesAPI.fetchMatches(for: "dota2") {
|
||||
if let matches = self.matchesAPI.fetchMatches(for: "counterstrike") {
|
||||
for match in matches {
|
||||
let newItem = MatchMenuItem.init(for: match, action: #selector(self.openStreamLink))
|
||||
newItem.tag = 1
|
||||
|
||||
Reference in New Issue
Block a user