Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
iOS widget powered by the Scriptable app that shows the current capacity of McFit, John Reed, High5 and JOHN & JAME'S Gyms (RSG group)
/**
* Script for scriptable to get the current capacity of McFit, John Reed, High5 and JOHN & JAME'S Gyms
*/
let gymId = 1210252920
let param = args.widgetParameter
if (param != null && param.length > 0) {
gymId = param
}
const currentGymCapacity = await fetchGymCapacity(gymId)
const storeInfo = await fetchGymInfo(gymId)
const gymName = await fetchGymInfo(gymId)
const widget = new ListWidget()
await createWidget()
if (!config.runsInWidget) {
await widget.presentSmall()
}
Script.setWidget(widget)
Script.complete()
//Create the widget
async function createWidget() {
const headlineText = widget.addText("🏋️ Capacity")
headlineText.font = Font.mediumRoundedSystemFont(19)
widget.addSpacer()
const widgetStack = widget.addStack()
widgetStack.layoutVertically()
widgetStack.bottomAlignContent()
const capacityText = widgetStack.addText(currentGymCapacity.toString() + "%")
capacityText.font = Font.mediumRoundedSystemFont(50)
if (currentGymCapacity < 20) {
capacityText.textColor = new Color("#33cc33")
} else if (currentGymCapacity < 30){
capacityText.textColor = new Color("#ff9900")
}else{
capacityText.textColor = new Color("#ff3300")
}
widgetStack.addSpacer(1)
const gymNameText = widgetStack.addText(gymName)
gymNameText.font = Font.regularSystemFont(12)
}
//Fetches the current capacity of the John Reed gym
async function fetchGymCapacity(id) {
const url = 'https://typo3.johnreed.fitness/studiocapacity.json?studioId=' + id
const req = new Request(url)
const result = await req.loadJSON()
var counter = 0
for (var i in result.items) {
if(result.items[i].isCurrent){
counter = result.items[i].percentage
}
}
return counter
}
//Fetches the name of the gym
async function fetchGymInfo(id) {
const url = 'https://rsg-group.api.magicline.com/connect/v1/studio?studioTags=AKTIV-391B8025C1714FB9B15BB02F2F8AC0B2'
const req = new Request(url)
const apiResult = await req.loadJSON()
for (var i in apiResult){
if(apiResult[i].id == id)
{
return studioName = apiResult[i].studioName;
}
}
return 'Your Gym'
}
@eopo

This comment has been minimized.

Copy link
Owner Author

@eopo eopo commented Oct 23, 2020

Fork of https://gist.github.com/masselmello/6d4f4c533b98b2550ee23a7a5e6c6cff

image

How to use:

  1. You need to have Scriptable on your iOS 14 device and open it
  2. Tap on the plus in the upper right corner
  3. Tap on "Untitled Script" and give the script a name, for example "Gym Capacity"
  4. Copy the source code from above and paste it in the blank field
  5. Save it.
  6. Go to your home screen and enter wiggle mode. Then tap on the plus in the upper left corner.
  7. Select Scriptable from the promoted widgets, the app list or search for scriptable.
  8. Select your widget size. Since the John Reed Studio names are quite long, you might be better of with a 42 widget instead of a 22.
  9. Tap on "Add widget"
  10. Tap on the newly added widget.
  11. Select the John Reed script. On "When Interacting", you can select "Run Script", but it'll work just fine with "Open App"
  12. Paste your studio ID as parameter. You can see it in the table below.
    image
  13. Finished! 😍
Studio ID
High5 Berlin Mitte 2895769640
High5 Bremen-Altstadt 2934311450
High5 Düren 2932255110
High5 Fulda-Innenstadt 2917835990
High5 Hamburg - Hohenfelde 2935440040
High5 Kaiserslautern-Innenst. 2926023410
High5 Kleve 2933636030
High5 Linz-Innenstadt 2926788630
High5 Lübeck 2934770750
High5 Mainz-Neustadt 2920588880
High5 Wien-Simmering 2916934740
High5 Worms 2921886310
High5 Würzburg-Lengfeld 2917397480
JOHN & JANE'S POWERBASE 1211459930
JOHN & JANE'S SOULBASE 1210593380
JOHN REED Berlin Gesundbrunnen 1414770410
JOHN REED Berlin Kreuzberg 1414215390
JOHN REED Berlin Prenzlauer Berg 1404492860
JOHN REED Bonn 1613587690
JOHN REED Club Dresden 1642026390
JOHN REED Club Düsseldorf Bilk 1511018920
JOHN REED Club Essen Rüttenscheid 1210252920
JOHN REED Club Hamburg Harburg 1217496130
JOHN REED Club Hamburg Wandsbek 1246330520
JOHN REED Club Kiel Altstadt 1210250030
JOHN REED Club Mannheim 1210429940
JOHN REED Dortmund Gartenstadt 1897103860
JOHN REED Düsseldorf Friedrichstadt 1518062010
JOHN REED Erfurt 1897098610
JOHN REED Koblenz 1300470920
JOHN REED Leipzig 1584024160
JOHN REED Metropol Istanbul 3068946560
JOHN REED Moers 1332683490
JOHN REED Potsdam 1414810010
JOHN REED Salzburg 1721954170
JOHN REED Womens Club Prenzlauer Berg 1210025090
JOHN REED Wuppertal 1565411920
JOHN REED Zürich 1210592500
John Reed Augsburg 1211022120
John Reed Hannover 1211306330
John Reed Regensburg 1211588620
Linz Lenaupark 1210533690
McFIT Aachen 1536266890
McFIT Aachen-Nordost 1536269110
McFIT Aschaffenburg 1640035820
McFIT Augsburg-Göggingen 1832285310
McFIT Augsburg-Innenstadt 1832285460
McFIT Backnang 1731791930
McFIT Bamberg 1832287070
McFIT Bayreuth 1772000160
McFIT Bergisch Gladbach 1613589280
McFIT Berlin Alt-HSH 1367073160
McFIT Berlin Lichtenberg 1413742290
McFIT Berlin-Adlershof 1349612870
McFIT Berlin-Charlottenburg 1427956210
McFIT Berlin-Heinersdorf 1414048320
McFIT Berlin-Lichterfelde 1358621370
McFIT Berlin-Mahlsdorf 1349256200
McFIT Berlin-Marienfelde 1365913680
McFIT Berlin-Marzahn 1350226490
McFIT Berlin-Moabit 1387648020
McFIT Berlin-Neukölln 1378349880
McFIT Berlin-Niederschöneweide 1357900310
McFIT Berlin-Reinickendorf 1388329120
McFIT Berlin-Spandau West 1387327290
McFIT Berlin-Spandau 1378541720
McFIT Berlin-Tempelhof 1365485520
McFIT Berlin-Wedding 1401913170
McFIT Berlin-Wilmersdorf 1387456370
McFIT Bielefeld 1315301280
McFIT Bielefeld-Stieghorst 1318563820
McFIT Bochum-Grumme 1456553390
McFIT Bochum-Innenstadt 1470936540
McFIT Bochum-Wattenscheid 1456559430
McFIT Bonn-Zentrum 1632519320
McFIT Bottrop 1470930710
McFIT Braunschweig 1343005470
McFIT Bremen-Bahnhofsvorstadt 1444649250
McFIT Bremen-Kattenturm 1431982160
McFIT Bremen-Vahr 1432413020
McFIT Bremerhaven-Lehe 1341025840
McFIT Bruchsal 1799027410
McFIT Chemnitz 1897087250
McFIT Darmstadt 1653203780
McFIT Dinslaken 1332591200
McFIT Dortmund-Aplerbeck 1464428690
McFIT Dortmund-Mitte 1464398660
McFIT Dresden 1613967360
McFIT Dresden-Seidnitz 1877858840
McFIT Duisburg-Alt-Hamborn 1480580800
McFIT Duisburg-Wanheimerort 1470942300
McFIT Düsseldorf-Lierenfeld 1518062110
McFIT Erfurt 1897099150
McFIT Erlangen 1799038410
McFIT Essen-Bergerhausen 1487068340
McFIT Essen-Nordviertel 1486991540
McFIT Essen-Westviertel 1487084750
McFIT Flensburg 1259118100
McFIT Frankfurt Fechenheim 1641290300
McFIT Frankfurt Griesheim 1654413930
McFIT Frankfurt an der Oder 1358030660
McFIT Frankfurt-Innenstadt 1655280450
McFIT Freiburg 1731144220
McFIT Garbsen 1282764190
McFIT Gelsenkirchen 1518063990
McFIT Gera 1897099400
McFIT Gießen 1613588770
McFIT Gladbeck 1518063910
McFIT Graz-Center West 2919955190
McFIT Graz-Gries 1777567770
McFIT Gronau 1320817680
McFIT Göttingen 1431743730
McFIT Gütersloh 1536681400
McFIT Hagen 1471225620
McFIT Halle 1832285570
McFIT Hamburg Hamm 1227669060
McFIT Hamburg Langenhorn 1226210240
McFIT Hamburg Othmarschen 1243732290
McFIT Hamburg St. Georg 1238245210
McFIT Hamburg Steilshoop 1244533450
McFIT Hamburg Stellingen II 1222406050
McFIT Hamburg Stellingen 1217178980
McFIT Hanau 1674651890
McFIT Hannover Wülfel 1210249500
McFIT Hannover-Südstadt 1699737390
McFIT Hannover-Vahrenheide 1674653140
McFIT Heilbronn 1777724860
McFIT Herne 1536769810
McFIT Hildesheim 1301061690
McFIT Ingolstadt 1832288510
McFIT Innsbruck 1751344120
McFIT Iserlohn 2933215210
McFIT Kaiserslautern 1674650740
McFIT Kassel Nord 1858373350
McFIT Kassel 1858373180
McFIT Kiel 1266242250
McFIT Klagenfurt 1774825240
McFIT Krefeld 1537649930
McFIT Köln Bayenthal 1586570540
McFIT Köln-Altstadt 1587901620
McFIT Köln-Ehrenfeld 1587272080
McFIT Köln-Kalk 1585854790
McFIT Köln-Mülheim 1585313920
McFIT Köln-Sülz 1584024990
McFIT Leipzig Leutzsch 1549847800
McFIT Leipzig-Zentrum 1587593330
McFIT Leverkusen 1613589110
McFIT Ludwigshafen 1674650850
McFIT Lübeck 1265635050
McFIT Lüneburg 1261482430
McFIT Lünen 1326381890
McFIT Magdeburg 1307976090
McFIT Magdeburg-Altstadt 1308098500
McFIT Mainz 1699735990
McFIT Mannheim-Almenhof 1674652050
McFIT Mannheim-Käfertal 1674652490
McFIT Marburg 1300281990
McFIT Mönchengladbach-Pesch 1501356000
McFIT Mülheim 1487134350
McFIT München-Forstenried 1858377100
McFIT München-Laim 1882151370
McFIT München-Obergiesing 1879795550
McFIT München-Schwabing 1858374200
McFIT Münster 1447805280
McFIT Neu-Ulm 1777569150
McFIT Neumünster 1265095530
McFIT Neunkirchen 1699736310
McFIT Neuss 1518063160
McFIT Neuwied 1655147880
McFIT Nürnberg-Doos 1816185180
McFIT Nürnberg-Gibitzenhof 1805981150
McFIT Nürnberg-Gostenhof 1799035060
McFIT Nürnberg-Mögeldorf 1799173150
McFIT Oberhausen 1493810330
McFIT Oberhausen-Altstadt 1495802570
McFIT Offenbach 1674652800
McFIT Oldenburg 1286387060
McFIT Osnabrück 1320982950
McFIT Paderborn 1538574470
McFIT Pforzheim 1699736490
McFIT Ratingen 1501355840
McFIT Recklinghausen 1456341620
McFIT Regensburg-Reinhausen 1832288610
McFIT Remscheid 1518063650
McFIT Reutlingen 1777569990
McFIT Rheine 1326024770
McFIT Rosenheim 3119807980
McFIT Rostock 1261222410
McFIT Saarbrücken 1699736940
McFIT Salzgitter 1315044800
McFIT Schweinfurt 1777569060
McFIT Schwerin 1214245660
McFIT Siegen 1287088900
McFIT Sindelfingen 1731068920
McFIT Soest 1324491280
McFIT Solingen 1333102490
McFIT Solingen-Mitte 1300538400
McFIT Stuttgart-Feuerbach 1731333930
McFIT Stuttgart-Mitte 1731421430
McFIT Stuttgart-Mühlhausen 1699736840
McFIT Trier 1613591080
McFIT Tübingen 1731766900
McFIT Velbert 1330877890
McFIT Wien Jägerstraße 1210430420
McFIT Wien-Donaustadt 1869778900
McFIT Wien-Favoriten 1832290370
McFIT Wien-Floridsdorf 1808922310
McFIT Wien-Leopoldstadt 1812014550
McFIT Wien-Lugnercity 1876562160
McFIT Wien-Meidling 1751351510
McFIT Wien-Neubau 1832288950
McFIT Wien-Wienerberg 1897103300
McFIT Wiesbaden 1724102500
McFIT Wilhelmshaven 1282502730
McFIT Witten 1470853850
McFIT Wolfsburg 1341260900
McFIT Wuppertal-Barmen 1501358190
McFIT Wuppertal-Elberfeld 1511016690
McFIT Würzburg 1790336890
McFIT Zwickau 1897099900
McFit Hamm 1455779710
@twobeer

This comment has been minimized.

Copy link

@twobeer twobeer commented Oct 24, 2020

Moin!
Gibt es auch für das Fitnessstudio Elan eine solche Auslastungsgrenze? Kannst Du da mal nachschauen? https://elan-fitness.de/

Vielen Dank!

@eopo

This comment has been minimized.

Copy link
Owner Author

@eopo eopo commented Oct 24, 2020

Moin!
Gibt es auch für das Fitnessstudio Elan eine solche Auslastungsgrenze? Kannst Du da mal nachschauen? https://elan-fitness.de/

Vielen Dank!

Nein. Ich kann nur die Daten verarbeiten, die das Fitnessstudio selbst schon irgendwo bereitstellt. Da Elan auf seiner Website keine solche Daten hat, kann ich sie auch nicht auswerten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment