Last active
June 27, 2023 12:53
-
-
Save dwd0tcom/00a7aa6d41f6f945d16171249a50a29d to your computer and use it in GitHub Desktop.
Revisions
-
dwd0tcom revised this gist
Feb 19, 2022 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,12 +5,12 @@ // Licence: Robert Koch-Institut (RKI), dl-de/by-2-0 // Vaccine API by @_ThisIsBenny_ // Version 1.3 // For updates check: // https://gist.github.com/dwd0tcom/00a7aa6d41f6f945d16171249a50a29d/ // Define URLs based on the corona.rki.de webpage const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/ArcGIS/rest/services/Covid19_hubv/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true`; const incidenceUrl = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,cases7_per_100k&geometry=${location.longitude.toFixed( 3 -
dwd0tcom revised this gist
Jan 20, 2022 . 1 changed file with 43 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,10 +1,14 @@ // Variables used by Scriptable. // These must be at the very top of the file. Do not edit. // icon-color: deep-gray; icon-glyph: syringe; // Licence: Robert Koch-Institut (RKI), dl-de/by-2-0 // Vaccine API by @_ThisIsBenny_ // Version 1.2 // For updates check: // https://gist.github.com/dwd0tcom/00a7aa6d41f6f945d16171249a50a29d/ // Define URLs based on the corona.rki.de webpage const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true`; const incidenceUrl = (location) => @@ -35,11 +39,14 @@ async function createWidget(items) { // fetch new cases const newCasesData = await getNewCasesData(); header = list.addText("🚨 Neuinfektionen".toUpperCase()); header.font = Font.mediumSystemFont(10); header.minimumScaleFactor = 0.9; label = list.addText("+" + newCasesData.value.toLocaleString()); label.font = Font.mediumSystemFont(24); label.minimumScaleFactor = 0.9; const country = list.addText(newCasesData.areaName); country.font = Font.mediumSystemFont(12); @@ -55,10 +62,22 @@ async function createWidget(items) { label = list.addText(incidenceData.value + ""); label.font = Font.mediumSystemFont(24); if (incidenceData.value >= 1000) { label.textColor = new Color('#6E1472'); } else if (incidenceData.value >= 500) { label.textColor = new Color('#C82B81'); } else if (incidenceData.value >= 250) { label.textColor = new Color('#8c0801'); } else if (incidenceData.value >= 100) { label.textColor = new Color('#cc0a00'); } else if (incidenceData.value >= 50) { label.textColor = new Color('#ff3d33'); } else if (incidenceData.value >= 25) { label.textColor = new Color('#f9af4d'); } else if (incidenceData.value >= 5) { label.textColor = new Color('#fcf39f') } else if (incidenceData.value >= 0) { label.textColor = new Color('#000000'); } const city = list.addText(incidenceData.areaName); @@ -76,26 +95,40 @@ async function createWidget(items) { // fetch new vaccines const number = await getVaccineData(); let amount = number.value.toLocaleString(); header = list.addText("💉 " + amount + " geimpfte"); header.font = Font.mediumSystemFont(8); header.textColor = Color.gray() return list; } async function getLocation() { try { if (args.widgetParameter) { const fixedCoordinates = args.widgetParameter.split(",").map(parseFloat); return { latitude: fixedCoordinates[0], longitude: fixedCoordinates[1] }; } else { Location.setAccuracyToThreeKilometers(); return await Location.current(); } } catch (e) { return null; } } // Get vaccine Status async function getVaccineData() { let data = await new Request(vaccineStatus).loadJSON(); const attr = data.vaccinated; return { value: attr, } } async function getNewCasesData() { @@ -136,17 +169,3 @@ async function getIncidenceData() { return null; } } -
dwd0tcom revised this gist
Dec 30, 2020 . 1 changed file with 17 additions and 24 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,9 @@ // Variables used by Scriptable. // These must be at the very top of the file. Do not edit. // icon-color: deep-gray; icon-glyph: magic; // Licence: Robert Koch-Institut (RKI), dl-de/by-2-0 // Vaccine API by @_ThisIsBenny_ // Define URLs based on the corona.rki.de webpage const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true`; @@ -14,6 +16,8 @@ const incidenceUrl = (location) => const incidenceUrlStates = "https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/Coronaf%E4lle_in_den_Bundesl%E4ndern/FeatureServer/0/query?where=1%3D1&outFields=cases7_bl_per_100k&returnGeometry=false&outSR=4326&f=json"; const vaccineStatus = "https://rki-vaccination-data.vercel.app/api"; // Initialize Widget let widget = await createWidget(); if (!config.runsInWidget) { @@ -71,9 +75,13 @@ async function createWidget(items) { list.addSpacer(); // fetch new vaccines const number = await getVaccineData(); console.log(number); let amount = number.value.toLocaleString(); console.log(amount); header = list.addText("💉 " + amount + " geimpfte"); header.font = Font.mediumSystemFont(10); header.textColor = Color.gray() @@ -82,27 +90,12 @@ async function createWidget(items) { } // Get vaccine Status async function getVaccineData() { let data = await new Request(vaccineStatus).loadJSON(); const attr = data.vaccinated; return { value: attr, }; } async function getNewCasesData() { -
dwd0tcom revised this gist
Dec 30, 2020 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,8 @@ // Variables used by Scriptable. // These must be at the very top of the file. Do not edit. // icon-color: deep-gray; icon-glyph: magic; // Licence: Robert Koch-Institut (RKI), dl-de/by-2-0 // Define URLs based on the corona.rki.de webpage const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true`; const incidenceUrl = (location) => @@ -34,7 +34,7 @@ async function createWidget(items) { header = list.addText("🦠 Neuinfektionen".toUpperCase()); header.font = Font.mediumSystemFont(10); label = list.addText("+" + newCasesData.value.toLocaleString()); label.font = Font.mediumSystemFont(24); const country = list.addText(newCasesData.areaName); -
dwd0tcom created this gist
Dec 29, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,159 @@ // Licence: Robert Koch-Institut (RKI), dl-de/by-2-0 //Vaccine Script by: https://gist.github.com/marco79cgn //Fork by https://gist.github.com/dwd0tcom // Define URLs based on the corona.rki.de webpage const newCasesApiUrl = `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_COVID19/FeatureServer/0/query?f=json&where=NeuerFall%20IN(1%2C%20-1)&returnGeometry=false&spatialRel=esriSpatialRelIntersects&outFields=*&outStatistics=%5B%7B%22statisticType%22%3A%22sum%22%2C%22onStatisticField%22%3A%22AnzahlFall%22%2C%22outStatisticFieldName%22%3A%22value%22%7D%5D&resultType=standard&cacheHint=true`; const incidenceUrl = (location) => `https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/RKI_Landkreisdaten/FeatureServer/0/query?where=1%3D1&outFields=GEN,cases7_per_100k&geometry=${location.longitude.toFixed( 3 )}%2C${location.latitude.toFixed( 3 )}&geometryType=esriGeometryPoint&inSR=4326&spatialRel=esriSpatialRelWithin&returnGeometry=false&outSR=4326&f=json`; const incidenceUrlStates = "https://services7.arcgis.com/mOBPykOjAyBO2ZKk/arcgis/rest/services/Coronaf%E4lle_in_den_Bundesl%E4ndern/FeatureServer/0/query?where=1%3D1&outFields=cases7_bl_per_100k&returnGeometry=false&outSR=4326&f=json"; // Initialize Widget let widget = await createWidget(); if (!config.runsInWidget) { await widget.presentSmall(); } Script.setWidget(widget); Script.complete(); // Build Widget async function createWidget(items) { const list = new ListWidget(); let header, label; // fetch new cases const newCasesData = await getNewCasesData(); header = list.addText("🦠 Neuinfektionen".toUpperCase()); header.font = Font.mediumSystemFont(10); label = list.addText("+" + newCasesData.value); label.font = Font.mediumSystemFont(24); const country = list.addText(newCasesData.areaName); country.font = Font.mediumSystemFont(12); country.textColor = Color.gray(); list.addSpacer(); // fetch new incidents const incidenceData = await getIncidenceData(); header = list.addText("🦠 Inzidenz".toUpperCase()); header.font = Font.mediumSystemFont(10); if (incidenceData) { label = list.addText(incidenceData.value + ""); label.font = Font.mediumSystemFont(24); if (incidenceData.value >= 50) { label.textColor = Color.red(); } else if (incidenceData.value >= 25) { label.textColor = Color.orange(); } const city = list.addText(incidenceData.areaName); city.font = Font.mediumSystemFont(12); city.textColor = Color.gray(); if (incidenceData.shouldCache) { list.refreshAfterDate = new Date(Date.now() + 60 * 60 * 1000); } } else { list.addText("Daten nicht verfügbar"); } list.addSpacer(); // fetch new vaccines const number = await getLatestNumber() let amount = number.split(" (")[0]; header = list.addText("💉 " + amount + "geimpfte"); header.font = Font.mediumSystemFont(10); header.textColor = Color.gray() return list; } // Get vaccine Status async function getLatestNumber() { let wbv = new WebView() await wbv.loadURL("https://www.rki.de/DE/Content/InfAZ/N/Neuartiges_Coronavirus/Daten/Impfquoten-Tab.html") // javasript to grab data from the website let jscript = ` result = ''; const metas = document.getElementsByTagName('meta'); for (let i = 0; i < metas.length; i++) { if (metas[i].getAttribute('name') === 'description') { result = metas[i].getAttribute('content'); } } JSON.stringify(result) ` // Run the javascript let result = await wbv.evaluateJavaScript(jscript) let substring = result.split("Gesamtzahl der Impfungen bis einschl. ")[1].split(": ")[1] result = substring.replace("\"", "") return result } async function getNewCasesData() { let data = await new Request(newCasesApiUrl).loadJSON(); const attr = data.features[0].attributes; return { value: attr.value, areaName: "Deutschland", shouldCache: false, }; } async function getIncidenceData() { try { const location = await getLocation(); if (location) { let data = await new Request(incidenceUrl(location)).loadJSON(); const attr = data.features[0].attributes; return { value: attr.cases7_per_100k.toFixed(1), areaName: attr.GEN, shouldCache: true, }; } else { let data = await new Request(incidenceUrlStates).loadJSON(); const incidencePerState = data.features.map( (f) => f.attributes.cases7_bl_per_100k ); const averageIncidence = incidencePerState.reduce((a, b) => a + b) / incidencePerState.length; return { value: averageIncidence.toFixed(1), areaName: "Deutschland", shouldCache: false, }; } } catch (e) { return null; } } async function getLocation() { try { if (args.widgetParameter) { const fixedCoordinates = args.widgetParameter.split(",").map(parseFloat); return { latitude: fixedCoordinates[0], longitude: fixedCoordinates[1] }; } else { Location.setAccuracyToThreeKilometers(); return await Location.current(); } } catch (e) { return null; } }