Last active
February 18, 2018 15:40
-
-
Save 0xmilan/ef0c5f5f5d6055312dda05fe827756a3 to your computer and use it in GitHub Desktop.
Push notifier for new (private) messages on the PROHARDVER! forums (prohardver.hu)
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
#!/usr/bin/python | |
# -*- coding: utf8 -*- | |
import urllib2, json, subprocess, gzip | |
from time import sleep | |
from StringIO import StringIO | |
def parse(): | |
num = int(item["msgs"]) - item["read_msgs"] | |
if num > 0: | |
subprocess.call(["notify-send", item["title"] , str(num) + " új hozzászólás", "-t" , "5000"]) | |
opener = urllib2.build_opener() | |
opener.addheaders.append(('Cookie', 'identifier=CHANGE_ME')) | |
opener.addheaders.append(('Accept-Encoding', 'gzip')) | |
while True: | |
data = json.loads(gzip.GzipFile(fileobj=StringIO(opener.open("https://prohardver.hu/phws/favlms.json").read())).read()) | |
if int(data["prv"]) > 0: | |
subprocess.call(["notify-send", str(data["prv"]) + " új privát üzenet" , "-t" , "5000"]) | |
for item in data["fav"]["threads"]: | |
parse() | |
for item in data["lms"]: | |
parse() | |
sleep(60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment