├── MANIFEST.in ├── requirements.txt ├── genshinhelper ├── __version__.py ├── config.py ├── locale │ ├── zh │ │ └── LC_MESSAGES │ │ │ ├── genshinhelper.mo │ │ │ └── genshinhelper.po │ ├── en │ │ └── LC_MESSAGES │ │ │ └── genshinhelper.po │ └── genshinhelper.pot ├── cloudgenshin.py ├── exceptions.py ├── __init__.py ├── __main__.py ├── jfsc.py ├── hoyolab.py ├── weibo.py ├── core.py ├── utils.py └── mihoyo.py ├── README.md ├── .gitignore ├── update_i18n.sh ├── setup.py └── LICENSE /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include LICENSE 2 | include *.md 3 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | requests 2 | beautifulsoup4 3 | -------------------------------------------------------------------------------- /genshinhelper/__version__.py: -------------------------------------------------------------------------------- 1 | __version__ = '2.1.3' 2 | -------------------------------------------------------------------------------- /genshinhelper/config.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | LANGUAGE = os.environ['LANGUAGE'] if os.environ.get('LANGUAGE') else 'en' 4 | 5 | -------------------------------------------------------------------------------- /genshinhelper/locale/zh/LC_MESSAGES/genshinhelper.mo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/y1ndan/genshinhelper2/HEAD/genshinhelper/locale/zh/LC_MESSAGES/genshinhelper.mo -------------------------------------------------------------------------------- /genshinhelper/cloudgenshin.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | from .utils import request 9 | 10 | 11 | def get_cloudgenshin_free_time(headers): 12 | url = 'https://api-cloudgame.mihoyo.com/hk4e_cg_cn/wallet/wallet/get' 13 | return request('get', url, headers=headers).json() 14 | -------------------------------------------------------------------------------- /genshinhelper/exceptions.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | from .utils import log 9 | 10 | 11 | class GenshinHelperException(Exception): 12 | """Base genshinhelper exception.""" 13 | 14 | def __init__(self, message): 15 | super().__init__(message) 16 | log.error(message) 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # genshinhelper 2 | 3 | A Python library for miHoYo bbs and HoYoLAB Community. 4 | 5 | ## Installation 6 | 7 | Via pip: 8 | 9 | ``` 10 | pip install genshinhelper 11 | ``` 12 | 13 | Or via source code: 14 | 15 | ``` 16 | git clone https://github.com/y1ndan/genshinhelper2.git 17 | cd genshinhelper2 18 | python setup.py install 19 | ``` 20 | 21 | ## Basic Usage 22 | 23 | ```python 24 | import genshinhelper as gh 25 | 26 | cookie = 'account_id=16393939; cookie_token=jPjdK4yd7oeIifkdYhkFhkkjde00hdUgh' 27 | g = gh.Genshin(cookie) 28 | roles = g.roles_info 29 | print(roles) 30 | ``` 31 | 32 | -------------------------------------------------------------------------------- /genshinhelper/__init__.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | from .__version__ import __version__ 9 | from .cloudgenshin import get_cloudgenshin_free_time 10 | from .hoyolab import ( 11 | Genshin, 12 | StarRail 13 | ) 14 | from .mihoyo import ( 15 | YuanShen, 16 | Honkai3rd, 17 | MysDailyMissions, 18 | ) 19 | from .jfsc import check_jfsc, sign_jfsc 20 | from .utils import ( 21 | request, 22 | today, 23 | month, 24 | get_mihoyo_app_cookie, 25 | set_lang, 26 | ) 27 | from .weibo import Weibo 28 | -------------------------------------------------------------------------------- /genshinhelper/__main__.py: -------------------------------------------------------------------------------- 1 | """genshinhelper entry point. 2 | 3 | Using `python ` or `python -m ` command. 4 | """ 5 | 6 | if not __package__: 7 | import os 8 | import sys 9 | 10 | sys.path.append(os.path.dirname(os.path.dirname(__file__))) 11 | 12 | from .utils import get_mihoyo_app_cookie, log, _ 13 | 14 | 15 | def main(cookie): 16 | app_cookie = get_mihoyo_app_cookie(cookie) 17 | return app_cookie 18 | 19 | 20 | if __name__ == "__main__": 21 | log.info(_('Converting cookie to mihoyo app cookie.')) 22 | raw_cookie = input(_('Please enter your cookie, similar to `account_id=xxxxxx; login_ticket=xxxxxx`: ')) 23 | main(raw_cookie) 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.py[cod] 2 | 3 | # C extensions 4 | *.so 5 | 6 | # Packages 7 | config.json 8 | *.egg 9 | *.egg-info 10 | dist 11 | build 12 | eggs 13 | parts 14 | bin 15 | var 16 | sdist 17 | develop-eggs 18 | .installed.cfg 19 | lib 20 | lib64 21 | __pycache__ 22 | 23 | # Installer logs 24 | pip-log.txt 25 | 26 | # Unit tmp / coverage reports 27 | .coverage 28 | .tox 29 | nosetests.xml 30 | .pytest_cache 31 | .python-version 32 | 33 | # Translations 34 | *.mo 35 | 36 | # Mr Developer 37 | .mr.developer.cfg 38 | .project 39 | .pydevproject 40 | 41 | # temp file 42 | .DS_Store 43 | *.pkl 44 | 45 | # Environments 46 | .env 47 | .venv 48 | env/ 49 | venv/ 50 | ENV/ 51 | env.bak/ 52 | venv.bak/ 53 | 54 | # Cookiecutter 55 | output/ 56 | 57 | # vscode 58 | .vscode 59 | 60 | # notebooks 61 | notebooks/ 62 | 63 | # idea 64 | .idea 65 | -------------------------------------------------------------------------------- /genshinhelper/jfsc.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | from .utils import request 9 | 10 | headers = { 11 | 'User-Agent': 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 MicroMessenger/8.0.1(0x1800012a) NetType/4G Language/zh_CN' 12 | } 13 | 14 | 15 | def check_jfsc(token): 16 | url = 'http://ysjfsc.mihoyo.com/api/SignIn/checkSign' 17 | payload = {'token': token} 18 | response = request('get', url, headers=headers, params=payload).json() 19 | return True if response.get('is_sign') else False 20 | 21 | 22 | def sign_jfsc(token): 23 | url = 'http://ysjfsc.mihoyo.com/api/SignIn/sign' 24 | payload = {'token': token} 25 | return request('post', url, headers=headers, data=payload).json() 26 | -------------------------------------------------------------------------------- /update_i18n.sh: -------------------------------------------------------------------------------- 1 | # Script for updating all the .po files, and .mo files 2 | # This keeps locales for docker and the module separate 3 | 4 | function update_or_copy() { 5 | locales=$1 6 | for lang in $locales/*; do 7 | if [[ -d $lang ]]; then 8 | po_file=$lang/LC_MESSAGES/genshinhelper.po 9 | mo_file=$lang/LC_MESSAGES/genshinhelper.mo 10 | if [[ -f $po_file ]]; then 11 | # If the po file already exists, merge it 12 | msgmerge --update $po_file $locales/genshinhelper.pot 13 | else 14 | # Else copy the template file 15 | cp $locales/genshinhelper.pot $po_file 16 | fi 17 | msgfmt -o $mo_file $po_file 18 | fi 19 | done 20 | } 21 | 22 | # mkdir -p locale genshinhelper/locale 23 | mkdir -p genshinhelper/locale 24 | # xgettext -o locale/genshinhelper.pot *.py --from-code=UTF-8 25 | # xgettext -o genshinhelper/locale/genshinhelper.pot genshinhelper/*.py genshinhelper/*/*.py --from-code=UTF-8 26 | xgettext -o genshinhelper/locale/genshinhelper.pot genshinhelper/*.py --from-code=UTF-8 27 | 28 | # update_or_copy "locale" 29 | update_or_copy "genshinhelper/locale" 30 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | from pathlib import Path 3 | 4 | from setuptools import find_packages, setup 5 | 6 | long_description = Path('README.md').read_text(encoding='utf-8') 7 | 8 | 9 | def load_requirements(filename): 10 | with Path(filename).open() as f: 11 | return [line.strip() for line in f if not line.startswith('#')] 12 | 13 | 14 | def create_mo_files(): 15 | data_files = [] 16 | locale_dir = Path('genshinhelper/locale') 17 | po_dirs = [lang / 'LC_MESSAGES' for lang in locale_dir.iterdir() if lang.is_dir()] 18 | for dir in po_dirs: 19 | mo_files = [] 20 | po_files = [file for file in dir.iterdir() if file.suffix == '.po'] 21 | for po_file in po_files: 22 | mo_file = po_file.with_suffix('.mo') 23 | msgfmt_cmd = ['msgfmt', po_file, '-o', mo_file] 24 | subprocess.run(msgfmt_cmd) 25 | mo_files.append(str(mo_file)) 26 | data_files.append((str(dir), mo_files)) 27 | return data_files 28 | 29 | 30 | __version__ = None 31 | with open('genshinhelper/__version__.py', encoding='utf-8') as f: 32 | exec(f.read()) 33 | 34 | if not __version__: 35 | print('Could not find __version__ from genshinhelper/__version__.py') 36 | exit(-1) 37 | 38 | setup( 39 | name='genshinhelper', 40 | version=__version__, 41 | packages=find_packages(), 42 | url='https://github.com/y1ndan/genshinhelper2', 43 | license='GPLv3', 44 | author='y1ndan', 45 | author_email='i@yindan.me', 46 | description='A Python library for miHoYo bbs and HoYoLAB Community.', 47 | long_description=long_description, 48 | long_description_content_type='text/markdown', 49 | keywords='原神 签到 mihoyo hoyolab genshin genshin-impact check-in weibo', 50 | include_package_data=True, 51 | data_files=create_mo_files(), 52 | install_requires=load_requirements('requirements.txt'), 53 | tests_require=['pytest'], 54 | classifiers=[ 55 | # As from https://pypi.python.org/pypi?%3Aaction=list_classifiers 56 | # 'Development Status :: 1 - Planning', 57 | # 'Development Status :: 2 - Pre-Alpha', 58 | # 'Development Status :: 3 - Alpha', 59 | # 'Development Status :: 4 - Beta', 60 | 'Development Status :: 5 - Production/Stable', 61 | # 'Development Status :: 6 - Mature', 62 | # 'Development Status :: 7 - Inactive', 63 | 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', 64 | 'Operating System :: OS Independent', 65 | 'Programming Language :: Python', 66 | # 'Programming Language :: Python :: 2', 67 | # 'Programming Language :: Python :: 2.3', 68 | # 'Programming Language :: Python :: 2.4', 69 | # 'Programming Language :: Python :: 2.5', 70 | # 'Programming Language :: Python :: 2.6', 71 | # 'Programming Language :: Python :: 2.7', 72 | # 'Programming Language :: Python :: 3', 73 | # 'Programming Language :: Python :: 3.0', 74 | # 'Programming Language :: Python :: 3.1', 75 | # 'Programming Language :: Python :: 3.2', 76 | # 'Programming Language :: Python :: 3.3', 77 | # 'Programming Language :: Python :: 3.4', 78 | # 'Programming Language :: Python :: 3.5', 79 | 'Programming Language :: Python :: 3.6', 80 | 'Programming Language :: Python :: 3.7', 81 | 'Programming Language :: Python :: 3.8', 82 | 'Programming Language :: Python :: 3.9', 83 | 'Intended Audience :: Developers', 84 | 'Intended Audience :: System Administrators', 85 | 'Topic :: System :: Systems Administration', 86 | ], 87 | entry_points={ 88 | 'console_scripts': [ 89 | 'genshinhelper=genshinhelper.__main__:main' 90 | ] 91 | }, 92 | python_requires='>=3.6', 93 | ) 94 | -------------------------------------------------------------------------------- /genshinhelper/locale/en/LC_MESSAGES/genshinhelper.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2021-11-01 14:07+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: genshinhelper/core.py:53 21 | msgid "Preparing to get user game roles information ..." 22 | msgstr "" 23 | 24 | #: genshinhelper/core.py:75 genshinhelper/mihoyo.py:130 25 | msgid "Preparing to get monthly rewards information ..." 26 | msgstr "" 27 | 28 | #: genshinhelper/core.py:115 29 | msgid "Preparing to claim daily reward ..." 30 | msgstr "" 31 | 32 | #: genshinhelper/core.py:119 33 | msgid "👀 You have already checked-in" 34 | msgstr "" 35 | 36 | #: genshinhelper/hoyolab.py:41 genshinhelper/mihoyo.py:45 37 | msgid "Preparing to get check-in information ..." 38 | msgstr "" 39 | 40 | #: genshinhelper/hoyolab.py:61 genshinhelper/mihoyo.py:61 41 | msgid "Preparing to get traveler's dairy ..." 42 | msgstr "" 43 | 44 | #: genshinhelper/__main__.py:21 45 | msgid "Converting cookie to mihoyo app cookie." 46 | msgstr "" 47 | 48 | #: genshinhelper/__main__.py:22 49 | msgid "" 50 | "Please enter your cookie, similar to `account_id=xxxxxx; " 51 | "login_ticket=xxxxxx`: " 52 | msgstr "" 53 | 54 | #: genshinhelper/mihoyo.py:84 55 | msgid "Preparing to get Yuan Shen daily note ..." 56 | msgstr "" 57 | 58 | #: genshinhelper/mihoyo.py:150 59 | msgid "Preparing to get Honkai 3rd finance ..." 60 | msgstr "" 61 | 62 | #: genshinhelper/mihoyo.py:201 63 | msgid "Preparing to get user missions state ..." 64 | msgstr "" 65 | 66 | #: genshinhelper/mihoyo.py:224 67 | msgid "Preparing to check-in for {} ..." 68 | msgstr "" 69 | 70 | #: genshinhelper/mihoyo.py:238 71 | msgid "Preparing to get posts of {} ..." 72 | msgstr "" 73 | 74 | #: genshinhelper/mihoyo.py:246 75 | msgid "Successfully get {} posts" 76 | msgstr "" 77 | 78 | #: genshinhelper/mihoyo.py:250 79 | msgid "Preparing to view post {} ..." 80 | msgstr "" 81 | 82 | #: genshinhelper/mihoyo.py:261 83 | msgid "Preparing to upvote post {} ..." 84 | msgstr "" 85 | 86 | #: genshinhelper/mihoyo.py:273 87 | msgid "Preparing to share post {} ..." 88 | msgstr "" 89 | 90 | #: genshinhelper/utils.py:35 91 | #, python-brace-format 92 | msgid "" 93 | "\n" 94 | " {today:#^18}\n" 95 | " 🔅{nickname} {level} {region_name}\n" 96 | " Today's reward: {reward_name} × {reward_cnt}\n" 97 | " Total monthly check-ins: {total_sign_day} days\n" 98 | " Status: {status}\n" 99 | " {addons}\n" 100 | " {end:#^18}" 101 | msgstr "" 102 | 103 | #: genshinhelper/utils.py:44 104 | #, python-brace-format 105 | msgid "" 106 | "Traveler month {month} diary\n" 107 | " 💠primogems: {current_primogems}\n" 108 | " 🌕mora: {current_mora}" 109 | msgstr "" 110 | 111 | #: genshinhelper/utils.py:48 112 | #, python-brace-format 113 | msgid "" 114 | "Captain month {month} finance\n" 115 | " 💎hcoin: {month_hcoin}\n" 116 | " 🔮star: {month_star}" 117 | msgstr "" 118 | 119 | #: genshinhelper/utils.py:78 120 | #, python-brace-format 121 | msgid "" 122 | "Failed to convert:\n" 123 | "{response}" 124 | msgstr "" 125 | 126 | #: genshinhelper/utils.py:82 127 | #, python-brace-format 128 | msgid "" 129 | "Successful conversion!\n" 130 | "{app_cookie}" 131 | msgstr "" 132 | 133 | #: genshinhelper/utils.py:108 134 | #, python-brace-format 135 | msgid "" 136 | "Failed to extract cookie: The cookie does not contain the `{name}` field." 137 | msgstr "" 138 | 139 | #: genshinhelper/utils.py:218 140 | msgid "Request failed: {}" 141 | msgstr "" 142 | 143 | #: genshinhelper/utils.py:221 144 | msgid "Trying to reconnect in {} seconds ({}/{})..." 145 | msgstr "" 146 | -------------------------------------------------------------------------------- /genshinhelper/locale/genshinhelper.pot: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2021-11-01 14:25+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: genshinhelper/core.py:53 21 | msgid "Preparing to get user game roles information ..." 22 | msgstr "" 23 | 24 | #: genshinhelper/core.py:75 genshinhelper/mihoyo.py:130 25 | msgid "Preparing to get monthly rewards information ..." 26 | msgstr "" 27 | 28 | #: genshinhelper/core.py:115 29 | msgid "Preparing to claim daily reward ..." 30 | msgstr "" 31 | 32 | #: genshinhelper/core.py:119 33 | msgid "👀 You have already checked-in" 34 | msgstr "" 35 | 36 | #: genshinhelper/hoyolab.py:41 genshinhelper/mihoyo.py:45 37 | msgid "Preparing to get check-in information ..." 38 | msgstr "" 39 | 40 | #: genshinhelper/hoyolab.py:61 genshinhelper/mihoyo.py:61 41 | msgid "Preparing to get traveler's dairy ..." 42 | msgstr "" 43 | 44 | #: genshinhelper/__main__.py:21 45 | msgid "Converting cookie to mihoyo app cookie." 46 | msgstr "" 47 | 48 | #: genshinhelper/__main__.py:22 49 | msgid "" 50 | "Please enter your cookie, similar to `account_id=xxxxxx; " 51 | "login_ticket=xxxxxx`: " 52 | msgstr "" 53 | 54 | #: genshinhelper/mihoyo.py:84 55 | msgid "Preparing to get Yuan Shen daily note ..." 56 | msgstr "" 57 | 58 | #: genshinhelper/mihoyo.py:150 59 | msgid "Preparing to get Honkai 3rd finance ..." 60 | msgstr "" 61 | 62 | #: genshinhelper/mihoyo.py:201 63 | msgid "Preparing to get user missions state ..." 64 | msgstr "" 65 | 66 | #: genshinhelper/mihoyo.py:224 67 | msgid "Preparing to check-in for {} ..." 68 | msgstr "" 69 | 70 | #: genshinhelper/mihoyo.py:238 71 | msgid "Preparing to get posts of {} ..." 72 | msgstr "" 73 | 74 | #: genshinhelper/mihoyo.py:246 75 | msgid "Successfully get {} posts" 76 | msgstr "" 77 | 78 | #: genshinhelper/mihoyo.py:250 79 | msgid "Preparing to view post {} ..." 80 | msgstr "" 81 | 82 | #: genshinhelper/mihoyo.py:261 83 | msgid "Preparing to upvote post {} ..." 84 | msgstr "" 85 | 86 | #: genshinhelper/mihoyo.py:273 87 | msgid "Preparing to share post {} ..." 88 | msgstr "" 89 | 90 | #: genshinhelper/utils.py:35 91 | #, python-brace-format 92 | msgid "" 93 | "\n" 94 | " {today:#^18}\n" 95 | " 🔅{nickname} {level} {region_name}\n" 96 | " Today's reward: {reward_name} × {reward_cnt}\n" 97 | " Total monthly check-ins: {total_sign_day} days\n" 98 | " Status: {status}\n" 99 | " {addons}\n" 100 | " {end:#^18}" 101 | msgstr "" 102 | 103 | #: genshinhelper/utils.py:44 104 | #, python-brace-format 105 | msgid "" 106 | "Traveler month {month} diary\n" 107 | " 💠primogems: {current_primogems}\n" 108 | " 🌕mora: {current_mora}" 109 | msgstr "" 110 | 111 | #: genshinhelper/utils.py:48 112 | #, python-brace-format 113 | msgid "" 114 | "Captain month {month} finance\n" 115 | " 💎hcoin: {month_hcoin}\n" 116 | " 🔮star: {month_star}" 117 | msgstr "" 118 | 119 | #: genshinhelper/utils.py:78 120 | #, python-brace-format 121 | msgid "" 122 | "Failed to convert:\n" 123 | "{response}" 124 | msgstr "" 125 | 126 | #: genshinhelper/utils.py:82 127 | #, python-brace-format 128 | msgid "" 129 | "Successful conversion!\n" 130 | "{app_cookie}" 131 | msgstr "" 132 | 133 | #: genshinhelper/utils.py:108 134 | #, python-brace-format 135 | msgid "" 136 | "Failed to extract cookie: The cookie does not contain the `{name}` field." 137 | msgstr "" 138 | 139 | #: genshinhelper/utils.py:218 140 | msgid "Request failed: {}" 141 | msgstr "" 142 | 143 | #: genshinhelper/utils.py:221 144 | msgid "Trying to reconnect in {} seconds ({}/{})..." 145 | msgstr "" 146 | 147 | #: genshinhelper/core.py:140 141 148 | msgid "Verification code appears" 149 | msgstr "" 150 | -------------------------------------------------------------------------------- /genshinhelper/locale/zh/LC_MESSAGES/genshinhelper.po: -------------------------------------------------------------------------------- 1 | # SOME DESCRIPTIVE TITLE. 2 | # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER 3 | # This file is distributed under the same license as the PACKAGE package. 4 | # FIRST AUTHOR , YEAR. 5 | # 6 | #, fuzzy 7 | msgid "" 8 | msgstr "" 9 | "Project-Id-Version: PACKAGE VERSION\n" 10 | "Report-Msgid-Bugs-To: \n" 11 | "POT-Creation-Date: 2021-11-01 14:07+0800\n" 12 | "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 | "Last-Translator: FULL NAME \n" 14 | "Language-Team: LANGUAGE \n" 15 | "Language: \n" 16 | "MIME-Version: 1.0\n" 17 | "Content-Type: text/plain; charset=UTF-8\n" 18 | "Content-Transfer-Encoding: 8bit\n" 19 | 20 | #: genshinhelper/core.py:53 21 | msgid "Preparing to get user game roles information ..." 22 | msgstr "准备获取角色信息..." 23 | 24 | #: genshinhelper/core.py:75 genshinhelper/mihoyo.py:130 25 | msgid "Preparing to get monthly rewards information ..." 26 | msgstr "准备获取月度奖励..." 27 | 28 | #: genshinhelper/core.py:115 29 | msgid "Preparing to claim daily reward ..." 30 | msgstr "准备领取签到福利..." 31 | 32 | #: genshinhelper/core.py:119 33 | msgid "👀 You have already checked-in" 34 | msgstr "👀 你已经签到过了哦" 35 | 36 | #: genshinhelper/hoyolab.py:41 genshinhelper/mihoyo.py:45 37 | msgid "Preparing to get check-in information ..." 38 | msgstr "准备获取签到信息..." 39 | 40 | #: genshinhelper/hoyolab.py:61 genshinhelper/mihoyo.py:61 41 | msgid "Preparing to get traveler's dairy ..." 42 | msgstr "准备获取旅行者札记..." 43 | 44 | #: genshinhelper/__main__.py:21 45 | msgid "Converting cookie to mihoyo app cookie." 46 | msgstr "将米游社cookie转换成米游币cookie." 47 | 48 | #: genshinhelper/__main__.py:22 49 | msgid "" 50 | "Please enter your cookie, similar to `account_id=xxxxxx; " 51 | "login_ticket=xxxxxx`: " 52 | msgstr "" 53 | "请输入您的cookie, 格式 `account_id=xxxxxx; " 54 | "login_ticket=xxxxxx`: " 55 | 56 | #: genshinhelper/mihoyo.py:84 57 | msgid "Preparing to get Yuan Shen daily note ..." 58 | msgstr "准备获取实时便笺..." 59 | 60 | #: genshinhelper/mihoyo.py:150 61 | msgid "Preparing to get Honkai 3rd finance ..." 62 | msgstr "准备获取崩坏3手帐..." 63 | 64 | #: genshinhelper/mihoyo.py:201 65 | msgid "Preparing to get user missions state ..." 66 | msgstr "准备获取米游社任务状态..." 67 | 68 | #: genshinhelper/mihoyo.py:224 69 | msgid "Preparing to check-in for {} ..." 70 | msgstr "准备为 {} 签到..." 71 | 72 | #: genshinhelper/mihoyo.py:238 73 | msgid "Preparing to get posts of {} ..." 74 | msgstr "准备获取 {} 的帖子..." 75 | 76 | #: genshinhelper/mihoyo.py:246 77 | msgid "Successfully get {} posts" 78 | msgstr "成功获得 {} 个帖子" 79 | 80 | #: genshinhelper/mihoyo.py:250 81 | msgid "Preparing to view post {} ..." 82 | msgstr "准备浏览帖子 {} ..." 83 | 84 | #: genshinhelper/mihoyo.py:261 85 | msgid "Preparing to upvote post {} ..." 86 | msgstr "准备点赞帖子 {} ..." 87 | 88 | #: genshinhelper/mihoyo.py:273 89 | msgid "Preparing to share post {} ..." 90 | msgstr "准备分享帖子 {} ..." 91 | 92 | #: genshinhelper/utils.py:35 93 | #, python-brace-format 94 | msgid "" 95 | "\n" 96 | " {today:#^18}\n" 97 | " 🔅{nickname} {level} {region_name}\n" 98 | " Today's reward: {reward_name} × {reward_cnt}\n" 99 | " Total monthly check-ins: {total_sign_day} days\n" 100 | " Status: {status}\n" 101 | " {addons}\n" 102 | " {end:#^18}" 103 | msgstr "" 104 | "\n" 105 | " {today:#^18}\n" 106 | " 🔅{nickname} {level} {region_name}\n" 107 | " 今日奖励: {reward_name} × {reward_cnt}\n" 108 | " 本月累签: {total_sign_day} 天\n" 109 | " 签到结果: {status}\n" 110 | " {addons}\n" 111 | " {end:#^18}" 112 | 113 | #: genshinhelper/utils.py:44 114 | #, python-brace-format 115 | msgid "" 116 | "Traveler month {month} diary\n" 117 | " 💠primogems: {current_primogems}\n" 118 | " 🌕mora: {current_mora}" 119 | msgstr "" 120 | "旅行者 {month} 月札记\n" 121 | " 💠原石: {current_primogems}\n" 122 | " 🌕摩拉: {current_mora}" 123 | 124 | #: genshinhelper/utils.py:48 125 | #, python-brace-format 126 | msgid "" 127 | "Captain month {month} finance\n" 128 | " 💎hcoin: {month_hcoin}\n" 129 | " 🔮star: {month_star}" 130 | msgstr "" 131 | "舰长的 {month} 月手帐\n" 132 | " 💎水晶: {month_hcoin}\n" 133 | " 🔮星石: {month_star}" 134 | 135 | #: genshinhelper/utils.py:78 136 | #, python-brace-format 137 | msgid "" 138 | "Failed to convert:\n" 139 | "{response}" 140 | msgstr "" 141 | "转换失败:\n" 142 | "{response}" 143 | 144 | #: genshinhelper/utils.py:82 145 | #, python-brace-format 146 | msgid "" 147 | "Successful conversion!\n" 148 | "{app_cookie}" 149 | msgstr "" 150 | "转换成功!\n" 151 | "{app_cookie}" 152 | 153 | #: genshinhelper/utils.py:108 154 | #, python-brace-format 155 | msgid "" 156 | "Failed to extract cookie: The cookie does not contain the `{name}` field." 157 | msgstr "提取cookie失败: cookie 中未包含 `{name}` 字段." 158 | 159 | #: genshinhelper/utils.py:218 160 | msgid "Request failed: {}" 161 | msgstr "请求失败: {}" 162 | 163 | #: genshinhelper/utils.py:221 164 | msgid "Trying to reconnect in {} seconds ({}/{})..." 165 | msgstr "尝试在 {} 秒后重新连接 ({}/{})..." 166 | -------------------------------------------------------------------------------- /genshinhelper/hoyolab.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | from .core import Client, get_headers 9 | from .utils import request, log, nested_lookup, extract_subset_of_dict, config, _, merge_dicts 10 | 11 | _LANG_DICT = { 12 | 'zh': 'zh-cn', 13 | 'en': 'en-us' 14 | } 15 | 16 | 17 | class Genshin(Client): 18 | def __init__(self, cookie: str = None): 19 | super().__init__(cookie) 20 | self.headers = get_headers(oversea=True) 21 | self.api = 'https://sg-hk4e-api.hoyolab.com' 22 | self.act_id = 'e202102251931481' 23 | self.game_biz = 'hk4e_global' 24 | self.required_keys.update({ 25 | 'total_sign_day', 'today', 'is_sign', 'first_bind', 26 | 'current_primogems', 'current_mora' 27 | }) 28 | 29 | self.lang = _LANG_DICT.get(config.LANGUAGE, '') 30 | self.roles_info_url = 'https://api-os-takumi.mihoyo.com/binding/api/getUserGameRolesByCookie?game_biz={}' 31 | self.sign_info_url = f'{self.api}/event/sol/info?lang={self.lang}&act_id={self.act_id}' 32 | self.rewards_info_url = f'{self.api}/event/sol/home?lang={self.lang}&act_id={self.act_id}' 33 | self.sign_url = f'{self.api}/event/sol/sign?lang={self.lang}' 34 | 35 | self._travelers_dairy = None 36 | self.travelers_dairy_url = f'{self.api}/event/ysledgeros/month_info?lang={self.lang}&' + 'uid={}®ion={}&month={}' 37 | 38 | @property 39 | def sign_info(self): 40 | if not self._sign_info: 41 | log.info(_('Preparing to get check-in information ...')) 42 | url = self.sign_info_url 43 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 44 | log.debug(response) 45 | data = nested_lookup(response, 'data', fetch_first=True) 46 | if data: 47 | del data['region'] 48 | self._sign_info.append(extract_subset_of_dict(data, self.required_keys)) 49 | return self._sign_info 50 | 51 | @property 52 | def travelers_dairy(self): 53 | roles_info = self.roles_info 54 | self._travelers_dairy = [ 55 | self.get_travelers_dairy(i['game_uid'], i['region']) 56 | for i in roles_info 57 | ] 58 | return self._travelers_dairy 59 | 60 | def get_travelers_dairy(self, uid: str, region: str, month: int = 0): 61 | log.info(_("Preparing to get traveler's dairy ...")) 62 | url = self.travelers_dairy_url.format(uid, region, month) 63 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 64 | log.debug(response) 65 | return nested_lookup(response, 'data', fetch_first=True) 66 | 67 | @property 68 | def month_dairy(self): 69 | raw_month_data = nested_lookup(self.travelers_dairy, 'month_data') 70 | return [ 71 | extract_subset_of_dict(i, self.required_keys) 72 | for i in raw_month_data 73 | ] 74 | 75 | 76 | class StarRail(Client): 77 | def __init__(self, cookie: str = None): 78 | super().__init__(cookie) 79 | self.headers = get_headers(oversea=True) 80 | self.api = 'https://sg-public-api.hoyolab.com' 81 | self.act_id = 'e202303301540311' 82 | 83 | self.required_keys.update({ 84 | 'total_sign_day', 'today', 'is_sign', 'is_sub', 85 | 'sign_cnt_missed', 'short_sign_day' 86 | }) 87 | self.lang = _LANG_DICT.get(config.LANGUAGE, '') 88 | self.roles_info_url = '' 89 | self.sign_info_url = f'{self.api}/event/luna/info?lang={self.lang}&act_id={self.act_id}' 90 | self.rewards_info_url = f'{self.api}/event/luna/home?lang={self.lang}&act_id={self.act_id}' 91 | self.sign_url = f'{self.api}/event/luna/sign?lang={self.lang}' 92 | 93 | @property 94 | def sign_info(self): 95 | if not self._sign_info: 96 | log.info(_('Preparing to get check-in information ...')) 97 | url = self.sign_info_url 98 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 99 | log.debug(response) 100 | data = nested_lookup(response, 'data', fetch_first=True) 101 | log.debug(data) 102 | if data: 103 | del data['region'] 104 | self._sign_info.append(extract_subset_of_dict(data, self.required_keys)) 105 | log.debug(self._sign_info) 106 | return self._sign_info 107 | 108 | @property 109 | def user_data(self): 110 | sign_info = self.sign_info 111 | roles_info = '' 112 | current_reward = self.current_reward 113 | 114 | for i in range(len(sign_info)): 115 | # d1 = roles_info[i] 116 | d2 = sign_info[i] 117 | d3 = current_reward[i] 118 | # region of d2 is empty 119 | merged = merge_dicts(d2, d3) 120 | self._user_data.append(merged) 121 | return self._user_data -------------------------------------------------------------------------------- /genshinhelper/weibo.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | import re 9 | from urllib.parse import unquote 10 | 11 | from bs4 import BeautifulSoup 12 | 13 | from .utils import request, nested_lookup, cookie_to_dict 14 | 15 | 16 | class Weibo(object): 17 | def __init__(self, params: str = None, cookie: str = None): 18 | """ 19 | params: s=xxxxxx; gsid=xxxxxx; aid=xxxxxx; from=xxxxxx 20 | """ 21 | self.params = cookie_to_dict(params.replace('&', ';')) if params else None 22 | self.cookie = cookie_to_dict(cookie) 23 | self.container_id = '100808fc439dedbb06ca5fd858848e521b8716' 24 | self.ua = 'WeiboOverseas/4.4.6 (iPhone; iOS 14.0.1; Scale/2.00)' 25 | self.headers = {'User-Agent': self.ua} 26 | self.follow_data_url = 'https://api.weibo.cn/2/cardlist' 27 | self.sign_url = 'https://api.weibo.cn/2/page/button' 28 | self.event_url = f'https://m.weibo.cn/api/container/getIndex?containerid={self.container_id}_-_activity_list' 29 | self.mybox_url = 'https://ka.sina.com.cn/html5/mybox' 30 | self.draw_url = 'https://games.weibo.cn/prize/aj/lottery' 31 | self._follow_data = [] 32 | 33 | @property 34 | def follow_data(self): 35 | if not self._follow_data: 36 | url = self.follow_data_url 37 | self.params['containerid'] = '100803_-_followsuper' 38 | # turn off certificate verification 39 | response = request('get', url, params=self.params, headers=self.headers, cookies=self.cookie, verify=False).json() 40 | card_group = nested_lookup(response, 'card_group', fetch_first=True) 41 | follow_list = [i for i in card_group if i['card_type'] == '8'] 42 | for i in follow_list: 43 | action = nested_lookup(i, 'action', fetch_first=True) 44 | request_url = ''.join( 45 | re.findall('request_url=(.*)%26container', action)) if action else None 46 | follow = { 47 | 'name': nested_lookup(i, 'title_sub', fetch_first=True), 48 | 'level': int(re.findall('\d+', i['desc1'])[0]), 49 | 'is_sign': False if nested_lookup(i, 'name', fetch_first=True) == '签到' else True, 50 | 'request_url': request_url 51 | } 52 | self._follow_data.append(follow) 53 | 54 | self._follow_data.sort(key=lambda k: (k['level']), reverse=True) 55 | return self._follow_data 56 | 57 | def sign(self): 58 | result = [] 59 | for follow in self.follow_data: 60 | if not follow['is_sign']: 61 | url = self.sign_url 62 | self.params['request_url'] = follow['request_url'] 63 | if self.params.get('containerid'): 64 | del self.params['containerid'] 65 | # turn off certificate verification 66 | response = request('get', url, params=self.params, headers=self.headers, cookies=self.cookie, verify=False).json() 67 | follow['sign_response'] = response 68 | if int(response.get('result', -1)) == 1: 69 | follow['is_sign'] = True 70 | follow['request_url'] = None 71 | 72 | result.append(follow) 73 | return result 74 | 75 | @property 76 | def event_list(self): 77 | url = self.event_url 78 | response = request('get', url).json() 79 | return nested_lookup(response, 'group', fetch_first=True) 80 | 81 | def check_event(self): 82 | return True if self.event_list else False 83 | 84 | def get_event_gift_ids(self): 85 | return [ 86 | i 87 | for event in self.event_list 88 | for i in re.findall(r'ticket_id=(\d*)', unquote(unquote(event['scheme']))) 89 | ] 90 | 91 | def get_mybox_codes(self): 92 | url = self.mybox_url 93 | response = request('get', url, headers=self.headers, cookies=self.cookie, allow_redirects=False) 94 | if response.status_code != 200: 95 | raise Exception( 96 | 'Failed to get my box codes: ' 97 | 'The cookie seems to be invalid, please re-login to https://ka.sina.com.cn' 98 | ) 99 | 100 | response.encoding = 'utf-8' 101 | soup = BeautifulSoup(response.text, 'html.parser') 102 | # print(soup.prettify()) 103 | boxs = soup.find_all(class_='giftbag') 104 | mybox_codes = [] 105 | for box in boxs: 106 | item = { 107 | 'id': box.find(class_='deleBtn').get('data-itemid'), 108 | 'title': box.find(class_='title itemTitle').text, 109 | 'code': '`'+box.find('span').parent.contents[1]+'`' 110 | } 111 | mybox_codes.append(item) 112 | return mybox_codes 113 | 114 | def unclaimed_gift_ids(self): 115 | event_gift_ids = self.get_event_gift_ids() 116 | #mybox_gift_ids = [item.get('id') for item in self.get_mybox_codes()] 117 | #return [i for i in event_gift_ids if i not in mybox_gift_ids] 118 | return event_gift_ids 119 | 120 | def get_code(self, id: str): 121 | url = self.draw_url 122 | self.headers.update({ 123 | 'Referer': f'https://ka.sina.com.cn/html5/gift/{id}' 124 | }) 125 | data = { 126 | 'ext': '', 'ticket_id': id, 'aid': self.cookie['aid'], 'from': self.cookie['from'] 127 | } 128 | response = request('get', url, params=data, headers=self.headers, cookies=self.cookie).json() 129 | code = '`'+response['data']['prize_data']['card_no']+'`' if response['msg'] == 'success' or response['msg'] == 'recently' else False 130 | if response['msg'] == 'fail': 131 | response['msg'] = response['data']['fail_desc1'] 132 | result = {'success': True, 'id': id, 'code': code} if code else {'success': False, 'id': id, 'response': response} 133 | return result 134 | -------------------------------------------------------------------------------- /genshinhelper/core.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | import uuid 9 | 10 | from .exceptions import GenshinHelperException 11 | from .utils import request, log, get_ds, nested_lookup, extract_subset_of_dict, merge_dicts, cookie_to_dict, today, _ 12 | 13 | 14 | def get_headers(oversea: bool = False, with_ds: bool = False, *args, **kwargs): 15 | ua_cn = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBS/{}' 16 | ua_os = 'Mozilla/5.0 (iPhone; CPU iPhone OS 14_0_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) miHoYoBBSOversea/1.5.0' 17 | ua_default = ua_os if oversea else ua_cn 18 | app_version, client_type, ds = get_ds(*args, **kwargs) 19 | headers = {'User-Agent': ua_default.format(app_version)} 20 | if with_ds: 21 | headers.update({ 22 | 'x-rpc-device_id': 23 | str(uuid.uuid3(uuid.NAMESPACE_URL, ua_default)).replace( 24 | '-', '').upper(), 25 | 'x-rpc-client_type': client_type, 26 | 'x-rpc-app_version': app_version, 27 | 'DS': ds 28 | }) 29 | return headers 30 | 31 | 32 | class Client(object): 33 | def __init__(self, cookie: str = None): 34 | self.cookie = cookie_to_dict(cookie) 35 | self.headers = get_headers() 36 | self._roles_info = None 37 | self._sign_info = [] 38 | self._rewards_info = [] 39 | self._user_data = [] 40 | self.api = 'https://api-takumi.mihoyo.com' 41 | self.act_id = None 42 | self.game_biz = None 43 | self.required_keys = {'region', 'game_uid', 'nickname', 'level', 'region_name'} 44 | 45 | self.roles_info_url = f'{self.api}/binding/api/getUserGameRolesByCookie' + '?game_biz={}' 46 | self.sign_info_url = None 47 | self.rewards_info_url = None 48 | self.sign_url = None 49 | 50 | @property 51 | def roles_info(self): 52 | if not self._roles_info: 53 | log.info(_('Preparing to get user game roles information ...')) 54 | url = self.roles_info_url.format(self.game_biz) 55 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 56 | log.debug(response) 57 | if response.get('retcode') != 0: 58 | raise GenshinHelperException(response.get('message')) 59 | 60 | raw_roles_info = nested_lookup(response, 'list', fetch_first=True) 61 | self._roles_info = [ 62 | extract_subset_of_dict(i, self.required_keys) 63 | for i in raw_roles_info 64 | ] 65 | return self._roles_info 66 | 67 | @property 68 | def sign_info(self): 69 | ... 70 | return self._sign_info 71 | 72 | @property 73 | def rewards_info(self): 74 | if not self._rewards_info: 75 | log.info(_('Preparing to get monthly rewards information ...')) 76 | url = self.rewards_info_url 77 | response = request('get', url).json() 78 | self._rewards_info = nested_lookup(response, 'awards', fetch_first=True) 79 | return self._rewards_info 80 | 81 | @property 82 | def current_reward(self): 83 | sign_info = self.sign_info 84 | return [ 85 | self.get_current_reward(i['total_sign_day'], i['is_sign']) 86 | for i in sign_info 87 | ] 88 | 89 | def get_current_reward(self, total_sign_day: int, is_sign: bool = False): 90 | rewards_info = self.rewards_info 91 | if isinstance(rewards_info[0], list): 92 | rewards_info = rewards_info[0] 93 | if is_sign: 94 | total_sign_day -= 1 95 | 96 | raw_current_reward = rewards_info[total_sign_day] 97 | return {'reward_' + k: v for k, v in raw_current_reward.items()} 98 | 99 | @property 100 | def user_data(self): 101 | sign_info = self.sign_info 102 | roles_info = self.roles_info 103 | current_reward = self.current_reward 104 | 105 | for i in range(len(sign_info)): 106 | d1 = roles_info[i] 107 | d2 = sign_info[i] 108 | d3 = current_reward[i] 109 | # region of d2 is empty 110 | merged = merge_dicts(d2, d1, d3) 111 | self._user_data.append(merged) 112 | return self._user_data 113 | 114 | def sign(self): 115 | user_data = self.user_data 116 | log.info(_('Preparing to claim daily reward ...')) 117 | result = [] 118 | for i in range(len(user_data)): 119 | user_data[i]['today'] = str(today()) 120 | user_data[i]['status'] = _('👀 You have already checked-in') 121 | user_data[i]['addons'] = 'Olah! Odomu' 122 | user_data[i]['sign_response'] = None 123 | user_data[i]['end'] = '' 124 | total_sign_day = user_data[i]['total_sign_day'] 125 | is_sign = user_data[i]['is_sign'] 126 | 127 | if not is_sign: 128 | payload = { 129 | 'act_id': self.act_id, 130 | 'region': user_data[i]['region'], 131 | 'uid': user_data[i]['game_uid'] 132 | } 133 | response = request( 134 | 'post', 135 | self.sign_url, 136 | headers=get_headers(with_ds=True), 137 | json=payload, cookies=self.cookie).json() 138 | log.debug(response) 139 | if response["data"] != "" and response["data"]["success"] == 1: 140 | user_data[i]['status'] = _('verification code appears') 141 | user_data[i]['reward_name'] = _('verification code appears') 142 | else: 143 | user_data[i]['status'] = response.get('message', -1) 144 | user_data[i]['sign_response'] = response 145 | retcode = response.get('retcode', -1) 146 | # 0: success 147 | # -5003: already checked in 148 | if retcode == 0: 149 | user_data[i]['total_sign_day'] = total_sign_day + 1 150 | user_data[i]['is_sign'] = True 151 | result.append(user_data[i]) 152 | self._user_data = result 153 | return result 154 | -------------------------------------------------------------------------------- /genshinhelper/utils.py: -------------------------------------------------------------------------------- 1 | """Utilities. 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | import datetime 9 | import gettext 10 | import hashlib 11 | import json 12 | import logging 13 | import os 14 | import random 15 | import string 16 | import time 17 | import uuid 18 | from urllib.parse import urlencode 19 | 20 | import requests 21 | 22 | from genshinhelper import config 23 | 24 | logging.basicConfig( 25 | level=logging.INFO, 26 | format='%(asctime)s %(levelname)s %(message)s', 27 | datefmt='%Y-%m-%d %H:%M:%S') 28 | 29 | log = logger = logging 30 | 31 | _localedir = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'locale') 32 | _translate = gettext.translation( 33 | 'genshinhelper', _localedir, languages=[config.LANGUAGE], fallback=True) 34 | _ = _translate.gettext 35 | 36 | MESSAGE_TEMPLATE = _(''' 37 | {today:#^18} 38 | 🔅{nickname} {level} {region_name} 39 | Today's reward: {reward_name} × {reward_cnt} 40 | Total monthly check-ins: {total_sign_day} days 41 | Status: {status} 42 | {addons} 43 | {end:#^18}''') 44 | 45 | DAIRY_TEMPLATE = _('''Traveler month {month} diary 46 | 💠primogems: {current_primogems} 47 | 🌕mora: {current_mora}''') 48 | 49 | FINANCE_TEMPLATE = _('''Captain month {month} finance 50 | 💎hcoin: {month_hcoin} 51 | 🔮star: {month_star}''') 52 | 53 | 54 | def set_lang(lang=None): 55 | if lang: 56 | os.environ['LANGUAGE'] = lang 57 | 58 | 59 | def today(): 60 | return datetime.date.today() 61 | 62 | 63 | def month(): 64 | return today().month 65 | 66 | 67 | def get_mihoyo_app_cookie(cookie): 68 | if 'stoken' in cookie: 69 | return cookie 70 | 71 | cookie_dict = cookie_to_dict(cookie) 72 | stuid = cookie_dict['account_id'] 73 | login_ticket = cookie_dict['login_ticket'] 74 | url = 'https://api-takumi.mihoyo.com/auth/api/getMultiTokenByLoginTicket?uid={}&login_ticket={}&token_types=3'.format(stuid, login_ticket) 75 | response = request('get', url).json() 76 | list = nested_lookup(response, 'list', fetch_first=True) 77 | stoken = nested_lookup([i for i in list if i['name'] == 'stoken'], 'token', fetch_first=True) 78 | if not stoken: 79 | log.error(_('Failed to convert:\n{response}').format(response=response)) 80 | return 81 | 82 | app_cookie = f'stuid={stuid}; stoken={stoken}; login_ticket={login_ticket}' 83 | log.info(_(f'Successful conversion!\n{app_cookie}').format(app_cookie=app_cookie)) 84 | return app_cookie 85 | 86 | 87 | def minutes_to_hours(minutes): 88 | minutes = int(minutes) 89 | if minutes < 0: 90 | raise ValueError('Input number cannot be negative') 91 | 92 | return {'hour': int(minutes / 60), 'minute': minutes % 60} 93 | 94 | 95 | def get_cookies(cookies: str = None): 96 | if '#' in cookies: 97 | return cookies.split('#') 98 | elif isinstance(cookies, list): 99 | return cookies 100 | elif '{' in cookies: 101 | return json.loads(cookies) 102 | else: 103 | return cookies.splitlines() 104 | 105 | 106 | def extract_cookie(name: str, cookie: str): 107 | if name not in cookie: 108 | raise Exception( 109 | _('Failed to extract cookie: The cookie does not contain the `{name}` field.').format( 110 | name=name 111 | ) 112 | ) 113 | return cookie.split(f'{name}=')[1].split(';')[0] 114 | 115 | 116 | def cookie_to_dict(cookie): 117 | if cookie and '=' in cookie: 118 | cookie = dict([line.strip().split('=', 1) for line in cookie.split(';')]) 119 | return cookie 120 | 121 | 122 | def merge_dicts(*dict_args): 123 | result = {} 124 | for d in dict_args: 125 | result.update(d) 126 | return result 127 | 128 | 129 | def extract_subset_of_dict(raw_dict, keys): 130 | subset = {} 131 | if isinstance(raw_dict, dict): 132 | subset = {key: value for key, value in raw_dict.items() if key in keys} 133 | return subset 134 | 135 | 136 | def nested_lookup(obj, key, with_keys=False, fetch_first=False): 137 | result = list(_nested_lookup(obj, key, with_keys=with_keys)) 138 | if with_keys: 139 | values = [v for k, v in _nested_lookup(obj, key, with_keys=with_keys)] 140 | result = {key: values} 141 | if fetch_first: 142 | result = result[0] if result else result 143 | return result 144 | 145 | 146 | def _nested_lookup(obj, key, with_keys=False): 147 | if isinstance(obj, list): 148 | for i in obj: 149 | yield from _nested_lookup(i, key, with_keys=with_keys) 150 | 151 | if isinstance(obj, dict): 152 | for k, v in obj.items(): 153 | if key == k: 154 | if with_keys: 155 | yield k, v 156 | else: 157 | yield v 158 | 159 | if isinstance(v, list) or isinstance(v, dict): 160 | yield from _nested_lookup(v, key, with_keys=with_keys) 161 | 162 | 163 | def get_ds(ds_type: str = None, new_ds: bool = False, data: dict = None, params: dict = None): 164 | # 1: ios 165 | # 2: android 166 | # 4: pc web 167 | # 5: mobile web 168 | def new(): 169 | t = str(int(time.time())) 170 | r = str(random.randint(100001, 200000)) 171 | b = json.dumps(data) if data else '' 172 | q = urlencode(params) if params else '' 173 | c = _hexdigest(f'salt={salt}&t={t}&r={r}&b={b}&q={q}') 174 | return f'{t},{r},{c}' 175 | 176 | def old(): 177 | t = str(int(time.time())) 178 | r = ''.join(random.sample(string.ascii_lowercase + string.digits, 6)) 179 | c = _hexdigest(f'salt={salt}&t={t}&r={r}') 180 | return f'{t},{r},{c}' 181 | 182 | app_version = '2.36.1' 183 | client_type = '5' 184 | salt = 'YVEIkzDFNHLeKXLxzqCA9TzxCpWwbIbk' 185 | ds = old() 186 | if ds_type == '2' or ds_type == 'android': 187 | app_version = '2.36.1' 188 | client_type = '2' 189 | salt = 'n0KjuIrKgLHh08LWSCYP0WXlVXaYvV64' 190 | ds = old() 191 | if ds_type == 'android_new': 192 | app_version = '2.36.1' 193 | client_type = '2' 194 | salt = 't0qEgfub6cvueAPgR5m9aQWWVciEer7v' 195 | ds = new() 196 | if new_ds: 197 | app_version = '2.36.1' 198 | client_type = '5' 199 | salt = 'xV8v4Qu54lUKrEYFZkJhB8cuOh9Asafs' 200 | ds = new() 201 | 202 | return app_version, client_type, ds 203 | 204 | 205 | def get_device_id(name: str = None): 206 | return str(uuid.uuid3(uuid.NAMESPACE_URL, name)) 207 | 208 | 209 | def _hexdigest(text): 210 | md5 = hashlib.md5() 211 | md5.update(text.encode()) 212 | return md5.hexdigest() 213 | 214 | 215 | def request(*args, **kwargs): 216 | is_retry = True 217 | count = 0 218 | max_retries = 3 219 | sleep_seconds = 5 220 | while is_retry and count <= max_retries: 221 | try: 222 | s = requests.Session() 223 | response = s.request(*args, **kwargs) 224 | is_retry = False 225 | except Exception as e: 226 | if count == max_retries: 227 | raise e 228 | log.error(_('Request failed: {}').format(e)) 229 | count += 1 230 | log.info( 231 | _('Trying to reconnect in {} seconds ({}/{})...').format( 232 | sleep_seconds, count, max_retries)) 233 | time.sleep(sleep_seconds) 234 | else: 235 | return response 236 | 237 | -------------------------------------------------------------------------------- /genshinhelper/mihoyo.py: -------------------------------------------------------------------------------- 1 | """ 2 | @Project : genshinhelper 3 | @Author : y1ndan 4 | @Blog : https://www.yindan.me 5 | @GitHub : https://github.com/y1ndan 6 | """ 7 | 8 | import random 9 | import time 10 | 11 | from .core import Client, get_headers 12 | from .utils import request, log, nested_lookup, extract_subset_of_dict, merge_dicts, cookie_to_dict, get_device_id, _ 13 | 14 | 15 | class YuanShen(Client): 16 | def __init__(self, cookie: str = None): 17 | super().__init__(cookie) 18 | self.act_id = 'e202009291139501' 19 | self.game_biz = 'hk4e_cn' 20 | self.required_keys.update({ 21 | 'total_sign_day', 'today', 'is_sign', 'first_bind', 22 | 'current_primogems', 'current_mora' 23 | }) 24 | 25 | self.sign_info_url = f'{self.api}/event/bbs_sign_reward/info?act_id={self.act_id}' + '&uid={}®ion={}' 26 | self.rewards_info_url = f'{self.api}/event/bbs_sign_reward/home?act_id={self.act_id}' 27 | self.sign_url = f'{self.api}/event/bbs_sign_reward/sign' 28 | 29 | self._travelers_dairy = None 30 | self._daily_note = None 31 | self.travelers_dairy_url = 'https://hk4e-api.mihoyo.com/event/ys_ledger/monthInfo?bind_uid={}&bind_region={}&month={}&bbs_presentation_style=fullscreen&bbs_auth_required=true&mys_source=GameRecord' 32 | self.daily_note_url = 'https://api-takumi-record.mihoyo.com/game_record/app/genshin/api/dailyNote' 33 | 34 | @property 35 | def sign_info(self): 36 | if not self._sign_info: 37 | roles_info = self.roles_info 38 | self._sign_info = [ 39 | self.get_sign_info(i['game_uid'], i['region']) 40 | for i in roles_info 41 | ] 42 | return self._sign_info 43 | 44 | def get_sign_info(self, uid: str, region: str): 45 | log.info(_('Preparing to get check-in information ...')) 46 | url = self.sign_info_url.format(uid, region) 47 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 48 | data = nested_lookup(response, 'data', fetch_first=True) 49 | return extract_subset_of_dict(data, self.required_keys) 50 | 51 | @property 52 | def travelers_dairy(self): 53 | roles_info = self.roles_info 54 | """ 55 | self._travelers_dairy = [ 56 | self.get_travelers_dairy(i['game_uid'], i['region']) 57 | for i in roles_info 58 | ] 59 | """ 60 | """ 61 | 修复等级不足10级时无法查看旅行者札记(无法获取每个月获得的摩拉原石数量) 62 | 导致 _tp 为None 63 | 使 genshin-checkin-help 中会出现`list index out of range`的bug 64 | """ 65 | self._travelers_dairy = [] 66 | for i in roles_info: 67 | _tp = self.get_travelers_dairy(i['game_uid'], i['region']) 68 | if _tp is None: 69 | self._travelers_dairy.append({'month_data': {}}) 70 | else: 71 | self._travelers_dairy.append(_tp) 72 | 73 | return self._travelers_dairy 74 | 75 | def get_travelers_dairy(self, uid: str, region: str, month: int = 0): 76 | log.info(_("Preparing to get traveler's dairy ...")) 77 | url = self.travelers_dairy_url.format(uid, region, month) 78 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 79 | return nested_lookup(response, 'data', fetch_first=True) 80 | 81 | @property 82 | def month_dairy(self): 83 | raw_month_data = nested_lookup(self.travelers_dairy, 'month_data') 84 | return [ 85 | extract_subset_of_dict(i, self.required_keys) 86 | for i in raw_month_data 87 | ] 88 | 89 | @property 90 | def daily_note(self): 91 | roles_info = self.roles_info 92 | self._daily_note = [ 93 | self.get_daily_note(i['game_uid'], i['region']) 94 | for i in roles_info 95 | ] 96 | return self._daily_note 97 | 98 | def get_daily_note(self, uid: str, region: str): 99 | log.info(_('Preparing to get Yuan Shen daily note ...')) 100 | url = self.daily_note_url 101 | payload = { 102 | 'role_id': uid, 103 | 'server': region 104 | } 105 | response = request('get', url, headers=get_headers(with_ds=True, new_ds=True, params=payload), params=payload, cookies=self.cookie).json() 106 | data = nested_lookup(response, 'data', fetch_first=True) 107 | return data if data else response 108 | 109 | 110 | class Honkai3rd(Client): 111 | def __init__(self, cookie: str = None): 112 | super().__init__(cookie) 113 | self.act_id = 'e202207181446311' 114 | self.game_biz = 'bh3_cn' 115 | self.required_keys.update({ 116 | 'total_sign_day', 'today', 'is_sign', 'first_bind', 117 | 'month_hcoin', 'month_star' 118 | }) 119 | 120 | self.sign_info_url = f'{self.api}/event/luna/info?act_id={self.act_id}' + '&uid={}®ion={}' 121 | self.rewards_info_url = f'{self.api}/event/luna/home?act_id={self.act_id}' 122 | self.sign_url = f'{self.api}/event/luna/sign' 123 | 124 | self._bh3_finance = None 125 | self.bh3_finance_url = 'https://api.mihoyo.com/bh3-weekly_finance/api/index?bind_uid={}&bind_region={}&game_biz=bh3_cn' 126 | 127 | @property 128 | def sign_info(self): 129 | if not self._sign_info: 130 | roles_info = self.roles_info 131 | self._sign_info = [ 132 | self.get_sign_info(i['game_uid'], i['region']) 133 | for i in roles_info 134 | ] 135 | return self._sign_info 136 | 137 | def get_sign_info(self, uid: str, region: str): 138 | log.info(_('Preparing to get check-in information ...')) 139 | url = self.sign_info_url.format(uid, region) 140 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 141 | data = nested_lookup(response, 'data', fetch_first=True) 142 | return extract_subset_of_dict(data, self.required_keys) 143 | 144 | @property 145 | def bh3_finance(self): 146 | roles_info = self.roles_info 147 | self._bh3_finance = [ 148 | self.get_bh3_finance(i['game_uid'], i['region']) 149 | for i in roles_info 150 | ] 151 | return self._bh3_finance 152 | 153 | # Requires the game roles level greater than 25 154 | def get_bh3_finance(self, uid: str, region: str): 155 | log.info(_('Preparing to get Honkai 3rd finance ...')) 156 | url = self.bh3_finance_url.format(uid, region) 157 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 158 | return nested_lookup(response, 'data', fetch_first=True) 159 | 160 | @property 161 | def month_finance(self): 162 | bh3_finance = self.bh3_finance 163 | return [ 164 | extract_subset_of_dict(i, self.required_keys) 165 | for i in bh3_finance 166 | ] 167 | 168 | 169 | class MysDailyMissions(object): 170 | def __init__(self, cookie: str = None): 171 | self.cookie = cookie_to_dict(cookie) 172 | self.api = 'https://bbs-api.mihoyo.com' 173 | self.state_url = f'{self.api}/apihub/sapi/getUserMissionsState' 174 | self.sign_url = f'{self.api}/apihub/app/api/signIn' 175 | self.post_list_url = f'{self.api}/post/api/getForumPostList?&is_good=false&is_hot=false&page_size=20&sort_type=1' + '&forum_id={}' 176 | self.post_full_url = f'{self.api}/post/api/getPostFull' + '?post_id={}' 177 | self.upvote_url = f'{self.api}/apihub/sapi/upvotePost' 178 | self.share_url = f'{self.api}/apihub/api/getShareConf?entity_type=1' + '&entity_id={}' 179 | 180 | self._missions_state = None 181 | self._posts = None 182 | 183 | self.game_ids_dict = {1: '崩坏3', 2: '原神', 3: '崩坏2', 4: '未定事件簿', 5: '大别野', 6: '崩坏: 星穹铁道', 8: '绝区零'} 184 | self.forum_ids_dict = {1: '崩坏3', 26: '原神', 30: '崩坏2', 37: '未定事件簿', 34: '大别野', 52: '崩坏: 星穹铁道', 57: '绝区零'} 185 | self.game_ids = list(self.game_ids_dict.keys()) 186 | self.forum_ids = list(self.forum_ids_dict.keys()) 187 | self.result = { 188 | 'sign': [], 189 | 'view': [], 190 | 'upvote': [], 191 | 'share': [] 192 | } 193 | 194 | @property 195 | def headers(self): 196 | headers = get_headers(with_ds=True, ds_type='android') 197 | headers.update({ 198 | 'User-Agent': 'okhttp/4.8.0', 199 | 'Referer': 'https://app.mihoyo.com', 200 | 'x-rpc-channel': 'miyousheluodi', 201 | 'x-rpc-device_id': get_device_id(str(self.cookie)), 202 | }) 203 | return headers 204 | 205 | @property 206 | def missions_state(self): 207 | log.info(_('Preparing to get user missions state ...')) 208 | url = self.state_url 209 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 210 | data = nested_lookup(response, 'data') 211 | states = nested_lookup(response, 'states', fetch_first=True) 212 | _missions_state = { 213 | i['mission_key']: i['is_get_award'] for i in states if i['mission_id'] in (58, 59, 60, 61) 214 | } 215 | self._missions_state = { 216 | 'total_points': nested_lookup(data, 'total_points', fetch_first=True), 217 | 'is_sign': _missions_state.get('continuous_sign', False), 218 | 'is_view': _missions_state.get('view_post_0', False), 219 | 'is_upvote': _missions_state.get('post_up_0', False), 220 | 'is_share': _missions_state.get('share_post_0', False) 221 | } 222 | return self._missions_state 223 | 224 | def sign(self, game_id: int = None): 225 | if not game_id: 226 | game_id = random.choice(self.game_ids) 227 | if game_id not in self.game_ids: 228 | raise ValueError(f'The value of game_id is one of {self.game_ids}') 229 | 230 | log.info(_('Preparing to check-in for {} ...').format(self.game_ids_dict[game_id])) 231 | url = self.sign_url 232 | data = {'gids': str(game_id)} 233 | headers = get_headers(with_ds=True, ds_type='android_new', data=data) 234 | headers.update({ 235 | 'User-Agent': 'okhttp/4.8.0', 236 | 'Referer': 'https://app.mihoyo.com', 237 | 'x-rpc-channel': 'miyousheluodi', 238 | 'x-rpc-device_id': get_device_id(str(self.cookie)), 239 | }) 240 | response = request('post', url, json=data, headers=headers, cookies=self.cookie).json() 241 | message = response.get('message') 242 | result = {'name': self.game_ids_dict[game_id], 'message': message} 243 | self.result['sign'].append(result) 244 | return result 245 | 246 | def get_posts(self, forum_id: int = None): 247 | if not forum_id: 248 | forum_id = random.choice(self.forum_ids) 249 | if forum_id not in self.forum_ids: 250 | raise ValueError(f'The value of forum_id is one of {self.forum_ids}') 251 | 252 | log.info(_('Preparing to get posts of {} ...').format(self.forum_ids_dict[forum_id])) 253 | url = self.post_list_url.format(forum_id) 254 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 255 | post_list = nested_lookup(response, 'list', fetch_first=True) 256 | posts = [{ 257 | 'post_id': nested_lookup(post, 'post_id', fetch_first=True), 258 | 'title': nested_lookup(post, 'subject', fetch_first=True) 259 | } for post in post_list] 260 | log.info(_('Successfully get {} posts').format(len(posts))) 261 | return posts 262 | 263 | def view_post(self, post: dict): 264 | log.info(_('Preparing to view post {} ...').format(post['title'])) 265 | time.sleep(3) 266 | url = self.post_full_url.format(post['post_id']) 267 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 268 | message = response.get('message') 269 | log.info(message) 270 | result = {'title': post['title'], 'message': message} 271 | self.result['view'].append(result) 272 | return result 273 | 274 | def upvote_post(self, post: dict): 275 | log.info(_('Preparing to upvote post {} ...').format(post['title'])) 276 | time.sleep(3) 277 | url = self.upvote_url 278 | data = {'post_id': post['post_id'], 'is_cancel': False} 279 | response = request('post', url, json=data, headers=self.headers, cookies=self.cookie).json() 280 | message = response.get('message') 281 | log.info(message) 282 | result = {'title': post['title'], 'message': message} 283 | self.result['upvote'].append(result) 284 | return result 285 | 286 | def share_post(self, post: dict): 287 | log.info(_('Preparing to share post {} ...').format(post['title'])) 288 | url = self.share_url.format(post['post_id']) 289 | response = request('get', url, headers=self.headers, cookies=self.cookie).json() 290 | message = response.get('message') 291 | log.info(message) 292 | result = {'title': post['title'], 'message': message} 293 | self.result['share'].append(result) 294 | return result 295 | 296 | def run(self, forum_id: int = None): 297 | state = self.missions_state 298 | [self.sign(i) for i in self.game_ids if not state['is_sign']] 299 | 300 | posts = self.get_posts(forum_id) 301 | [self.view_post(i) for i in random.sample(posts[0:8], 5) if not state['is_view']] 302 | [self.upvote_post(i) for i in random.sample(posts[5:17], 10) if not state['is_upvote']] 303 | [self.share_post(i) for i in random.sample(posts[-3:-1], 1) if not state['is_share']] 304 | 305 | state = self.missions_state 306 | self.result = merge_dicts(state, self.result) 307 | return self.result 308 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . --------------------------------------------------------------------------------