Last active
June 12, 2022 14:13
-
-
Save JLuetzen/015f1fda87289a6b0633798f3b43ad06 to your computer and use it in GitHub Desktop.
2 Einzelne Webcams: Diese Seite gehört zur Homepage der WebcamWidgetsSylt: https://wwsylt.live. Ein iPhone Widget, das Bilder einzelner WebCams auf der wundervollen Nordseeinsel Sylt zeigt. Dies sind die WebCams im Hotel Rungholt und die Surfcam Sylt auf dem Hotel Miramar in Westerland. Was genau zu tun ist, steht ganz unten.
This file contains 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 characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: blue; icon-glyph: camera-retro; | |
// Cam URL: https://webtv.feratel.com/webtv/?design=v3v&cam=3150&c24=0 | |
// Preview Cam imgURL "https://cs3.wettercomassets.com/thumbnails/variants/5afdfcba9c6a4/16x9_player.jpg" | |
const camLocation = "Kampen Hotel Rungholt"; | |
const url = "http://webtv.feratel.com/webtv/?design=v4&cam=3150&pg=5EB12424-7C2D-428A-BEFF-0C9140CD772F"; | |
const imgUrl ="http://wtvpict.feratel.com/picture/37/3150.jpeg?design=noxdesign&dcsdesign=WTP_partner"; | |
const imgReq = await new Request(imgUrl); | |
const img = await imgReq.loadImage(); | |
let actualdate = new Date(); | |
let lastrefresh = new DateFormatter(); | |
lastrefresh.useShortDateStyle(); | |
lastrefresh.useShortTimeStyle(); | |
camSubtitle = lastrefresh.string(actualdate); | |
const logoImg = await getImage('WWS-Logo.png'); | |
if (config.runsInWidget) { | |
let widget = createWidget(img); | |
Script.setWidget(widget); | |
Script.complete(); | |
} else { | |
let widget = createWidget(img); | |
await widget.presentMedium(); | |
} | |
function createWidget(img) { | |
const widget = new ListWidget(); | |
sourceURL = "https://wwsylt.live"; | |
widget.backgroundColor = Color.black(); | |
widget.url = url; | |
widget.backgroundImage = img; | |
widget.setPadding(3,15,15,3) | |
const logoStack = widget.addStack() | |
logoStack.addSpacer() | |
const logoImageStack = logoStack.addStack() | |
logoImageStack.addSpacer() | |
const wimg = logoImageStack.addImage(logoImg) | |
wimg.imageSize = new Size(80, 80) | |
wimg.rightAlignImage() | |
widget.addStack | |
widget.addSpacer(); | |
const titleText = widget.addText(camLocation); | |
titleText.font = Font.boldSystemFont(12); | |
titleText.textColor = Color.white(); | |
titleText.shadowRadius = 3; | |
titleText.shadowColor = Color.black(); | |
widget.addSpacer(2); | |
const subtitleText = widget.addText(camSubtitle); | |
subtitleText.font = Font.systemFont(8); | |
subtitleText.textColor = Color.white(); | |
subtitleText.textOpacity = 0.8; | |
subtitleText.shadowRadius = 3; | |
subtitleText.shadowColor = Color.black(); | |
const sourceURLText = widget.addText(sourceURL); | |
sourceURLText.font = Font.systemFont(8); | |
sourceURLText.textColor = Color.white(); | |
sourceURLText.textOpacity = 0.8; | |
sourceURLText.shadowRadius = 3; | |
sourceURLText.shadowColor = Color.black(); | |
return widget | |
} | |
// get images from local filestore or download them once | |
async function getImage(image) { | |
let fm = FileManager.local() | |
let dir = fm.documentsDirectory() | |
let path = fm.joinPath(dir, image) | |
if (fm.fileExists(path)) { | |
return fm.readImage(path) | |
} else { | |
// download once | |
let logoUrl | |
switch (image) { | |
case 'WWS-Logo.png': | |
logoUrl = "https://wwsylt.live/images/WWS_Logo.png" | |
console.log("set URL: " + logoUrl); | |
break | |
default: | |
console.log(`Sorry, couldn't find ${image}.`); | |
} | |
console.log("passing URL: " + logoUrl); | |
let iconImage = await loadImage(logoUrl) | |
fm.writeImage(path, iconImage) | |
return iconImage | |
} | |
} | |
// helper function to download an image from a given url | |
async function loadImage(prvlogoUrl) { | |
console.log(`passed URL: ${prvlogoUrl}.`); | |
const req = new Request(prvlogoUrl) | |
return await req.loadImage() | |
} |
This file contains 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 characters
// Variables used by Scriptable. | |
// These must be at the very top of the file. Do not edit. | |
// icon-color: blue; icon-glyph: camera-retro; | |
// Cam URL https://surfcam-sylt.de | |
// Preview Cam imgURL "https://www.worldcam.pl/images/webcams/420x236/strand-sylt.jpg" | |
const camLocation = "Surfcam Sylt - Westerland"; | |
const url = "https://surfcam-sylt.de/"; | |
const imgUrl = "https://surfcam-sylt.de/preview.jpg"; | |
//"https://www.worldcam.pl/images/webcams/420x236/strand-sylt.jpg"; | |
const imgReq = await new Request(imgUrl); | |
const img = await imgReq.loadImage(); | |
const logoImg = await getImage('WWS-Logo.png'); | |
let actualdate = new Date(); | |
let lastrefresh = new DateFormatter(); | |
lastrefresh.useShortDateStyle(); | |
lastrefresh.useShortTimeStyle(); | |
camSubtitle = lastrefresh.string(actualdate); | |
if (config.runsInWidget) { | |
let widget = createWidget(img); | |
Script.setWidget(widget); | |
Script.complete(); | |
} else { | |
let widget = createWidget(img); | |
await widget.presentMedium(); | |
} | |
function createWidget(img) { | |
const widget = new ListWidget(); | |
sourceURL = "https://wwsylt.live"; | |
widget.backgroundColor = Color.black(); | |
widget.url = url; | |
widget.backgroundImage = img; | |
widget.setPadding(3,15,15,3) | |
const logoStack = widget.addStack() | |
logoStack.addSpacer() | |
const logoImageStack = logoStack.addStack() | |
logoImageStack.addSpacer() | |
const wimg = logoImageStack.addImage(logoImg) | |
wimg.imageSize = new Size(80, 80) | |
wimg.rightAlignImage() | |
widget.addStack | |
widget.addSpacer(); | |
const titleText = widget.addText(camLocation); | |
titleText.font = Font.boldSystemFont(12); | |
titleText.textColor = Color.white(); | |
titleText.shadowRadius = 3; | |
titleText.shadowColor = Color.black(); | |
widget.addSpacer(2); | |
const subtitleText = widget.addText(camSubtitle); | |
subtitleText.font = Font.systemFont(8); | |
subtitleText.textColor = Color.white(); | |
subtitleText.textOpacity = 0.8; | |
subtitleText.shadowRadius = 3; | |
subtitleText.shadowColor = Color.black(); | |
const sourceURLText = widget.addText(sourceURL); | |
sourceURLText.font = Font.systemFont(8); | |
sourceURLText.textColor = Color.white(); | |
sourceURLText.textOpacity = 0.8; | |
sourceURLText.shadowRadius = 3; | |
sourceURLText.shadowColor = Color.black(); | |
return widget | |
} | |
// get images from local filestore or download them once | |
async function getImage(image) { | |
let fm = FileManager.local() | |
let dir = fm.documentsDirectory() | |
let path = fm.joinPath(dir, image) | |
if (fm.fileExists(path)) { | |
return fm.readImage(path) | |
} else { | |
// download once | |
let logoUrl | |
switch (image) { | |
case 'WWS-Logo.png': | |
logoUrl = "https://wwsylt.live/images/WWS_Logo.png" | |
console.log("set URL: " + logoUrl); | |
break | |
default: | |
console.log(`Sorry, couldn't find ${image}.`); | |
} | |
console.log("passing URL: " + logoUrl); | |
let iconImage = await loadImage(logoUrl) | |
fm.writeImage(path, iconImage) | |
return iconImage | |
} | |
} | |
// helper function to download an image from a given url | |
async function loadImage(prvlogoUrl) { | |
console.log(`passed URL: ${prvlogoUrl}.`); | |
const req = new Request(prvlogoUrl) | |
return await req.loadImage() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2 einzelne WebCams auf Sylt
Diese Seite gehört zur Homepage der WebCamWidgetsSylt:
https://wwsylt.live
Die Scripts auf dieser Seite zeigen von 2 ausgewählten Locations die Bilder von WebCams auf der wundervollen Nordsee-Insel Sylt in Echtzeit direkt auf dem HomeScreen vom iPhone.
Das Script verwendet die App Scriptable
HowTo: (Einfach) (nach unten scrollen für die detaillierte Anleitung)
Auf dem iPhone:
Bitte Folgendes berücksichtigen:
Dieses und andere Widgets teilen:
Ihr wollt vielleicht die Links zu diesem und anderen Widgets teilen:
Auf YouTube:
Präsentation der Widgets
https://youtu.be/YtO87t9DvtA
Demo aller Widgets
https://youtu.be/En-h2LZYh1w
Demo Autozug / Sylt-Shuttle
https://youtu.be/okgi-ZKg_PY
Erklärung Script Laden am Beispiel Westerland Kurpromenade
https://youtu.be/tRHFpwIr_l0
Erklärung Widget Einrichten auf dem Homescreen am Beispiel Westerland Kurpromenade
https://youtu.be/LnrikIM3T0U
Erklärung Widget Einrichten auf dem Homescreen am Beispiel Autozug / Sylt-Shuttle
https://youtu.be/vTvw9BsSmVY
2,99 € für die Kaffeedose:
Die hier zur Verfügung gestellten Widgets sind kostenlos und "as-is".
Wenn sie Euch gefallen, würde ich mich freuen, wenn Ihr mir einen Kaffee ausgebt.
HowTo: (detaillierte Schritt für Schritt Anleitung)