diff options
| author | Kyomotoi <1172294279@qq.com> | 2020-08-18 22:47:39 +0800 | 
|---|---|---|
| committer | Kyomotoi <1172294279@qq.com> | 2020-08-18 22:47:39 +0800 | 
| commit | 0d3d479a9b98aab47fb84ce0f5eadff17ff5d046 (patch) | |
| tree | f57fb390c6155060d8119b6f1d2895e2aa07fb8e /ATRI/modules | |
| parent | 636a16033ccb426a888e4f8a7d411e5fcb68faf2 (diff) | |
| download | ATRI-0d3d479a9b98aab47fb84ce0f5eadff17ff5d046.tar.gz ATRI-0d3d479a9b98aab47fb84ce0f5eadff17ff5d046.tar.bz2 ATRI-0d3d479a9b98aab47fb84ce0f5eadff17ff5d046.zip | |
[Update]
Diffstat (limited to 'ATRI/modules')
| -rw-r--r-- | ATRI/modules/b64/__init__.py | 37 | ||||
| -rw-r--r-- | ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc | bin | 1022 -> 831 bytes | 
2 files changed, 11 insertions, 26 deletions
| diff --git a/ATRI/modules/b64/__init__.py b/ATRI/modules/b64/__init__.py index cb5387a..f54334b 100644 --- a/ATRI/modules/b64/__init__.py +++ b/ATRI/modules/b64/__init__.py @@ -1,37 +1,22 @@  import os +import time  import base64 +import requests  from pathlib import Path -path_emoji = Path('.') / 'ATRI' / 'data' / 'emoji'  path_temp_img = Path('.') / 'ATRI' / 'data' / 'temp' / 'img' -path_img = Path('.') / 'ATRI' / 'data' / 'img' -def b64_str_emoji(file_name: str): -    find_file = os.path.join(str(path_emoji) + '/' + file_name) -    with open(find_file, 'rb') as f: -        content = f.read() -    b64_str = base64.b64encode(content).decode() -    return b64_str - -# def b64_str_img_url(url: str): -#     img_d = requests.get(url) -#     name = 'temp.jpg' -#     with open(str(path_temp_img) + '/' + name, 'wb') as f: -#         f.write(img_d.content) -#     find_img = os.path.join(str(path_temp_img) + '/' + name) -#     with open(find_img, 'rb') as f: -#         content = f.read() -#     img = ImageGrab. -#     b64_str = base64.b64encode(content).decode() -#     time.sleep(1) -#     os.remove(str(path_temp_img) + '/' + name) -#     return b64_str - -def b64_str_img_path(file_name: str): -    find_file = os.path.join(str(path_img) + '/' + file_name) -    with open(find_file, 'rb') as f: +def b64_str_img_url(url: str): +    img_d = requests.get(url) +    name = 'temp.jpg' +    with open(str(path_temp_img) + '/' + name, 'wb') as f: +        f.write(img_d.content) +    find_img = os.path.join(str(path_temp_img) + '/' + name) +    with open(find_img, 'rb') as f:          content = f.read()      b64_str = base64.b64encode(content).decode() +    time.sleep(1) +    os.remove(str(path_temp_img) + '/' + name)      return b64_str
\ No newline at end of file diff --git a/ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc b/ATRI/modules/b64/__pycache__/__init__.cpython-38.pycBinary files differ index 5b3821c..b23fb54 100644 --- a/ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc +++ b/ATRI/modules/b64/__pycache__/__init__.cpython-38.pyc | 
