Exemple #1
0
def main():
    root_path = os.path.dirname(os.path.realpath(sys.argv[0]))
    client = api.Client()
    username = input('请输入您的账号:')
    password = input('请输入您的密码:')
    cookies_file = os.path.join(root_path, username + ".cookies")
    # chapter_file = os.path.join(root_path, "captcha.png")
    # if client.login(username, password, chapter_file):
    # 直播接口无需验证码,弃用原有网页登陆接口
    if client.live_login(username, password):
        #存储cookies
        client.save_cookies(cookies_file)
        #存储username
        config_path = os.path.join(root_path, 'username.config')
        json_content = {"username": username}
        f = open(config_path, 'w')
        f.write(json.dumps(json_content))
        f.close()
        #提示语
        client.get_account_info()
        print('欢迎您:', client.userdata['uname'])
        print('登陆状态已储存,您现在可以使用其他功能脚本啦')
    else:
        sys.exit()
Exemple #2
0
def main():
    root_path = os.path.dirname(os.path.realpath(sys.argv[0]))
    cache_path = os.path.join(root_path, "app.json")
    config_path = os.path.join(root_path, "config.json")

    # read cache file
    try:
        f = open(cache_path, 'r', encoding='utf-8')
        content = f.read()
        f.close()
        cache_list = json.loads(content)
    except BaseException:
        print("read app.json error")
        return

    # token = ''
    # enable_notice = False
    # app_lost_notice = False
    # app_update_notice = False
    # app_price_change_notice = False
    # app_price_discount_notice = False

    # read config file
    try:
        f = open(config_path, 'r')
        content = f.read()
        f.close()
        config = json.loads(content)
        token = config['token']
        enable_notice = config['enable_notice']
        app_lost_notice = config['app_lost_notice']
        app_update_notice = config['app_update_notice']
        app_price_change_notice = config['app_price_change_notice']
        app_price_discount_notice = config['app_price_discount_notice']
    except BaseException:
        print('read config.json error')
        return

    client = api.Client()
    current_index = 0
    app_count = len(cache_list)

    for item in cache_list:
        has_change = False
        current_index += 1
        app_id = item['trackId']
        country = item['country']
        track_name = item['trackName']
        new_item = client.get_app_info(app_id, country)
        if new_item is None or len(new_item) == 0:
            # app lost in App Store
            if item['available']:
                item['available'] = False
                content = "{} 下架了".format(track_name)
                report_print(current_index, app_count, content)
                if enable_notice and app_lost_notice:
                    client.send_notice(token, 0, "APP 下架提示!", content)
        else:
            new_item['available'] = True
            new_item['country'] = item['country']

            if not item['available']:
                # app come back to App Store
                has_change = True
                item['available'] = True
                content = "【{}】 又上架了".format(track_name)
                report_print(current_index, app_count, content)
                if enable_notice and app_lost_notice:
                    client.send_notice(token, 0, "APP 上架提示!", content)

            if new_item['price'] != item['price']:
                # app price changed
                has_change = True
                content = "【{}】 从 {} -> {}".format(new_item['trackName'],
                                                   item['price'],
                                                   new_item['price'])
                report_print(current_index, app_count, content)
                if enable_notice:
                    if new_item['price'] < item['price']:
                        if app_price_discount_notice:
                            client.send_notice(token, 0, "APP 降价了!", content)
                    elif app_price_change_notice:
                        client.send_notice(token, 0, "APP 涨价了!", content)

            if new_item['version'] != item['version']:
                # app version changed
                has_change = True
                content = "【{}】 version changed {} -> {}".format(
                    new_item['trackName'], item['version'],
                    new_item['version'])
                report_print(current_index, app_count, content)
                if enable_notice and app_update_notice:
                    client.send_notice(token, 0, "APP version changed!",
                                       content)

            for key in item.keys():
                item[key] = new_item[key]

            if not has_change:
                content = "【{}】 没有变化".format(track_name)
                report_print(current_index, app_count, content)
            if current_index != app_count:
                time.sleep(2)

    content = json.dumps(cache_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False)
    f = open(cache_path, 'w', encoding='utf-8')
    f.write(content)
    f.close()
Exemple #3
0
import os
import re
import sys
import json
import shutil
import zipfile
import argparse
import platform

import api
import img2pdf
from tqdm import tqdm
from requests.exceptions import HTTPError
from api.exceptions import IneligibleError

client = api.Client()


def print_title():
    print("""
 _____ _____ _____ 
|     |  |  | __  |
| | | |  |  |    -|
|_|_|_|_____|__|__|
   """)


def get_os():
    if platform.system() == 'Windows':
        return True
    return False
Exemple #4
0
 def __init__(self):
     self.max_over_minute = 120
     self.data_dic = self._read_cache()
     self.api = api.Client()
     self.api.cookies_login()
Exemple #5
0
def main():
    root_path = os.path.dirname(os.path.realpath(sys.argv[0]))
    cache_path = os.path.join(root_path, "app.json")
    f = None
    try:
        f = open(cache_path, 'r', encoding='utf-8')
        cache_list = json.loads(f.read())
    except Exception as e:
        cache_list = []
    finally:
        if f:
            f.close()
    client = api.Client()
    print("America = us, China = cn, Japan = jp ...")
    print("-" * 60)
    country = input("please choose country: ")
    country = country.strip()
    while True:
        keywords = input("please input app name to search(exit): ")
        if keywords == "exit":
            break

        print("searching...")
        data = client.search_app(keywords, country, 10)
        if data is None or len(data) == 0:
            print("404 not found")
            continue
        print("-" * 60)
        format_str = "%-5s%-15s%-10s%-10s%-10s%s"
        print(format_str %
              ("", "APPID", "VERSION", "APPSIZE", "PRICE", "APPNAME"))
        for index, item in enumerate(data):
            size = int(item['fileSizeBytes']) / 1024 / 1024
            size_str = "%.2fMb" % size
            app_name = item['trackName']
            if len(app_name) > 20:
                app_name = app_name[:20] + "..."
            print(format_str % (str(index), item['trackId'], item['version'],
                                size_str, item['formattedPrice'], app_name))
        print("-" * 60)
        select = input("please select one to save(exit): ")
        if select == "exit":
            break
        try:
            select_index = int(select)
            select_item = data[select_index]
            save_data = {}
            save_data['trackName'] = select_item['trackName']
            save_data['trackId'] = select_item['trackId']
            save_data['version'] = select_item['version']
            save_data['price'] = select_item['price']
            save_data['available'] = True
            save_data['country'] = country
            cache_list.append(save_data)
            content = json.dumps(cache_list,
                                 indent=4,
                                 sort_keys=True,
                                 ensure_ascii=False)
            f = open(cache_path, 'w', encoding='utf-8')
            f.write(content)
            f.close()
            print(
                "{} save finished, you can run handler_app.py to handle app changes\n\n"
                .format(select_item['trackId']))
        except Exception as e:
            print("input error ", e)
            continue
Exemple #6
0
 def __init__(self, token, cache, update_cache=True):
     self._client = api.Client(token)
     self._cache = cache
     self._run_update_cache = update_cache
Exemple #7
0
 def __init__(self, token):
     self._client = api.Client(token)
Exemple #8
0
#!/usr/bin/env python3
import configparser
import api

# Configuration
conf = configparser.ConfigParser()
with open("config", "r") as f:
    conf.read_file(f)

URL = conf.get("testrail", "base_url")
project_id = conf.get("testrail", "project_id")
client = api.Client(URL,
                    project_id=project_id,
                    user=conf.get("testrail", "user"),
                    password=conf.get("testrail", "password"))

all_suites = client.get_suites()

print(all_suites)
Exemple #9
0
def main():
    root_path = os.path.dirname(os.path.realpath(sys.argv[0]))
    cache_path = os.path.join(root_path, "handler.json")
    config_path = os.path.join(root_path, "config.ini")
    # read cache file
    f = None
    try:
        f = open(cache_path, 'r', encoding='utf-8')
        content = f.read()
        f.close()
        cache_list = json.loads(content)
    except Exception as e:
        print("read handler.json error")
        return

    # read config file
    allow_email = False
    try:
        f = open(config_path, 'r')
        content = f.read()
        f.close()
        config = json.loads(content)
        sender = config['sender']
        password = config['password']
        receiver = config['receiver']
        app_lost_mail = config['app_lost_mail']
        app_update_mail = config['app_update_mail']
        app_cut_price_mail = config['app_cut_price_mail']
        mail_title = "App Store Reminder"
        regex = re.compile(
            r"\b[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}\b",
            re.IGNORECASE)
        if not re.match(regex, sender):
            raise Exception("'sender' is not a email address")
        if not re.match(regex, receiver):
            raise Exception("'receiver' is not a email address")
        allow_email = True
    except Exception as e:
        print('read config.ini error:', e)
        print('script will not send email for you.')

    client = api.Client()

    # test connect
    if allow_email and not client.test_email_connect(sender, password):
        sys.exit()

    has_change = False
    for item in cache_list:
        app_id = item['trackId']
        country = item['country']
        trackName = item['trackName']
        new_item = client.get_app_info(app_id, country)
        now_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
        if new_item == None or len(new_item) == 0:
            # app lost in appstore
            if item['available'] == True:
                item['available'] = False
                has_change = True
                content = "{} {} is not available in appstore any more".format(
                    now_time, trackName)
                print(content)
                if allow_email and app_lost_mail == True:
                    client.send_email(sender, password, receiver, mail_title,
                                      content)
        else:
            new_item['available'] = True
            new_item['country'] = item['country']

            if item['available'] == False:
                # app come back to appstore
                has_change = True
                content = "{} {} is come back to appstore".format(
                    now_time, trackName)
                print(content)
                if allow_email and app_lost_mail == True:
                    client.send_email(sender, password, receiver, mail_title,
                                      content)

            elif new_item['price'] != item['price']:
                # app price changed
                has_change = True
                content = "{} {} price changed {} -> {}".format(
                    now_time, new_item['trackName'], item['price'],
                    new_item['price'])
                print(content)
                if allow_email and app_cut_price_mail == True:
                    client.send_email(sender, password, receiver, mail_title,
                                      content)

            elif new_item['version'] != item['version']:
                # app version changed
                has_change = True
                content = "{} {} version changed {} -> {}".format(
                    now_time, new_item['trackName'], item['version'],
                    new_item['version'])
                print(content)
                if allow_email and app_update_mail == True:
                    client.send_email(sender, password, receiver, mail_title,
                                      content)

            for key in item.keys():
                item[key] = new_item[key]

            if not has_change:
                print(now_time, trackName, "no change")

    content = json.dumps(cache_list,
                         indent=4,
                         sort_keys=True,
                         ensure_ascii=False)
    f = open(cache_path, 'w', encoding='utf-8')
    f.write(content)
    f.close()