Skip to content

Commit

Permalink
plugin.py: Update urllib
Browse files Browse the repository at this point in the history
  • Loading branch information
WanWizard committed Jul 23, 2022
1 parent f0acae8 commit 2c15101
Showing 1 changed file with 41 additions and 45 deletions.
86 changes: 41 additions & 45 deletions plugin/plugin.py
Expand Up @@ -8,14 +8,13 @@
import struct
import gettext
import datetime, time
import urllib2, urllib
import urllib
from Screens.Console import Console
from Components.Language import language
from Plugins.Plugin import PluginDescriptor
from Screens.Screen import Screen
from Components.MenuList import MenuList
from Screens.VirtualKeyBoard import VirtualKeyBoard
from urllib import urlretrieve
from Components.Label import Label
from Components.ScrollLabel import ScrollLabel
from Components.ActionMap import ActionMap, HelpableActionMap
Expand Down Expand Up @@ -174,11 +173,11 @@ def is_png(data):

def checkInternet():
try:
response = urllib2.urlopen("http://google.com", None, 5)
response = urllib.request.urlopen("http://google.com", None, 5)
response.close()
except urllib2.HTTPError:
except urllib.error.HTTPError:
return False
except urllib2.URLError:
except urllib.error.URLError:
return False
except socket.timeout:
return False
Expand Down Expand Up @@ -213,7 +212,7 @@ def getLocWeer(iscity = None):
print(mydata)
citynumb = int(mydata.split("-")[1])
print(citynumb)
response = urllib.urlopen("http://api.buienradar.nl/data/forecast/1.1/all/"+ str(citynumb))
response = urllib.request.urlopen("http://api.buienradar.nl/data/forecast/1.1/all/"+ str(citynumb))
antw = response.read()
global weatherData
weatherData = json.loads(antw)
Expand All @@ -229,7 +228,7 @@ def getLocWeer(iscity = None):
countycodenewy = snewy[1]
text = mydata.replace(' ', '%20')
print("cityname lookup", citynamenewy)
response = urllib.urlopen("https://location.buienradar.nl/1.1/location/search?query="+citynamenewy)
response = urllib.request.urlopen("https://location.buienradar.nl/1.1/location/search?query="+citynamenewy)
antw = response.read()
staddata = json.loads(antw)
entryselect = 0
Expand All @@ -242,7 +241,7 @@ def getLocWeer(iscity = None):
break
entrselect += 1
print("cipt id find", staddata[entryselect]["id"])
response = urllib.urlopen("https://forecast.buienradar.nl/2.0/forecast/"+str(staddata[entryselect]["id"]))
response = urllib.request.urlopen("https://forecast.buienradar.nl/2.0/forecast/"+str(staddata[entryselect]["id"]))
antw = response.read()
global weatherData
weatherData = json.loads(antw)
Expand All @@ -257,8 +256,8 @@ def getLocWeer(iscity = None):


def weatherchat(country):
req = urllib2.Request("http://www.buienradar."+country+"/weerbericht")
response = urllib2.urlopen(req)
req = urllib.request.Request("http://www.buienradar."+country+"/weerbericht")
response = urllib.request.urlopen(req)
antw = response.read()
antw = antw.replace("\t", "").replace("\r", "").replace("\n", "").replace("<strong>", "")
antw = antw.replace("<br />", "").replace("</strong>", "").replace("</a>", "")
Expand Down Expand Up @@ -345,7 +344,7 @@ def exit(self):
self.close()

def checkupg(self):
response = urllib2.urlopen("http://users.telenet.be/caught/version_hetweer.txt")
response = urllib.request.urlopen("http://users.telenet.be/caught/version_hetweer.txt")
curver = float(response.read())

if WeerInfoCurVer < curver:
Expand Down Expand Up @@ -958,7 +957,7 @@ class weatherMenuSub(Screen):
<widget name="key_red" position="185,643" size="220,28" zPosition="1" transparent="1" font="Regular;24" borderColor="black" borderWidth="1" halign="left"/>
</screen>"""

listNamesnl = [_("Rainfall radar"), _("Temperature"), _("Drizzle"), _("Thunder radar"), _("Clouds radar"), _("Mist radar"), _("Snow radar"), _("Sun radar"), _("Sunpower-UV"), _("Satellite"), _("Weather forecast-nl")]
listNamesnl = [_("Temperature"), _("Rainfall radar"), _("Drizzle"), _("Thunder radar"), _("Clouds radar"), _("Mist radar"), _("Snow radar"), _("Sun radar"), _("Sunpower-UV"), _("Satellite"), _("Weather forecast-nl")]
listNamesbe = [_("Rainfall radar"), _("Drizzle"), _("Thunder radar"), _("Clouds radar"), _("Hail radar"), _("Snow radar"), _("Sun radar"), _("Satellite"), _("Weather forecast-nl")]
listNameseu = [_("Rainfall radar"), _("Thunder radar"), _("Satellite"), _("Weather forecast-nl")]
def __init__(self, session):
Expand Down Expand Up @@ -1023,29 +1022,26 @@ def openScreenRadar():
if type == _("Weather forecast-nl"):
wchat = weatherchat("be/Belgie/weerbericht")
self.session.open(weathertalk)
elif type == _("Temperature"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/weathermapnl/?ext=png&l=2&hist=12&forc=1&step=0&type=temperatuur&w=550&h=512', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Rainfall radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/radarmapbe/?ext=png&l=2&hist=0&forc=20&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/radarmapbe/?ext=png&l=2&hist=0&forc=20&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Drizzle"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/drizzlemapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/drizzlemapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Clouds radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/cloudmapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/cloudmapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Sun radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/sunmapnl/?ext=png&l=2&hist=0&forc=30&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/sunmapnl/?ext=png&l=2&hist=0&forc=30&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Thunder radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/lightningnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/lightningnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Hail radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/hailnl/?ext=png&l=2&hist=10&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/hailnl/?ext=png&l=2&hist=10&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
elif type == _("Snow radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/snowmapnl/?ext=png&l=2&hist=100&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/snowmapnl/?ext=png&l=2&hist=100&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
elif type == _("Satellite"):
urllib.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/SatCombined?height=512&width=550&history=8&skip=0', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/SatCombined?height=512&width=550&history=8&skip=0', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Sunpower-UV"):
urllib.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/WeatherMapUVIndexNL?extension=png&l=2&hist=0&forc=10&step=0&width=550&height=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/WeatherMapUVIndexNL?extension=png&l=2&hist=0&forc=10&step=0&width=550&height=512', '/tmp/HetWeer/00.png')
legend = False
if not type == _("Weather forecast-nl"):
openScreenRadar()
Expand All @@ -1054,32 +1050,32 @@ def openScreenRadar():
if type == _("Weather forecast-nl"):
wchat = weatherchat("nl/Nederland/weerbericht")
self.session.open(weathertalk)
elif type == _("Rainfall radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/radarmapnl/?ext=png&l=2&hist=0&forc=20&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Temperature"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/weathermapnl/?ext=png&l=2&hist=12&forc=1&step=0&type=temperatuur&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/weathermapnl/?ext=png&l=2&hist=2&forc=1&step=20&type=temperatuur&w=550&h=512', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Rainfall radar"):
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/radarmapnl/?ext=png&l=2&hist=0&forc=20&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Drizzle"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/drizzlemapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/drizzlemapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Clouds radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/cloudmapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/cloudmapnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Snow radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/snowmapnl/?ext=png&l=2&hist=10&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.request.urlretrieve('http://api.buienradar.nl/image/1.0/snowmapnl/?ext=png&l=2&hist=10&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
elif type == _("Mist radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/weathermapnl/?type=zicht&ext=png&l=2&hist=2&forc=0&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/weathermapnl/?type=zicht&ext=png&l=2&hist=2&forc=0&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Sun radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/sunmapnl/?ext=png&l=2&hist=0&forc=30&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/sunmapnl/?ext=png&l=2&hist=0&forc=30&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Thunder radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/lightningnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/lightningnl/?ext=png&l=2&hist=30&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Hail radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/hailnl/?ext=png&l=2&hist=10&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/hailnl/?ext=png&l=2&hist=10&forc=1&step=0&w=550&h=512', '/tmp/HetWeer/00.png')
elif type == _("Satellite"):
urllib.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/SatCombined?height=512&width=550&history=8&skip=0', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/SatCombined?height=512&width=550&history=8&skip=0', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Sunpower-UV"):
urllib.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/WeatherMapUVIndexNL?extension=png&l=2&hist=0&forc=10&step=0&width=550&height=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/WeatherMapUVIndexNL?extension=png&l=2&hist=0&forc=10&step=0&width=550&height=512', '/tmp/HetWeer/00.png')
legend = False
if not type == _("Weather forecast-nl"):
openScreenRadar()
Expand All @@ -1089,14 +1085,14 @@ def openScreenRadar():
wchat = weatherchat("nl/wereldwijd/europa")
self.session.open(weathertalk)
elif type == _("Rainfall radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/radarmapeu/?ext=png&l=2&hist=0&forc=10&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/radarmapeu/?ext=png&l=2&hist=0&forc=10&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Thunder radar"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/radarcloudseu/?ext=png&l=2&hist=8&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/radarcloudseu/?ext=png&l=2&hist=8&forc=0&step=0&h=512&w=550', '/tmp/HetWeer/00.png')
elif type == _("Satellite"):
urllib.urlretrieve('http://api.buienradar.nl/image/1.0/satvisual2/?ext=png&l=2&hist=10&forc=1&step=0&type=eu&w=550&h=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('http://api.buienradar.nl/image/1.0/satvisual2/?ext=png&l=2&hist=10&forc=1&step=0&type=eu&w=550&h=512', '/tmp/HetWeer/00.png')
legend = False
elif type == _("Sunpower-UV"):
urllib.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/WeatherMapUVIndexNL?extension=png&l=2&hist=0&forc=10&step=0&width=550&height=512', '/tmp/HetWeer/00.png')
urllib.request.urlretrieve('https://image.buienradar.nl/2.0/image/sprite/WeatherMapUVIndexNL?extension=png&l=2&hist=0&forc=10&step=0&width=550&height=512', '/tmp/HetWeer/00.png')
legend = False
if not type == _("Weather forecast-nl"):
openScreenRadar()
Expand All @@ -1108,7 +1104,7 @@ def openScreenRadar():
dir = "/tmp/HetWeer/%02d.png" % (aantalfotos - (x + 1))
tt += tijdstap * 60
print(picturedownloadurl+ turl)
urllib.urlretrieve(picturedownloadurl + turl, dir)
urllib.request.urlretrieve(picturedownloadurl + turl, dir)

if os.path.exists('/tmp/HetWeer/00.png'):
try:
Expand Down Expand Up @@ -1476,14 +1472,14 @@ def main(session, **kwargs):
SavedLokaleWeer.append(location)
print("start-----------:" + str(SavedLokaleWeer))
try:
response = urllib2.urlopen("https://www.luxsat.be/hpengine/download_files/plugins/wallpapers/daa.php?data")
response = urllib.request.urlopen("https://www.luxsat.be/hpengine/download_files/plugins/wallpapers/daa.php?data")
ids = int(response.read())
with open('/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/background.txt', 'rb') as f:
data = f.read()
if not int(data) == ids:
urllib.urlretrieve('http://claudck193.193.axc.nl/wallpapers/daa.php', '/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/backgroundhd.png')
urllib.urlretrieve('http://claudck193.193.axc.nl/wallpapers/daa.php?small', '/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/background.png')
urllib.urlretrieve('http://claudck193.193.axc.nl/wallpapers/daa.php?data', '/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/background.txt')
urllib.request.urlretrieve('http://claudck193.193.axc.nl/wallpapers/daa.php', '/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/backgroundhd.png')
urllib.request.urlretrieve('http://claudck193.193.axc.nl/wallpapers/daa.php?small', '/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/background.png')
urllib.request.urlretrieve('http://claudck193.193.axc.nl/wallpapers/daa.php?data', '/usr/lib/enigma2/python/Plugins/Extensions/HetWeer/Images/background.txt')
except:
None
session.open(startScreen)
Expand Down

0 comments on commit 2c15101

Please sign in to comment.