mirror of
https://github.com/simbelmas/gotify-dunst.git
synced 2026-01-19 14:35:23 +01:00
Merge pull request #4 from husixu1/master
Added User-Agent request header
This commit is contained in:
11
main.py
11
main.py
@@ -1,5 +1,5 @@
|
|||||||
import websocket
|
import websocket
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen, Request
|
||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import os.path
|
import os.path
|
||||||
@@ -37,12 +37,15 @@ def get_picture(appid):
|
|||||||
if os.path.isfile(path):
|
if os.path.isfile(path):
|
||||||
return imgPath
|
return imgPath
|
||||||
else:
|
else:
|
||||||
r = json.loads(urlopen("https://{}/application?token={}".format(domain, token)).read())
|
req = Request("https://{}/application?token={}".format(domain, token))
|
||||||
|
req.add_header("User-Agent", "Mozilla/5.0")
|
||||||
|
r = json.loads(urlopen(req).read())
|
||||||
for i in r:
|
for i in r:
|
||||||
if i['id'] == appid:
|
if i['id'] == appid:
|
||||||
with open(imgPath, "wb") as f:
|
with open(imgPath, "wb") as f:
|
||||||
url = urlopen("https://{}/{}?token={}".format(domain, i['image'], token))
|
req = Request("https://{}/{}?token={}".format(domain, i['image'], token))
|
||||||
f.write(url.read())
|
req.add_header("User-Agent", "Mozilla/5.0")
|
||||||
|
f.write(urlopen(req).read())
|
||||||
return imgPath
|
return imgPath
|
||||||
|
|
||||||
def send_notification(message):
|
def send_notification(message):
|
||||||
|
|||||||
Reference in New Issue
Block a user