Created
October 28, 2015 04:21
-
-
Save naosim/bb74bbe5887fc27f9ae5 to your computer and use it in GitHub Desktop.
Androidアプリがリリースされたかをチェックするスクリプト
This file contains hidden or 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/env python | |
# -*- coding: utf-8 -*- | |
import urllib | |
import urllib2 | |
from urllib2 import Request, urlopen, URLError, HTTPError | |
import sys | |
# http request | |
def request(url, getParams={}, proxy=False): | |
if proxy != False: | |
# use proxy | |
urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler({'http': proxy, 'https': proxy}))) | |
return urllib2.urlopen(url, urllib.urlencode(getParams)) | |
def getArg(index, defaultValue): | |
argvs = sys.argv | |
argc = len(argvs) | |
if argc >= index + 1: | |
return argvs[index] | |
else: | |
return defaultValue | |
def getAppVersion(googlePlayHtmlSource): | |
a = googlePlayHtmlSource.split('<div class="content" itemprop="softwareVersion">')[1] | |
return a[0:a.find('</div>')].strip() | |
# main start | |
argc = len(sys.argv) | |
# description | |
if argc < 3: # argv not found | |
print "[usage]" | |
print "normal" | |
print " py release_check.py com.your.android.app.package v1.2.3" | |
print "with proxy" | |
print " py release_check.py com.hoge.yourapp v1.2.3 your.proxy.com:8080" | |
exit(1) | |
packageName = getArg(1, "") | |
appVersion = getArg(2, "") | |
proxy = getArg(3, False) | |
try: | |
res = request("https://play.google.com/store/apps/details", {'id':packageName}, proxy) | |
currentAppVersion = getAppVersion(res.read()) | |
if currentAppVersion == appVersion: | |
print "New App Released!!!!!!" | |
else: | |
exit("Not Updated") | |
except URLError, e: # 404 Not Found | |
exit("Not Released") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment