Skip to main content

TraceMoePY

Codacy Badge PyPI version Downloads Code style

Install

  • Install using pip: pip install tracemoepy

Examples

  • All the examples below are after this piece of code:
import tracemoepy
tracemoe = tracemoepy.tracemoe.TraceMoe()
  • Search image using url:
resp = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
print(resp.prettify())
print(f"Match: {resp.result[0].anilist.title.romaji}\nSimilarity: {resp.result[0].similarity*100}")
  • Or just file path:
print(tracemoe.search('image.jpg', upload_file=True))
  • Save Video Preview:
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
output.result[0].save('preview.mp4', mute = False) # True for silent
  • Save Video preview (2)
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
video = tracemoe.natural_preview(output)
with open('preview.mp4', 'wb') as f:
  f.write(video)
  • Save Image Preview
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
output.result[0].save(save_path = 'preview.png', preview_type="image")
  • Image Preview (Method 2)
output = tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
tracemoe.image_preview(output) # Gives content
  • You can do help(method_name) to get more info about the given method
help(tracemoe.search)

Asyncio

All the examples below assume you are running this inside a async function

  • Basic search (AioHttp session is not closed, You can access it as .aio_session)
import tracemoepy
tracemoe = tracemoepy.AsyncTrace()
resp = await tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
print(f"Match: {resp.result[0].anilist.title.romaji}\nSimilarity: {resp.result[0].similarity*100}")
  • Auto close session
import tracemoepy
async with tracemoepy.AsyncTrace() as tracemoe:
  resp = await tracemoe.search('https://trace.moe/img/flipped-good.jpg', is_url = True)
  print(f"Match: {resp.result[0].anilist.title.romaji}\nSimilarity: {resp.result[0].similarity*100}")

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.
  • InvalidPath: Invalid path was given, This is only raised by .save(...) method
  • 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

Metadata

Release files for tracemoepy 4.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for tracemoepy 4.1
File Size Uploaded
tracemoepy-4.1.tar.gz 9.5 kB Details

Release files / tracemoepy-4.1.tar.gz

Download URL tracemoepy-4.1.tar.gz
Size 9.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f2fc60cdd92e359bf740b58b00cf386d98e6b31b9065ef357a0041e692409e62
BLAKE2b-256 checksum
How to use checksums
eda6eabd996f20707670093774aff612e76eac5ac98f519f7baccc0ca47eafb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.0 CPython/3.10.0b1

Release history Release notifications | RSS feed

This release

4.1 This release

1 release file

4.0

1 release file

3.8

1 release file

3.7

1 release file

3.6

1 release file

3.5

1 release file

3.4

1 release file

3.3

1 release file

3.2

1 release file

3.1

1 release file

3.0

1 release file

2.0

1 release file

1.0

1 release file

0.9

1 release file

0.8

1 release file

0.7

1 release file

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.2

1 release file

0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page