Created
February 9, 2016 10:51
-
-
Save Self-Perfection/04cde81d183612da966b to your computer and use it in GitHub Desktop.
Check if new web release of MAPS.ME has been published
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/python2 | |
# Checker for new releases of MAPS.ME apk | |
# Author: Alexander Meshcheryakov | |
# Distributed under WTFPL | |
url = 'http://maps.me/apk/' | |
import os | |
cache_file_path = os.path.expanduser('~/.cache/mapsme_webreleases') | |
import urllib2 | |
request = urllib2.Request(url) | |
response = urllib2.urlopen(request) | |
data = response.read() | |
from lxml import html | |
html = html.fromstring(data) | |
current_releases = set([str(x) for x in html.xpath('//a/@href') if '.apk' in x]) | |
import cPickle as pickle | |
try: | |
old_releases = pickle.load(open(cache_file_path, 'r')) | |
except: | |
old_releases = set() | |
pickle.dump(current_releases, open(cache_file_path, 'w')) | |
new_releases = current_releases - old_releases | |
if len(new_releases) > 0: | |
# Your notification code goes here | |
print(new_releases) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment