Trace.moe python wrapper
Project description
tracemoepy
Install
- Install using pip:
pip install tracemoepy
Examples
- All the examples below are after this piece of code:
import tracemoepy
tracemoe = tracemoepy.tracemoe.TraceMoe()
- You can search image like:
print(tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True))
- Or if you provide base64 encoded image:
print(tracemoe.search(image, encode=False))
- Or if you want to just provide the image, The wrapper will encode image using base64:
print(tracemoe.search('a.jpg', encode=True))
- Video Preview (Gives content):
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
tracemoe.video_preview(output)
- Save video preview
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
video = tracemoe.video_preview(output)
with open('preview.mp4', 'wb') as f:
f.write(video)
Asyncio
import tracemoepy
import asyncio
tracemoe = tracemoe.asynctrace.Async_Trace()
async def anything():
#return await + Anything from the above examples
#like:
return await tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
loop = asyncio.get_event_loop()
loop.run_until_complete(anything())
Errors
TooManyRequests
: Raised when API Limit is reached or Too many requests in short period of time.EntityTooLarge
: Raised when image size is greater than max size of 10MB.ServerError
: Raised when Something wrong with the trace.moe server or Image provided was malformed.InvalidToken
: Raised when Invalid token was provided.EmptyImage
: Raised when Image provided was empty.- All these errors are located at tracemoepy.errors, Example of handling Exception:
from tracemoepy.errors import TooManyRequests
try:
# Do something
except TooManyRequests as t:
print(t)
# Do something if error
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
tracemoepy-3.4.tar.gz
(6.1 kB
view details)
File details
Details for the file tracemoepy-3.4.tar.gz
.
File metadata
- Download URL: tracemoepy-3.4.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.6.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fba63348885fe530e4de0b28736954446e3266c061a422f5d15366e570f57f1 |
|
MD5 | dfd092ccf6c75e23a876fe853fa2cbb3 |
|
BLAKE2b-256 | 7c6bdc0fb16a8599d0e8509f2df04fdff344027df9b2d10d32f034e4ea10078d |