Skip to content

Commit

Permalink
Merge pull request #507 from TwilCynder/feature/load-stream-queue
Browse files Browse the repository at this point in the history
Fix and improvement for the stream queue
  • Loading branch information
joaorb64 authored Jul 25, 2023
2 parents 00e7fee + 0adae14 commit 04df4b1
Show file tree
Hide file tree
Showing 14 changed files with 183 additions and 161 deletions.
Binary file modified TSH.exe
Binary file not shown.
18 changes: 14 additions & 4 deletions layout/stream_queue/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LoadEverything().then(() => {
"sets_displayed" : -1,
"display_first_set": true,
"station" : -1,
"currentEventOnly": false,
"display" : {
"station" : false,
"country_flag" : true,
Expand Down Expand Up @@ -87,7 +88,7 @@ LoadEverything().then(() => {
`
)

resolver.add(`.set${s} .p${t} .twitter`,
resolver.add(`.set${s - 1} .p${t} .twitter`,
(!isTeams) ? `<span class="twitter_logo"></span>${String(player.twitter)}` : ""
)

Expand All @@ -103,9 +104,17 @@ LoadEverything().then(() => {
<div class = "name">
<div class = "tag"></div>
<div class = "extra">
<div class = "twitter"> </div>
<div class = "pronoun"> ${ wrap_text((!isTeams && true) ? String(player.pronoun) : "") } </div>
<div class = "seed"> ${wrap_text("Seed " + team.seed)} </div>
${ player.twitter ?
` <div class = "twitter"> </div> ` : ''
}
${ player.pronoun ?
` <div class = "pronoun"> ${ wrap_text((!isTeams && true) ? String(player.pronoun) : "") } </div>` : ''
}
${ team.seed ?
`<div class = "seed"> ${wrap_text("Seed " + team.seed)} </div> ` : ''
}
</div>
</div>
</div>
Expand All @@ -118,6 +127,7 @@ LoadEverything().then(() => {
for (const [s, set] of Object.values(queue).slice(first_index).entries()){
if (sets_nb && (current_set_nb >= sets_nb)) break;

if (config.currentEventOnly && !set.isCurrentEvent) continue;
if (config.station != -1 && config.station != set.station) continue;

let isTeams = Object.keys(set.team["1"].player).length > 1;
Expand Down
1 change: 1 addition & 0 deletions layout/stream_queue/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"sets_displayed" : -1,
"display_first_set": true,
"station" : -1,
"currentEventOnly": true,
"display" : {
"station" : false,
"country_flag" : true,
Expand Down
33 changes: 20 additions & 13 deletions src/TournamentDataProvider/StartGGDataProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,7 @@ def GetStreamQueue(self, progress_callback=None):
data = json.loads(data.text)
print("Stream queue loaded from StartGG")

eventSlug = deep_get(data, "data.event.slug", "")
queues = deep_get(data, "data.event.tournament.streamQueue", [])

finalData = {}
Expand All @@ -897,13 +898,16 @@ def GetStreamQueue(self, progress_callback=None):
streamName = q.get("stream", {}).get("streamName", "")
queueData = {}
for setIndex, _set in enumerate(q.get("sets", [])):


phase_name = deep_get(_set, "phaseGroup.phase.name")
if deep_get(_set, "phaseGroup.phase.groupCount") > 1:
phase_name += " - " + TSHLocaleHelper.phaseNames.get(
"group").format(deep_get(_set, "phaseGroup.displayIdentifier"))

frt = _set.get("fullRoundText", "")
total_games = _set.get("totalGames", 0)
seteventSlug = deep_get(_set, "event.slug", "")

setData = {
"id": _set.get("id"),
Expand All @@ -913,7 +917,9 @@ def GetStreamQueue(self, progress_callback=None):
"best_of_text": TSHLocaleHelper.matchNames.get("best_of").format(total_games) if total_games > 0 else "",
"state": _set.get("state"),
"team": {},
"station": deep_get(_set, "station.number", -1)
"station": deep_get(_set, "station.number", -1),
"event": seteventSlug,
"isCurrentEvent": seteventSlug == eventSlug
}

for teamIndex, slot in enumerate(_set.get("slots", [])):
Expand Down Expand Up @@ -945,18 +951,19 @@ def GetStreamQueue(self, progress_callback=None):
stateCode = playerData.get("state_code", "")
countryData = TSHCountryHelper.countries.get(
countryCode)
states = countryData.get("states")
stateData = {}
if stateCode:
stateData = states[stateCode]

path = f'./assets/state_flag/{countryCode}/{"_CON" if stateCode == "CON" else stateCode}.png'
if not os.path.exists(path):
path = None

stateData.update({
"asset": path
})
if countryData:
states = countryData.get("states")
stateData = {}
if stateCode:
stateData = states[stateCode]

path = f'./assets/state_flag/{countryCode}/{"_CON" if stateCode == "CON" else stateCode}.png'
if not os.path.exists(path):
path = None

stateData.update({
"asset": path
})

playerData = {
"country": TSHCountryHelper.GetBasicCountryInfo(countryCode),
Expand Down
4 changes: 4 additions & 0 deletions src/TournamentDataProvider/StartGGStreamQueueQuery.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
query StreamQueueQuery($slug: String) {
event(slug: $slug){
slug
tournament {
streamQueue {
sets {
Expand All @@ -11,6 +12,9 @@ query StreamQueueQuery($slug: String) {
station {
number
}
event {
slug
}
slots {
entrant {
id
Expand Down
32 changes: 16 additions & 16 deletions src/i18n/TSH_de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@ p, li { white-space: pre-wrap; }
<context>
<name>Form</name>
<message>
<location filename="../layout/TSHScoreboardTeam.ui" line="20"/>
<location filename="../layout/TSHScoreboardScore.ui" line="21"/>
<location filename="../layout/TSHThumbnailSettings.ui" line="14"/>
<location filename="../layout/TSHScoreboardPlayer.ui" line="25"/>
<location filename="../layout/TSHScoreboardStage.ui" line="14"/>
<location filename="../layout/TSHThumbnailSettings.ui" line="14"/>
<location filename="../layout/TSHScoreboardTeam.ui" line="20"/>
<source>Form</source>
<translation></translation>
</message>
Expand Down Expand Up @@ -622,14 +622,14 @@ p, li { white-space: pre-wrap; }
<context>
<name>GroupBox</name>
<message>
<location filename="../layout/TSHCommentary.ui" line="23"/>
<location filename="../layout/TSHCommentator.ui" line="29"/>
<location filename="../layout/TSHCommentary.ui" line="23"/>
<source>GroupBox</source>
<translation></translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="26"/>
<location filename="../layout/TSHCommentator.ui" line="32"/>
<location filename="../layout/TSHCommentary.ui" line="26"/>
<source>Commentator 1</source>
<translation>Kommentator 1</translation>
</message>
Expand All @@ -644,38 +644,38 @@ p, li { white-space: pre-wrap; }
<translation></translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="90"/>
<location filename="../layout/TSHCommentator.ui" line="90"/>
<location filename="../layout/TSHCommentary.ui" line="90"/>
<source>GamerTag</source>
<translation>Spielername</translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="108"/>
<location filename="../layout/TSHCommentator.ui" line="108"/>
<location filename="../layout/TSHCommentary.ui" line="108"/>
<source>REAL NAME</source>
<translation>KLARNAME</translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="124"/>
<location filename="../layout/TSHCommentator.ui" line="124"/>
<location filename="../layout/TSHCommentary.ui" line="124"/>
<source>Real Name</source>
<translation>Klarname</translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="140"/>
<location filename="../layout/TSHCommentator.ui" line="140"/>
<location filename="../layout/TSHCommentary.ui" line="140"/>
<source>TWITTER</source>
<translation></translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="156"/>
<location filename="../layout/TSHCommentator.ui" line="156"/>
<location filename="../layout/TSHCommentary.ui" line="156"/>
<source>Handle Only</source>
<translation>Handle exkl. @</translation>
</message>
<message>
<location filename="../layout/TSHCommentary.ui" line="170"/>
<location filename="../layout/TSHCommentator.ui" line="172"/>
<location filename="../layout/TSHCommentary.ui" line="170"/>
<source>PRONOUNS</source>
<translation>PRONOMEN</translation>
</message>
Expand Down Expand Up @@ -708,21 +708,21 @@ p, li { white-space: pre-wrap; }
<translation>Spielerliste</translation>
</message>
<message>
<location filename="../TSHPlayerListWidget.py" line="54"/>
<location filename="../TSHBracketWidget.py" line="70"/>
<location filename="../TSHPlayerListWidget.py" line="54"/>
<source>Number of slots</source>
<translation>Zahl der Slots</translation>
</message>
<message>
<location filename="../TSHPlayerListWidget.py" line="63"/>
<location filename="../TSHBracketWidget.py" line="81"/>
<location filename="../TSHPlayerListWidget.py" line="63"/>
<source>Players per slot</source>
<translation>Spieler pro Slot</translation>
</message>
<message>
<location filename="../TSHBracketWidget.py" line="90"/>
<location filename="../TSHScoreboardWidget.py" line="116"/>
<location filename="../TSHPlayerListWidget.py" line="72"/>
<location filename="../TSHBracketWidget.py" line="90"/>
<source>Characters per player</source>
<translation>Charaktere pro Slot</translation>
</message>
Expand Down Expand Up @@ -773,8 +773,8 @@ p, li { white-space: pre-wrap; }
<translation>Das Programm wird nun geschlossen.</translation>
</message>
<message>
<location filename="../TSHThumbnailSettingsWidget.py" line="74"/>
<location filename="../TournamentStreamHelper.py" line="233"/>
<location filename="../TSHThumbnailSettingsWidget.py" line="74"/>
<source>Thumbnail Settings</source>
<translation>Thumbnail-Einstellungen</translation>
</message>
Expand Down Expand Up @@ -1245,12 +1245,12 @@ p, li { white-space: pre-wrap; }
<translation>TEAM {0}</translation>
</message>
<message>
<location filename="../TSHThumbnailSettingsWidget.py" line="929"/>
<location filename="../TournamentStreamHelper.py" line="59"/>
<location filename="../TournamentStreamHelper.py" line="95"/>
<location filename="../TournamentStreamHelper.py" line="496"/>
<location filename="../TournamentStreamHelper.py" line="683"/>
<location filename="../TSHScoreboardWidget.py" line="459"/>
<location filename="../TSHThumbnailSettingsWidget.py" line="929"/>
<source>Warning</source>
<translation>ACHTUNG</translation>
</message>
Expand Down Expand Up @@ -1454,8 +1454,8 @@ p, li { white-space: pre-wrap; }
<context>
<name>thumb_app</name>
<message>
<location filename="../TSHThumbnailSettingsWidget.py" line="927"/>
<location filename="../TSHScoreboardWidget.py" line="435"/>
<location filename="../TSHThumbnailSettingsWidget.py" line="927"/>
<source>TSH - Thumbnail</source>
<translation></translation>
</message>
Expand Down
Loading

0 comments on commit 04df4b1

Please sign in to comment.